Skip to content

Instantly share code, notes, and snippets.

@mr-karan
Created January 22, 2016 13:04
Show Gist options
  • Save mr-karan/54429d20c003e0b99763 to your computer and use it in GitHub Desktop.
Save mr-karan/54429d20c003e0b99763 to your computer and use it in GitHub Desktop.
A script which will download all videos hosted on PyVideos till date.
'''
Author : Karan
For the love of pyvideo
'''
from __future__ import unicode_literals
import os,json,youtube_dl
def walker():
a=[]
for root,dirs,files in os.walk(os.getcwd()):
for file in files:
try:
if file.endswith(".json"):
#print(os.path.join(root,file))
with open(os.path.join(root,file)) as data_file:
try:
i = (json.load(data_file)['source_url'])
if len(i)>1:
a.append(i)
except KeyError:
pass
except:
continue
return a
def downloader(a):
ydl = youtube_dl.YoutubeDL({'outtmpl': '%(id)s%(ext)s'})
with ydl:
for i in a:
try:
ydl.extract_info(i,download=True)
except (youtube_dl.MaxDownloadsReached , youtube_dl.DownloadError):
continue
def main():
url_list = walker()
downloader(url_list)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment