Skip to content

Instantly share code, notes, and snippets.

@DnyaneshwarWagh
Last active December 22, 2020 17:46
Show Gist options
  • Save DnyaneshwarWagh/887b848538d676693adbc04e47618b85 to your computer and use it in GitHub Desktop.
Save DnyaneshwarWagh/887b848538d676693adbc04e47618b85 to your computer and use it in GitHub Desktop.
Download Playlist Using Youtube-DL
#!/usr/bin/env python3
import argparse
import base64
import os
import re
import subprocess
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--url-list', help='List of URL/filename pairs, delimited by tabs')
args = parser.parse_args()
for line in open(args.url_list):
output_file, master_json_url = line.rstrip().split()
print("\n*** %s - DOWNLOAD STARTED ***\n" % output_file)
master_json_url = '.mpd'.join(master_json_url.rsplit('.json', 1))
# Downloading video using youtube-dl
cmd = 'youtube-dl --no-check-certificate -f bestvideo+bestaudio -o '
cmd += output_file
cmd += '.mp4 '
cmd += master_json_url
print(cmd)
subprocess.call(cmd, shell=True)
# Log the conclusion of the operations
print("\n*** %s - DOWNLOADED SUCCESSFULLY ***\n" % output_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment