Skip to content

Instantly share code, notes, and snippets.

@pankaj28843
Created February 26, 2012 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pankaj28843/1918004 to your computer and use it in GitHub Desktop.
Save pankaj28843/1918004 to your computer and use it in GitHub Desktop.
Download multiple youtube videos at once
# -*- coding: utf-8 -*-
from BeautifulSoup import BeautifulSoup
input_file = file('input.txt')
soup = BeautifulSoup(input_file.read())
for a in soup.findAll('a'):
if 'watch?v=' in a['href']:
print 'http://www.youtube.com'+a['href']
#!/bin/bash
cwd="$(pwd)"
#Uncomment following two lines if behind proxy
#http_proxy="http://10.3.100.212:8080"
#https_proxy="http://10.3.100.212:8080"
gedit input.txt
links="/tmp/$(date).txt"
python /home/psjinx/parse_youtube_urls.py > "$links"
rm input.txt
while read line
do
name=$(echo $(youtube-dl -e "$line").mp4);
dummy_url=$(youtube-dl -g "$line");
path="$cwd/$name"
if [ ! -f "$path" ];
then
echo $path
wget -c --no-verbose $dummy_url -O "$path"&
#aria2c -c -m0 -s10 -o "$path" $dummy_url &
fi
done < "$links"
rm "$links"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment