From 65f3c684e824378abc8cadc55804e09ff726b426 Mon Sep 17 00:00:00 2001 From: Jackson Taylor Date: Thu, 31 Mar 2022 07:59:22 -0400 Subject: Add cleanup function for json files --- jamos | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'jamos') diff --git a/jamos b/jamos index b4b382b..dc86158 100755 --- a/jamos +++ b/jamos @@ -9,6 +9,11 @@ from pathlib import Path import sys import youtube_dl +def cleanup_metadata_files(music_directory): + files = glob.glob(os.path.join(music_directory, '*.json')) + + for file in files: + os.remove(file) def download_song(song_url, ytdl): @@ -84,7 +89,7 @@ def move_file(file, metadata, output_directory): artist = metadata['artist'].replace(' ', '_').lower() if ('album' in metadata.keys()) and (metadata['album'] is not None): - album = metadata['album'].replace(' ', '_').lower() + album = metadata['album'].replace(' ', '_').replace(',', '').replace("'", "").replace('"', "").lower() if ('title' in metadata.keys()) and (metadata['title'] is not None): title = metadata['title'].replace(' ', '_').replace('/', '').lower() @@ -189,3 +194,5 @@ if __name__ == "__main__": write_metadata_to_song_file(f, json_data) move_file(f, json_data, music_directory) + cleanup_metadata_files(music_directory) + -- cgit v1.2.3