android youtube download url 403被禁止 [英] android youtube download url 403 forbidden

查看:258
本文介绍了android youtube download url 403被禁止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有些视频无法下载。



我使用这个



<$ p下载了url $ p> http://www.youtube.com/get_video_info?video_id=itGNQbJwRSk





总URL:

  http://r1---sn-a5m7lnek.googlevideo.com/videoplayback?expire=1391267516&ms=au&source=youtube&sver=3&upn=OzZzFV_-2o4&id=8ad18d41b2704529& ; ITAG = 22&安培; MT = 1391243224&安培; ipbits = 0&安培; ratebypass = YES&安培; FEXP = 935622%2C914924%2C926515%2C916623%2C936910%2C936913&安培; sparams = GCR%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&安培; mv = m& ip = 183.101.166.55& key = yt5& gcr = kr& signature = F303D0C863C27A6A46124A09E40F308BB67181E013.3FA3E17460DDF6ECA004D9E48B1356849534EBFFFF 

每个参数分隔的网址:

  http://r1---sn-a5m7lnek.googlevideo.com/视频回放? 

expire = 1391267516&

ms = au&

source = youtube&

sver = 3&

upn = OzZzFV_-2o4&

id = 8ad18d41b2704529&

itag = 22&

mt = 1391243224&

ipbits = 0&

ratebypass = yes&

fexp = 935622%2C914924%2C926515%2C916623%2C936910%2C936913&

sparams = gcr%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&

mv = m&

ip = 183.101.166.55&

key = yt5&

gcr = kr&

签名= F303D0C863C27A6A46124A09E40F308BB67181E013.3FA3E17460DDF6ECA004D9E48B1356849534EBFFFF

我使用下面的代码在开放流

  u =新的URL(url); 
HttpURLConnection huc =(HttpURLConnection)u.openConnection(); //知道视频的大小
huc.setRequestProperty(User-Agent,Mozilla / 5.0(Macintosh; Intel Mac OS X 10_9_1 )AppleWebKit / 537.36(KHTML,像Gecko)Chrome / 32.0.1700.102 Safari / 537.36);
huc.setRequestProperty(Accept,* / *);
huc.setRequestMethod(GET);
huc.setDoOutput(false);
int size = huc.getContentLength();
int status = huc.getResponseCode();
Log.e(download,status + huc.getResponseMessage());
is = new BufferedInputStream(huc.getInputStream());

但它返回status = 403,size = -1。
我找不到任何帮助。



有没有人有想法?

解决方案

此视频正在使用密码,您可以在 http: //www.youtube.com/get_video_info?video_id=itGNQbJwRSk

 'use_cipher_signature = True'

要下载此类型的视频,首先必须解码它的签名。
播放器文件(HTML5播放器或Flash播放器)中存在解码算法



解码后,您必须使用相同的IP地址从您的已经获取所有信息。 (您可以使用代理绕过同一个IP限制)



最好使用刮擦该特定视频的网页并搜索; ytplayer.config = {(。*?)}; 。这包含了所有必需的信息。



如果您不想删除,则可以使用以下方法获取JSON对象

  https://www.youtube.com/watch?v=<Video-ID>&spf=prefetch 

请检查此API以方便解决: CipherAPI



另一个很酷的API: YTstream API


there are some videos that can't download.

I got download url by using this

http://www.youtube.com/get_video_info?video_id=itGNQbJwRSk

Is there anyone why below url is not available to download?

total url:

http://r1---sn-a5m7lnek.googlevideo.com/videoplayback?expire=1391267516&ms=au&source=youtube&sver=3&upn=OzZzFV_-2o4&id=8ad18d41b2704529&itag=22&mt=1391243224&ipbits=0&ratebypass=yes&fexp=935622%2C914924%2C926515%2C916623%2C936910%2C936913&sparams=gcr%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&mv=m&ip=183.101.166.55&key=yt5&gcr=kr&signature=F303D0C863C27A6A46124A09E40F308BB67181E013.3FA3E17460DDF6ECA004D9E48B1356849534EBFFFF

separated url with each params:

http://r1---sn-a5m7lnek.googlevideo.com/videoplayback?

expire=1391267516&

ms=au&

source=youtube&

sver=3&

upn=OzZzFV_-2o4&

id=8ad18d41b2704529&

itag=22&

mt=1391243224&

ipbits=0&

ratebypass=yes&

fexp=935622%2C914924%2C926515%2C916623%2C936910%2C936913&

sparams=gcr%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&

mv=m&

ip=183.101.166.55&

key=yt5&

gcr=kr&

signature=F303D0C863C27A6A46124A09E40F308BB67181E013.3FA3E17460DDF6ECA004D9E48B1356849534EBFFFF

and I used below codes in open stream

    u = new URL(url);
    HttpURLConnection huc = (HttpURLConnection)u.openConnection();//to know the size of video
    huc.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.102 Safari/537.36");
    huc.setRequestProperty("Accept","*/*");
    huc.setRequestMethod("GET");
    huc.setDoOutput(false);
    int size = huc.getContentLength();      
    int status = huc.getResponseCode();
    Log.e("download", status+ huc.getResponseMessage());
    is = new BufferedInputStream(huc.getInputStream());

but it returns status = 403, size = -1. I couldn't find anything to help yet.

Is there anyone have a idea?

解决方案

This video is using cipher signatrue as you can see in the info returned by http://www.youtube.com/get_video_info?video_id=itGNQbJwRSk has

'use_cipher_signature=True'

To download this type of video, first you have to decode it's signature. Decoding algorithm is present in the player file (HTML5player or Flash player)

After decoding you have to use the same IP address to download the video from where you have fetched all the information. (You can bypass same IP restriction using Proxy)

Its better to use the scrape the webpage of that particular video and search for ;ytplayer.config = {(.*?)}; . This contains all the required infomation.

If you don't want to scrape then you can use below method to get the JSON object

https://www.youtube.com/watch?v=<Video-ID>&spf=prefetch

Please check this API for easy solution: CipherAPI

Another cool API: YTstream API

这篇关于android youtube download url 403被禁止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆