Home > Bash, Linux, Useful commands > How to download all videos from youtube playlist

How to download all videos from youtube playlist

#!/bin/sh
n=1
for i in 1 26 51 76 101
do
for video in $(curl -s http://gdata.youtube.com/feeds/api/playlists/PLAYLISTID?start-index="$i" | grep -o "url='http://www.youtube.com/watch?v=[^']*'")
do
id=$(echo $video | sed "s|url\='http://www.youtube.com/watch?v=\(.*\)&.*'|\1|")
wget http://www.youtube.com/watch?v=$id -qO- | sed -n "/fmt_url_map/{s/[\'\"\|]/\n/g;p}" | sed -n '/^fmt_url_map/,/videoplayback/p' | sed -e :a -e '$q;N;5,$D;ba' | tr -d '\n' | sed -e 's/\(.*\),\(.\)\{1,3\}/\1/' | wget -i - -O $n.flv
n=$(( $n + 1 ))
done
done

where PLAYLISTID is a ID taken from playlist url (ex.: http://www.youtube.com/my_playlists?p=1EC20BA340CD627B)

Categories: Bash, Linux, Useful commands
  1. 27/02/2011 at 01:08

    nice tutorial….

  2. 28/02/2011 at 23:39

    You read my mind ;p I was searching for similar solution and can use yours.

  3. Fouad
    13/04/2012 at 10:00

    It gave me this error, Would you help

  4. Fouad
    13/04/2012 at 10:06

    Fouad :It gave me this error, Would you help

    No URLs found in -.
    No URLs found in -.
    No URLs found in -.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: