diff options
author | Jackson Taylor <jackson@jacksontaylor.xyz> | 2021-11-10 14:42:12 -0500 |
---|---|---|
committer | Jackson Taylor <jackson@jacksontaylor.xyz> | 2022-04-05 16:52:02 -0400 |
commit | 063b935723e6dca00cc216faf68210e12c08c25d (patch) | |
tree | 42023ffe7e4c4aa2e1473a6d81c9da870cac9f08 | |
parent | 4d3eebfbf352af0314453596f38b81414913cb75 (diff) |
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.
-rwxr-xr-x | jamos | 26 |
1 files changed, 20 insertions, 6 deletions
@@ -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) |