Skip to content

Instantly share code, notes, and snippets.

@ihercowitz
Created April 10, 2014 12:33
Show Gist options
  • Select an option

  • Save ihercowitz/10377097 to your computer and use it in GitHub Desktop.

Select an option

Save ihercowitz/10377097 to your computer and use it in GitHub Desktop.
A batch downloader for youtube-dl
import requests
from lxml.html import fromstring
import os
search='https://www.youtube.com/results'
def make_my_day(query):
page = requests.get(search, params=[{'search_query', str(query)}])
links = fromstring(page.text).cssselect('a')
videos = set(filter(lambda x: x is not None and x.__contains__('/watch'), map(lambda x: x.get('href'), links)))
map(lambda x: os.system('youtube-dl -f mp4 https://youtube.com%s' %x), videos)
#usage:
#uncomment the lines belows and execute the script
#for s in ['dora aventureira', 'go diego go', 'turma da monica', 'super why!', 'backyardigans']:
# make_my_day(s.replace(' ', '+'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment