2018-02-13 15:25:33 +00:00
|
|
|
extern crate clap;
|
2018-02-11 06:10:52 +00:00
|
|
|
extern crate hls_m3u8;
|
|
|
|
|
2018-02-13 15:25:33 +00:00
|
|
|
use clap::{App, Arg};
|
2018-02-14 03:00:19 +00:00
|
|
|
use hls_m3u8::{MasterPlaylist, MediaPlaylist};
|
2018-10-04 11:18:56 +00:00
|
|
|
use std::io::{self, Read};
|
2018-02-11 06:10:52 +00:00
|
|
|
|
|
|
|
fn main() {
|
2018-02-13 15:25:33 +00:00
|
|
|
let matches = App::new("parse")
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("M3U8_TYPE")
|
|
|
|
.long("m3u8-type")
|
|
|
|
.takes_value(true)
|
|
|
|
.default_value("media")
|
|
|
|
.possible_values(&["media", "master"]),
|
2019-03-31 09:54:21 +00:00
|
|
|
)
|
|
|
|
.get_matches();
|
2018-02-11 06:10:52 +00:00
|
|
|
let mut m3u8 = String::new();
|
2019-09-13 14:06:52 +00:00
|
|
|
io::stdin().read_to_string(&mut m3u8).unwrap();
|
2018-02-13 15:25:33 +00:00
|
|
|
|
|
|
|
match matches.value_of("M3U8_TYPE").unwrap() {
|
|
|
|
"media" => {
|
2019-09-13 14:06:52 +00:00
|
|
|
let playlist: MediaPlaylist = m3u8.parse().unwrap();
|
2018-02-13 15:25:33 +00:00
|
|
|
println!("{}", playlist);
|
|
|
|
}
|
2018-02-14 01:31:24 +00:00
|
|
|
"master" => {
|
2019-09-13 14:06:52 +00:00
|
|
|
let playlist: MasterPlaylist = m3u8.parse().unwrap();
|
2018-02-14 01:31:24 +00:00
|
|
|
println!("{}", playlist);
|
|
|
|
}
|
2018-02-13 15:25:33 +00:00
|
|
|
_ => unreachable!(),
|
2018-02-11 06:10:52 +00:00
|
|
|
}
|
|
|
|
}
|