youtube_dl_parser/state/parsed_state/
ffmpeg_state.rs1pub enum FFmpegState {
3 Destination(String),
4 ParseError(String),
5}
6
7impl FFmpegState {
8 pub fn parse<'a>(mut split: impl DoubleEndedIterator<Item = &'a str> + Send) -> FFmpegState {
9 let Some(first_word)= split.next() else { return FFmpegState::ParseError("Unable to get destination of mp3 file".to_owned())};
10 match first_word {
11 "Destination:" => {
12 let destination = split.collect::<Vec<&str>>().join(" ");
13 FFmpegState::Destination(destination)
14 }
15 "Merging" => {
16 split.next();
17 split.next();
18 let destination = split.collect::<Vec<&str>>().join(" ");
19 FFmpegState::Destination(destination)
20 }
21 _ => {
22 let leftover = split.collect::<Vec<&str>>().join(" ");
23 FFmpegState::ParseError(format!("{first_word} {leftover}"))
24 }
25 }
26 }
27}