Last active
May 23, 2020 09:24
-
-
Save dagvany/0c41dffdfde0c8c1f323e10ed7144ac4 to your computer and use it in GitHub Desktop.
Ninja Nerd Science yt playlist downloader
This file contains hidden or 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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import os | |
import subprocess | |
ytLists = { | |
'Hematology': 'https://www.youtube.com/watch?v=yF22BfXEO5g&list=PLTF9h-T1TcJh9T57G0nls2uGPzzHKMxxh', | |
'Biochemistry': 'https://www.youtube.com/watch?v=jJUoQMLMV2E&list=PLTF9h-T1TcJhcNo9M1VFXz6rMKT6CM_wd', | |
'Cardiovascular Physiology': 'https://www.youtube.com/watch?v=jU9w6w8LwqM&list=PLTF9h-T1TcJhp-1zjtApt2lVbQ2JHkY7b', | |
'Immunology': 'https://www.youtube.com/watch?v=LArxUakFsFs&list=PLTF9h-T1TcJj4AOPCxGxOUTH0IVmaH7_8&index=2&t=0s', | |
'Metabolism': 'https://www.youtube.com/watch?v=gggC9vctvBQ&list=PLTF9h-T1TcJhy6Og8piwo8doDJavTFOvg', | |
'Endocrinology': 'https://www.youtube.com/watch?v=RMV130vU8gA&list=PLTF9h-T1TcJjOIhflPV32PZxgcN8wLlvj', | |
'Myology': 'https://www.youtube.com/watch?v=UKgbfxPTn_s&list=PLTF9h-T1TcJjV2M7i8rULUOanzq1BgXht', | |
'The Circulatory System': 'https://www.youtube.com/watch?v=jU9w6w8LwqM&list=PLTF9h-T1TcJjneQygbo6JGEhMmt1kzzPw', | |
'Special Senses': 'https://www.youtube.com/watch?v=UUCn2Bq3oVQ&list=PLTF9h-T1TcJgF4V5joQUhO1inEppADuGb', | |
'Renal Physiology': 'https://www.youtube.com/watch?v=7Z7aeBCQwTQ&list=PLTF9h-T1TcJhB0HeD3fba49FTJuwPN8_O', | |
'Respiratory': 'https://www.youtube.com/watch?v=RnWVCE9KdR8&list=PLTF9h-T1TcJjdJppplKVsgPWNQ_beElaG', | |
'Neurology': 'https://www.youtube.com/watch?v=ADAOsuaOSCk&list=PLTF9h-T1TcJgx3OFachdjHPMX6VE4VDS1', | |
'Bone Anatomy': 'https://www.youtube.com/watch?v=BHfFY19LzT4&list=PLTF9h-T1TcJhCLwcSW_Wxb8ZzGZI3g9Pb', | |
'Muscle Anatomy': 'https://www.youtube.com/watch?v=F_O0Rj3IWn8&list=PLTF9h-T1TcJiKXBzOwN6R5HlAZn6aWIk4' | |
} | |
currentFolder = os.getcwd() | |
# https://ytdl-org.github.io/youtube-dl/download.html | |
ytdlCommand = "youtube-dl -i -f mp4 --yes-playlist '{}' -o '{}/%(playlist_index)s- %(title)s.%(ext)s'" | |
for listName, ytUrl in ytLists.items(): | |
path = os.path.join(currentFolder, listName) | |
command = ytdlCommand.format(ytUrl, path) | |
os.mkdir(path) | |
print(command) | |
ps = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
for line in iter(ps.stdout.readline, ''): | |
print(line) | |
if "Finished downloading playlist" in str(line): | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment