playlist_decoder

Function decode

Source
pub fn decode(content: &str) -> Result<Vec<String>, PlaylistDecodeError>
Expand description

Decode playlist content string. It checks for M3U, PLS, XSPF and ASX content in the string.

§Example

let list = playlist_decoder::decode(r##"<?xml version="1.0" encoding="UTF-8"?>
   <playlist version="1" xmlns="http://xspf.org/ns/0/">
     <trackList>
       <track>
         <title>Nobody Move, Nobody Get Hurt</title>
         <creator>We Are Scientists</creator>
         <location>file:///mp3s/titel_1.mp3</location>
       </track>
       <track>
         <title>See The World</title>
         <creator>The Kooks</creator>
         <location>http://www.example.org/musik/world.ogg</location>
       </track>
     </trackList>
   </playlist>"##).unwrap();
assert!(list.len() == 2, "Did not find 2 urls in example");
for item in list {
    println!("{:?}", item);
}

§Arguments

  • content - A string slice containing a playlist