Sto provando a scaricare tutti i file disponibili che sono diverse qualità di un singolo video usando l'API di YouTube, ma ogni URL che seguo per scaricare il video risulta in un 403.
script:
#!/bin/bash
_video_info=$(wget -qO- -- "http://www.youtube.com/get_video_info?&video_id=$1&el=detailpage&ps=default&eurl=&gl=US&hl=en")
_video_urls=$(sed -e 's|%25|%|g' -e 's|%25|%|g' -e 's|%3A|:|g' -e 's|%2F|/|g' -e 's|%26|\&|g' -e 's|%3D|=|g' -e 's|%3F|?|g' -e 's|%2C|,|g' -e 's|%2B|+|g' -e 's|%3B|;|g' -e 's|%22|"|g' -e 's|.*url_encoded_fmt_stream_map=url=\(.*&itag=[0-9]*\).*|\1|' -e 's|,url=|\n|g' <<< "${_video_info}")
_video_formats=$(sed 's|.*fmt_list=\([^\&]*\)\&.*|\1|' <<< "${_video_info}")
while read -r _video_download_url; do
wget "${_video_download_url}"
done <<< "${_video_urls}"
Produzione:
$ ./ytdl 5_xCfrpif4Q
--2011-08-19 00:14:21-- http://o-o.preferred.mil01s10.v1.lscache5.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,ratebypass&fexp=907312,904535,913501,906918&itag=43&ip=93.0.0.0&signature=32944F059B26E01072437068EAC6449FCD975383.2272568B833A7A706A82236297B6D6B8D900D330&sver=3&ratebypass=yes&expire=1313733600&key=yt1&ipbits=8&id=e7fc427eba627f84&quality=medium&fallback_host=tc.v1.cache5.c.youtube.com&type=video/webm;+codecs=%22vp8.0,+vorbis%22&itag=43
Resolving o-o.preferred.mil01s10.v1.lscache5.c.youtube.com... 173.194.2.38, 2a00:1450:4002:3::6
Connecting to o-o.preferred.mil01s10.v1.lscache5.c.youtube.com|173.194.2.38|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
2011-08-19 00:14:22 ERROR 403: Forbidden.
--2011-08-19 00:14:22-- http://o-o.preferred.mil01s10.v15.lscache6.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,algorithm,burst,factor&fexp=907312,904535,913501,906918&algorithm=throttle-factor&itag=34&ip=93.0.0.0&burst=40&sver=3&signature=C623D3002F9BC919B8D83666DB1274D9E37F9B63.A6FF45792995744504C9DF39EDEE8326D74450C5&expire=1313733600&key=yt1&ipbits=8&factor=1.25&id=e7fc427eba627f84&quality=medium&fallback_host=tc.v15.cache6.c.youtube.com&type=video/x-flv&itag=34
Resolving o-o.preferred.mil01s10.v15.lscache6.c.youtube.com... 173.194.2.56, 2a00:1450:4002:3::18
Connecting to o-o.preferred.mil01s10.v15.lscache6.c.youtube.com|173.194.2.56|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
2011-08-19 00:14:22 ERROR 403: Forbidden.
--2011-08-19 00:14:22-- http://o-o.preferred.mil01s10.v13.lscache5.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,ratebypass&fexp=907312,904535,913501,906918&itag=18&ip=93.0.0.0&signature=88D969809C0625D2B7AC600C0D0C127F7AD72022.CA5355DAEF26B2AADBD6AAFF1726A331C54850C0&sver=3&ratebypass=yes&expire=1313733600&key=yt1&ipbits=8&id=e7fc427eba627f84&quality=medium&fallback_host=tc.v13.cache5.c.youtube.com&type=video/mp4;+codecs=%22avc1.42001E,+mp4a.40.2%22&itag=18
Resolving o-o.preferred.mil01s10.v13.lscache5.c.youtube.com... 173.194.2.48, 2a00:1450:4002:3::10
Connecting to o-o.preferred.mil01s10.v13.lscache5.c.youtube.com|173.194.2.48|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
2011-08-19 00:14:22 ERROR 403: Forbidden.
--2011-08-19 00:14:22-- http://o-o.preferred.mil01s10.v1.lscache8.c.youtube.com/videoplayback?sparams=id,expire,ip,ipbits,itag,algorithm,burst,factor&fexp=907312,904535,913501,906918&algorithm=throttle-factor&itag=5&ip=93.0.0.0&burst=40&sver=3&signature=2D1C0BD8F7B617691F9905E79502E1FFFFF86611.C19F9CC435873BBC955C5FF82F60F7B90D140AFD&expire=1313733600&key=yt1&ipbits=8&factor=1.25&id=e7fc427eba627f84&quality=small&fallback_host=tc.v1.cache8.c.youtube.com&type=video/x-flv&itag=5
Resolving o-o.preferred.mil01s10.v1.lscache8.c.youtube.com... 173.194.2.38, 2a00:1450:4002:3::6
Connecting to o-o.preferred.mil01s10.v1.lscache8.c.youtube.com|173.194.2.38|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
2011-08-19 00:14:22 ERROR 403: Forbidden.
Come puoi vedere wget
dall'output, gli URL sembrano sintatticamente corretti, ma i server restituiscono sempre un 403. Questo accade indipendentemente dal video che provo.
Sto cercando di scaricare i file dallo stesso indirizzo IP e computer con cui ho generato i collegamenti. Qualche idea?