diff --git a/src/main.rs b/src/main.rs index 7d154d6..6e6b779 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,6 +46,17 @@ async fn create_session(credentials: Credentials) -> Session { session } +fn make_filename_compatible(filename: &str) -> String { + let invalid_chars = ['<', '>', ':', '\'', '"', '/', '\\', '|', '?', '*']; + let mut clean = String::new(); + for c in filename.chars() { + if !invalid_chars.contains(&c) && c.is_ascii() && !c.is_control() && c.len_utf8() == 1 { + clean.push(c); + } + } + clean +} + async fn download_tracks(session: &Session, destination: PathBuf, tracks: Vec) { let player_config = PlayerConfig::default(); let bar_style = ProgressStyle::default_bar() @@ -79,10 +90,11 @@ async fn download_tracks(session: &Session, destination: PathBuf, tracks: Vec