Lets cut the long discussion short and directly give you the script. The script is combination of all the posts that I did in the past about youtube downloads. You need to copy all the URL\’s in a file called \”~/youtube.urls\” which you want to be downloaded. Or if you need to donwload the related videos, then save the html of the page and give it as the first argument for the script. So, here\’s the scrit:
#!/bin/bash –
#===============================================================================
#
# FILE: youtube_releated.sh
#
# USAGE: ./youtube_releated.sh
#
# DESCRIPTION: Get the related urls from the youtube html
#
# OPTIONS: —
# REQUIREMENTS: —
# BUGS: —
# NOTES: —
# AUTHOR: Amit Agarwal (AKA), amit.agarwal@amit-agarwal.co.in
# COMPANY: Individual
# VERSION: 1.0
# CREATED: 05/02/2010 04:45:54 PM IST
# REVISION: —
#===============================================================================
user=raj77india
pass=Kukku1977
if [ $# -ge 1 ]
then
for i in $(grep video-list-item $1 |sed \’s/&.*//\’|sed \’s/.*=\”\\(.*\\)/\\1/\’)
do
echo \”Writing $i to youtube.urls file\”
echo \”http://www.youtube.com$i\” >> ~/youtube.urls
done
firead -p \”Download all the urls :\” ans
cd ~
if [ \”$ans\” = \”y\” ]
then
grep -v \”^#\” ~/youtube.urls > /tmp/youtube.urls
while read line
do
youtube-dl -u $user -p $pass -t $line
done < /tmp/youtube.urls
firead -p \”Add title to the file :\” ans1
if [ \”$ans1\” != \”y\” ]
then
exit
fi
rm -f /tmp/youtube.urlswhile read line
do
echo $line|grep -c \”^#\”
if [ $(echo $line|grep -c \”^#\”) -eq 1 ]
then
echo \”#$line\” >>/tmp/youtube.urls
echo \”Skipping $line\”
continue
else
title=$(youtube-dl -u $user -p $pass -e $line)
echo \”title is $title\”
fi
done <~/youtube.urlsmv /tmp/youtube.urls ~/youtube.urls
Since the script is quite simple, its not much documented. Anyways if you need help, feel free to contact me 🙂 (contact form or comment)
Related articles by Zemanta
- YouTube Introduces New Privacy Option for Videos (mashable.com)
- Download youtube video directly from the command line with youtube-dl (amit-agarwal.co.in)
- BYTubeD Makes It Easier Than Ever To Download Multiple Youtube Videos In One Go (mt-soft.com.ar)
- YouTube gets a very useful \’unlisted\’ video option (news.cnet.com)
- YouTube to allow \’private\’ videos (telegraph.co.uk)