|
By Mark Humphrys. March 2012.
The script needs re-writing every year or so, because YouTube keep changing their formats.
Thanks to Stefan Swerk for finding the strategy that works in 2012.
<div id="watch-player" ... var swf = ...
wget -O - "$1" > file
cat file | extracturl
sed 's|url|\ \ url|g'
TIP: See what the first one does, then the first 2, then the first 3, until you have all of them piped together.
url=`cat file | extracturl` echo $url
url%3Dhttp%253A%252F%252Fo-o.preferred.dub06s01.v4.lscache8.c.youtube.com%252Fvideoplayback%253Fsparams%253Dalgorithm%25252Cburst%25252Ccp%25252Cfactor%25252Cid%25252Cip%25252Cipbits%25252Citag%25252Csource%25252Cexpire%2526fexp%253D904549%25252C909902%25252C910207%25252C901604%2526algorithm%253Dthrottle-factor%2526itag%253D34%2526ip%253D136.0.0.0%2526burst%253D40%2526sver%253D3%2526signature%253D40D33F0FAA075B69E335B03BDDB7BE053ABA1F9C.B9FA2FC4BA73C348FAE94CD249136DB62F7064DB%2526source%253Dyoutube%2526expire%253D1331161680%2526key%253Dyt1%2526ipbits%253D8%2526factor%253D1.25%2526cp%253DU0hSRlFRT19NSkNOMl9JS1NHOm9yNXZ5aFV3c1BN%2526id%253D3ae49d53cb5b7076%26quality%3Dmedium%26fallback_host%3Dtc.v4.cache8.c.youtube.com%26type%3Dvideo%252Fx-flv%26itag%3D34%2C
[2 out of 5]
percentdecode "$url"
where "percentdecode" is this Perl script:
#!/usr/bin/perl use URI::Escape; my $encodedurl = $ARGV[0]; my $url = uri_unescape($encodedurl); print "$url\n";
url=`percentdecode "$url"` echo $url
url=http%3A%2F%2Fo-o.preferred.dub06s01.v4.lscache8.c.youtube.com%2Fvideoplayback%3Fsparams%3Dalgorithm%252Cburst%252Ccp%252Cfactor%252Cid%252Cip%252Cipbits%252Citag%252Csource%252Cexpire%26fexp%3D904549%252C909902%252C910207%252C901604%26algorithm%3Dthrottle-factor%26itag%3D34%26ip%3D136.0.0.0%26burst%3D40%26sver%3D3%26signature%3D40D33F0FAA075B69E335B03BDDB7BE053ABA1F9C.B9FA2FC4BA73C348FAE94CD249136DB62F7064DB%26source%3Dyoutube%26expire%3D1331161680%26key%3Dyt1%26ipbits%3D8%26factor%3D1.25%26cp%3DU0hSRlFRT19NSkNOMl9JS1NHOm9yNXZ5aFV3c1BN%26id%3D3ae49d53cb5b7076&quality=medium&fallback_host=tc.v4.cache8.c.youtube.com&type=video%2Fx-flv&itag=34,
url=`echo "$url" | sed 's|^url=||'` echo $url
url=`echo "$url" | sed 's|itag=.*$||'` echo $url
http%3A%2F%2Fo-o.preferred.dub06s01.v4.lscache8.c.youtube.com%2Fvideoplayback%3Fsparams%3Dalgorithm%252Cburst%252Ccp%252Cfactor%252Cid%252Cip%252Cipbits%252Citag%252Csource%252Cexpire%26fexp%3D904549%252C909902%252C910207%252C901604%26algorithm%3Dthrottle-factor%26itag%3D34%26ip%3D136.0.0.0%26burst%3D40%26sver%3D3%26signature%3D40D33F0FAA075B69E335B03BDDB7BE053ABA1F9C.B9FA2FC4BA73C348FAE94CD249136DB62F7064DB%26source%3Dyoutube%26expire%3D1331161680%26key%3Dyt1%26ipbits%3D8%26factor%3D1.25%26cp%3DU0hSRlFRT19NSkNOMl9JS1NHOm9yNXZ5aFV3c1BN%26id%3D3ae49d53cb5b7076&quality=medium&fallback_host=tc.v4.cache8.c.youtube.com&type=video%2Fx-flv&
[3 out of 5]
http://o-o.preferred.dub06s01.v4.lscache8.c.youtube.com/videoplayback?sparams=algorithm%2Cburst%2Ccp%2Cfactor%2Cid%2Cip%2Cipbits%2Citag%2Csource%2Cexpire&fexp=904549%2C909902%2C910207%2C901604&algorithm=throttle-factor&itag=34&ip=136.0.0.0&burst=40&sver=3&signature=40D33F0FAA075B69E335B03BDDB7BE053ABA1F9C.B9FA2FC4BA73C348FAE94CD249136DB62F7064DB&source=youtube&expire=1331161680&key=yt1&ipbits=8&factor=1.25&cp=U0hSRlFRT19NSkNOMl9JS1NHOm9yNXZ5aFV3c1BN&id=3ae49d53cb5b7076&quality=medium&fallback_host=tc.v4.cache8.c.youtube.com&type=video/x-flv&
UserAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)" wget -U "$UserAgent" -O - "$url" > file.flv
[5 out of 5]

On Internet since 1987.