diff options
Diffstat (limited to 'jamos')
-rwxr-xr-x | jamos | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -24,8 +24,10 @@ AUDIO_OPTIONS = { 'cookiefile': 'cookies.txt', 'outtmpl': MUSIC_DIRECTORY + '%(title)s.%(ext)s', 'postprocessors': [ - {'key': 'FFmpegExtractAudio','preferredcodec': 'mp3', - 'preferredquality': '192', + { + 'key': 'FFmpegExtractAudio', + 'preferredcodec': 'mp3', + 'preferredquality': '192', }, {'key': 'FFmpegMetadata'}, ], @@ -57,11 +59,13 @@ def write_metadata_to_song_file(file, metadata): f.save() + def format_youtube_date(date): fmt = "%Y%m%d" d = datetime.datetime.strptime(date, fmt) return d.year + def sort_stuff(): # read in all the files and directories to move get_all_files() @@ -117,11 +121,19 @@ def get_directories(): def move_file(file, metadata): - p = os.path.join(MUSIC_DIRECTORY, metadata['artist'].replace(' ', '_').lower(), metadata['album'].replace(' ', '_').lower()) - Path(p).mkdir( parents=True, exist_ok=True ) + p = os.path.join( + MUSIC_DIRECTORY, + metadata['artist'].replace(' ', '_').lower(), + metadata['album'].replace(' ', '_').lower()) - os.rename(file, os.path.join(p, metadata['artist'].replace(' ', '_').lower() + '_' + metadata['title'].replace(' ', '_').lower() + '.mp3')) + Path(p).mkdir(parents=True, exist_ok=True) + os.rename( + file, + os.path.join( + p, + metadata['artist'].replace(' ', '_').lower() + + '_' + metadata['title'].replace(' ', '_').lower() + '.mp3')) if __name__ == "__main__": @@ -139,4 +151,3 @@ if __name__ == "__main__": json_data = json.load(json_file) write_metadata_to_song_file(f, json_data) move_file(f, json_data) - |