Saya mencoba mengunduh semua file yang tersedia dengan kualitas berbeda dari satu video menggunakan YouTube API, tetapi setiap URL yang saya ikuti untuk mengunduh hasil video di 403.
Naskah:
#!/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}"
Keluaran:
$ ./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.
Seperti yang dapat Anda lihat dari wget
output, URL tampaknya benar secara sintaksis, tetapi server selalu mengembalikan 403. Ini terjadi terlepas dari video mana yang saya coba.
Saya mencoba mengunduh file dari alamat IP dan komputer yang sama dengan tempat saya membuat tautan. Ada ide?
Jawaban:
Anda mungkin mendapatkan
403
kesalahan karena tidak diautentikasi melaluiwget
perintah Anda . Youtube hanya memungkinkan mengunduh video yang Anda miliki. Untuk itu Anda harus diautentikasi.TOS Youtube
Dukungan mengunduh Youtube
sumber
Saya pikir Anda harus mempelajari halaman web ini dengan cermat.
Jangan lupa bahwa Youtube adalah produk yang diciptakan oleh Google. Sama seperti Google Map, Anda harus mendapatkan Kunci API terlebih dahulu
sumber