Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # YouTube playlist to .mp3 downloader
- # download_youtube: https://pastebin.com/c3dsukmk
- from download_youtube import main as download
- from pytube import Playlist
- from pathvalidate import sanitize_filename
- playlist = Playlist(input('Enter YouTube playlist URL: '))
- count = playlist.length
- title = sanitize_filename(playlist.title)
- print(f'\nVideo count: {count}, Output folder name: {title}\n\n')
- # start downloading
- error_list = []
- real_count = 0
- for i, url in enumerate(playlist.video_urls):
- print(f'Video {i+1} of {count}')
- try:
- download(url, title)
- except Exception as e:
- error_string = f'Error on url {url}: {e}'
- error_list.append(error_string)
- print(error_string)
- real_count += 1
- # check if there was unavailable videos
- if real_count != count:
- error_list.append(f"One or more videos were unavailable: {count-real_count} video(s) missing")
- # show errors
- if len(error_list) > 0:
- print(f'{len(error_list)} error(s) occured: {error_list}')
- input('Press enter to exit...')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement