diff options
-rwxr-xr-x | jamos | 46 |
1 files changed, 23 insertions, 23 deletions
@@ -35,11 +35,6 @@ AUDIO_OPTIONS = { ytdl = youtube_dl.YoutubeDL(AUDIO_OPTIONS) -# TODO: Make this better with argparse -def get_playlist_url(): - return sys.argv[1] - - def download_song(song_url): """ Download a song using youtube url and song title @@ -47,17 +42,6 @@ def download_song(song_url): return ytdl.extract_info(song_url, download=True) -def write_metadata_to_song_file(file, metadata): - f = music_tag.load_file(file) - - f['name'] = metadata['title'] - f['artist'] = metadata['artist'] - f['album'] = metadata['album'] - f['year'] = format_youtube_date(metadata['release_date']) - - f.save() - - def format_youtube_date(date): default = "Unknown Year" try: @@ -91,6 +75,22 @@ def get_directories(): DIRECTORIES.append(f) +# TODO: Make this better with argparse +def get_playlist_url(): + return sys.argv[1] + + +def get_video_urls_in_playlist(playlist_url): + videos = ytdl.extract_info(playlist_url, download=False) + + urls = [] + for vid in videos['entries']: + if 'webpage_url' in vid.keys() and vid['webpage_url'] is not None: + urls.append(vid['webpage_url']) + + return urls + + def move_file(file, metadata): artist = 'unknownartist' album = 'unknownalbum' @@ -122,15 +122,15 @@ def move_file(file, metadata): os.path.join(final_directory, artist + '_' + title + '.mp3')) -def get_video_urls_in_playlist(playlist_url): - videos = ytdl.extract_info(playlist_url, download=False) +def write_metadata_to_song_file(file, metadata): + f = music_tag.load_file(file) - urls = [] - for vid in videos['entries']: - if 'webpage_url' in vid.keys() and vid['webpage_url'] is not None: - urls.append(vid['webpage_url']) + f['name'] = metadata['title'] + f['artist'] = metadata['artist'] + f['album'] = metadata['album'] + f['year'] = format_youtube_date(metadata['release_date']) - return urls + f.save() if __name__ == "__main__": |