Download YouTube movies and Auto-Number Them
--D. Thiebaut (talk) 10:15, 23 March 2014 (EDT)
YouTube-dl
This script requires youtube-dl, which can be downloaded from GitHub.
Source
# getYouTubeVids.py
# (C) D. Thiebaut 2014
# given a list of youtube videos stored in the array vids, and a
# filename variable that represents the name of the videos, including
# a numbering scheme (%02d means 2 decimals with leading 0, i.e. 01,
# 02, etc., the program will fetch the videos using the command
# youtube-dl (to be downloaded from some other site) and will store
# all the movie files under the given filename format.
# Assumes Python V 2.7. Switch the print statements around for
# Python 3+
import subprocess
filename = "Qt5Tutorials_Thiebaut_%02d"
vids = [ "http://www.youtube.com/watch?v=EAdAvMc1MCI",
"http://www.youtube.com/watch?v=XmzqZmr-S-Q" ]
for i,vid in enumerate(vids):
thisFileName = filename % (i+1) + ".%(ext)s"
#print( "youtube-dl -o \"" + thisFileName + "\" " + vid )
print "youtube-dl -o \"" + thisFileName + "\" " + vid
#call( ["youtube-dl", "-o", thisFileName, vid ] )
subprocess.Popen( ["youtube-dl", "-o", thisFileName, vid ],
stdout = subprocess.PIPE,
stderr= subprocess.PIPE ).communicate()
#print( "done" )
print "done"