diff options
author | Jackson Taylor <jackson@jacksontaylor.xyz> | 2022-03-31 07:59:22 -0400 |
---|---|---|
committer | Jackson Taylor <jackson@jacksontaylor.xyz> | 2022-04-05 16:52:18 -0400 |
commit | 65f3c684e824378abc8cadc55804e09ff726b426 (patch) | |
tree | 83b3046b2947da0a5bfe4ea5819ae6a834140c05 /jamos | |
parent | c3dc00811296a2724ddcdb229ab58a5312af130c (diff) |
Add cleanup function for json files
Diffstat (limited to 'jamos')
-rwxr-xr-x | jamos | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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) + |