summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackson Taylor <jackson@jacksontaylor.xyz>2022-03-31 07:59:22 -0400
committerJackson Taylor <jackson@jacksontaylor.xyz>2022-04-05 16:52:18 -0400
commit65f3c684e824378abc8cadc55804e09ff726b426 (patch)
tree83b3046b2947da0a5bfe4ea5819ae6a834140c05
parentc3dc00811296a2724ddcdb229ab58a5312af130c (diff)
Add cleanup function for json files
-rwxr-xr-xjamos9
1 files changed, 8 insertions, 1 deletions
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)
+