-
-
Save ads901119/2566233 to your computer and use it in GitHub Desktop.
Download a youtube playlist using rg3/youtube-dl by @orschiro
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 shutil | |
import os | |
import sys | |
import subprocess | |
import re | |
# Settings | |
root_folder = 'C:/Users/Robert/Videos/YouTube/Playlists/' | |
destination_regex = re.compile(r'^\[download\] Destination: (.*)$', re.M) | |
def download(): | |
files = open('Playlists.txt').readlines() | |
for playlist in files: | |
p = playlist.split(';') | |
# Create the directory for the playlist if it does not exist yet | |
my_path = os.path.join(root_folder, p[0]) | |
if not os.path.exists (my_path): | |
os.makedirs(my_path) | |
# Download every single video from the given playlist | |
download_videos = subprocess.Popen([sys.executable, 'youtube-dl.py', '-cit', p[1]], | |
stdout=subprocess.PIPE) | |
output = download_videos.communicate()[0] | |
# After downloading all videos move them into the destination folder | |
for video in destination_regex.findall(output): | |
shutil.move(video, my_path) | |
if __name__ == '__main__': | |
download() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment