Crate m3u8_rs [−] [src]
A library to parse m3u8 playlists (HTTP Live Streaming) link.
Examples
Parsing a playlist and let the parser figure out if it's a media or master playlist.
extern crate m3u8_rs; extern crate nom; use m3u8_rs::playlist::Playlist; use nom::IResult; use std::io::Read; let mut file = std::fs::File::open("playlist.m3u8").unwrap(); let mut bytes: Vec<u8> = Vec::new(); file.read_to_end(&mut bytes).unwrap(); // Option 1: fn parse_playlist_res(input) -> Result<Playlist, _> match m3u8_rs::parse_playlist_res(&bytes) { Ok(Playlist::MasterPlaylist(pl)) => println!("Master playlist:\n{}", pl), Ok(Playlist::MediaPlaylist(pl)) => println!("Media playlist:\n{}", pl), Err(e) => println!("Error: {:?}", e) } // Option 2: fn parse_playlist(input) -> IResult<_, Playlist, _> match m3u8_rs::parse_playlist(&bytes) { IResult::Done(i, Playlist::MasterPlaylist(pl)) => println!("Master playlist:\n{}", pl), IResult::Done(i, Playlist::MediaPlaylist(pl)) => println!("Media playlist:\n{}", pl), IResult::Error(e) => panic!("Parsing error: \n{}", e), IResult::Incomplete(e) => panic!("Parsing error: \n{:?}", e), }
Parsing a master playlist directly
extern crate m3u8_rs; extern crate nom; use std::io::Read; use nom::IResult; let mut file = std::fs::File::open("masterplaylist.m3u8").unwrap(); let mut bytes: Vec<u8> = Vec::new(); file.read_to_end(&mut bytes).unwrap(); if let IResult::Done(_, pl) = m3u8_rs::parse_master_playlist(&bytes) { println!("{}", pl); }
Modules
playlist |
Contains all the structs used for parsing. |
Enums
MasterPlaylistTag |
Contains all the tags required to parse a master playlist. |
MediaPlaylistTag |
Contains all the tags required to parse a media playlist. |
SegmentTag |
All possible media segment tags. |
Functions
alternative_media_tag | |
byterange_val | |
comment_tag | |
consume_line | |
contains_master_tag |
Scans input looking for either a master or media |
duration_title_tag | |
ext_tag | |
float | |
from_utf8_slice | |
from_utf8_slice2 | |
is_master_playlist |
When a media tag or no master tag is found, this returns false. |
is_master_playlist_tag_line | |
key | |
key_value_pair | |
key_value_pairs | |
m3u_tag | |
map | |
master_playlist_tag | |
media_playlist_tag | |
media_segment_tag | |
number | |
parse_master_playlist |
Parse input as a master playlist |
parse_master_playlist_tags | |
parse_media_playlist |
Parse input as a media playlist |
parse_media_playlist_tags | |
parse_playlist |
Parse a m3u8 playlist. |
parse_playlist_res |
Parse a m3u8 playlist just like |
playlist_type_tag | |
quoted | |
session_data_tag | |
session_key_tag | |
start_tag | |
unquoted | |
variant_i_frame_stream_tag | |
variant_stream_tag | |
version_tag |