Last active
February 9, 2016 05:57
-
-
Save srhinos/61ac0f7046704a3fdc87 to your computer and use it in GitHub Desktop.
Extracts urls from youtube playlists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import youtube_dl | |
import datetime | |
playlists = ['PLAYLIST_URL_1', 'PLAYLIST_URL_2', 'PLAYLIST_URL_3'] | |
ytdl_format_options = { | |
'format': 'bestaudio/best', | |
'extractaudio': True, | |
'audioformat': "mp3", | |
'outtmpl': '%(id)s', # part file temp name | |
'noplaylist': True, | |
'nocheckcertificate': True, | |
'ignoreerrors': True, | |
'quiet': True, | |
'no_warnings': True, | |
'source_address': '0.0.0.0' | |
} | |
ydl = youtube_dl.YoutubeDL(ytdl_format_options) | |
with open('backuplist.txt', 'a+', encoding='utf8') as f: | |
for url in playlists: | |
print('Starting extraction of playlist #{}'.format((playlists.index(url)+1))) | |
for e in ydl.extract_info(url, download=False, process=False)['entries']: | |
if e: | |
f.write('#{}\nhttps://www.youtube.com/watch?v={}\n'.format(e['title'], e['url'])) | |
print('done') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment