diff --git a/src/audio/player.rs b/src/audio/player.rs index a0efd524f0a1a6f1fefd3926200dd825c96fde17..17ac3f8af61a1041595a4a7d3f32b29438091093 100644 --- a/src/audio/player.rs +++ b/src/audio/player.rs @@ -386,7 +386,12 @@ impl SongTitle { /// Returns path for current title fn get_path(&self) -> Option { if let Some(title) = &self.current_title { - let title = utils::simplify_string(title.to_string()); + // Remove unsupported characters from the file name + let title_raw = utils::simplify_string(title.to_string()); + // Limit file name to 200 chars + let title_vec = title_raw.chars().collect::>(); + let cut_to_length = title_vec.len().min(200); + let title = text_vec[..cut_to_length].iter().cloned().collect::(); let mut path = path::CACHE.clone(); path.push("recording"); diff --git a/src/utils.rs b/src/utils.rs index a8a035648acb237c863db058b00c69691dccb289..1fd164195dacc0228da97b25f0d7d341eecc41f6 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -96,7 +96,7 @@ where } pub fn simplify_string(s: String) -> String { - s.replace(&['/', '\\', ':', '<', '>', '\"', '|', '?', '*', '.'] as &[_], "") + s.replace(&['/', '\\0', '\\', ':', '<', '>', '\"', '|', '?', '*', '.'] as &[_], "") } pub fn station_subtitle(country: &str, state: &str, votes: i32) -> String {