2016-06-03 18:56:45 +00:00
|
|
|
extern crate nom;
|
|
|
|
extern crate m3u8_rs;
|
|
|
|
|
|
|
|
use m3u8_rs::playlist::{Playlist};
|
|
|
|
use std::io::Read;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut file = std::fs::File::open("playlist.m3u8").unwrap();
|
|
|
|
let mut bytes: Vec<u8> = Vec::new();
|
|
|
|
file.read_to_end(&mut bytes).unwrap();
|
|
|
|
|
|
|
|
let parsed = m3u8_rs::parse_playlist_res(&bytes);
|
|
|
|
|
|
|
|
match parsed {
|
2017-02-17 13:50:50 +00:00
|
|
|
Ok(Playlist::MasterPlaylist(pl)) => println!("Master playlist:\n{:?}", pl),
|
|
|
|
Ok(Playlist::MediaPlaylist(pl)) => println!("Media playlist:\n{:?}", pl),
|
2016-06-03 18:56:45 +00:00
|
|
|
Err(e) => println!("Error: {:?}", e)
|
|
|
|
}
|
|
|
|
}
|