From 063b935723e6dca00cc216faf68210e12c08c25d Mon Sep 17 00:00:00 2001 From: Jackson Taylor Date: Wed, 10 Nov 2021 14:42:12 -0500 Subject: Continue downloading if one video fails Now we separate out the urls into individual downloads so we can keep going if we get an error. --- jamos | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/jamos b/jamos index 4435653..0b0d7f1 100755 --- a/jamos +++ b/jamos @@ -146,16 +146,30 @@ 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) + + 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 + + if __name__ == "__main__": # Get the playlist url from the command line playlist_url = get_playlist_url() - try: - # TODO: make this continue downloading if a song fails - download_song(playlist_url) - except Exception as ex: - # TODO: Handle this a different way - print(ex) + urls = get_video_urls_in_playlist(playlist_url) + + for url in urls: + try: + # TODO: make this continue downloading if a song fails + download_song(url) + except Exception as ex: + # TODO: Handle this a different way + print(ex) files = get_all_files(MUSIC_DIRECTORY) -- cgit v1.2.3