Crates.io | xspf |
lib.rs | xspf |
version | 0.4.0 |
source | src |
created_at | 2023-11-15 20:59:36.592932 |
updated_at | 2023-11-22 21:37:48.081957 |
description | straightforward pure rust implementation of the Xml Sharable Playlist Format |
homepage | |
repository | https://git.envs.net/binarycat/xspf |
max_upload_size | |
id | 1036823 |
size | 38,258 |
goals:
limitations:
<location>
.the core type is Playlist.
all field names are taken from the spec, however camelCase names have been changed to snake_case.
//! simple example: append a track to a playlist, giving proper credit.
use std::env::{args, var};
use xspf::{Playlist, Track};
fn main() {
let playlist_path = args().nth(1).unwrap();
let track_location = args().nth(2).unwrap();
let mut pl = Playlist::read_file(&playlist_path)
.expect("unable to read playlist from file");
// move the previous playlist identifier (and location) to the
// attribution section.
pl.accredit();
// add track
let mut track = Track::default();
track.location.push(track_location.to_string());
pl.track_list.push(track);
// set the creator field to the current user
pl.creator = Some(var("USER").expect("$USER is not set").to_string());
// modify the playlist file in-place
pl.write_file(&playlist_path)
.expect("unable to write playlist to file");
}