From 4477267905374f88d5992f7d1ea7c6a69e4d4c3a Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Mon, 11 May 2020 03:48:24 +0400 Subject: Генератор списка файлов "events.xml" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/parser.rs | 60 ----------------------------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 src/parser.rs (limited to 'src/parser.rs') diff --git a/src/parser.rs b/src/parser.rs deleted file mode 100644 index 1c862c4..0000000 --- a/src/parser.rs +++ /dev/null @@ -1,60 +0,0 @@ -use std::fs::File; -use std::io::BufReader; - -use serde_json::Value; -use xml::reader::{EventReader, XmlEvent}; - -#[derive(Serialize)] -pub struct ParserResult { - pub context: Value, - pub external_id: String, - pub meeting_id: String, - pub meeting_name: String, - pub meeting_url: String, -} - -pub fn parser(content: BufReader) -> ParserResult { - let mut data = ParserResult { - context: serde_json::from_str("{}").unwrap(), - external_id: "".to_string(), - meeting_id: "".to_string(), - meeting_name: "".to_string(), - meeting_url: "".to_string(), - }; - - for element in EventReader::new(content) { - match element { - Ok(XmlEvent::StartElement { - name, attributes, .. - }) => { - let el_name = name.local_name.to_string(); - - for attribute in attributes { - let attr_name: String = attribute.name.local_name.to_string(); - let attr_value: String = attribute.value.to_string(); - - if el_name == "metadata" && attr_name == "bn-recording-status" { - data.context = serde_json::from_str(&attr_value).unwrap(); - } - - if el_name == "metadata" && attr_name == "meetingId" { - data.external_id = attr_value.clone(); - } - - if el_name == "recording" && attr_name == "meeting_id" { - data.meeting_id = attr_value.clone(); - data.meeting_url = format!("{}{}", "https://bbb.styleschool.ru/playback/presentation/0.9.0/playback.html?meetingId=", attr_value); - } - - if el_name == "metadata" && attr_name == "meetingName" { - data.meeting_name = attr_value.clone(); - } - } - } - Err(error) => panic!(error), - _ => {} - } - } - - return data; -} -- cgit v1.2.3