youtube-mp3.org api无法正常工作,只能下载缓存的视频 [英] youtube-mp3.org api not working properly, only downloads cached videos

查看:274
本文介绍了youtube-mp3.org api无法正常工作,只能下载缓存的视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以前,我可以通过youtube-mp3.org下载YouTube视频mp3。使用此方法:

  http:/ /www.youtube-mp3.org/api/pushItem/?item=http%3A//www.youtube.com/watch%3Fv%3D<VIDEOID>&xy=_ 

然后它返回视频ID,他们开始在服务器上转换视频。那么这个请求会返回一个包含视频信息和当前转换状态的JSON字符串:

  http://www.youtube -mp3.org/api/itemInfo/?video_id=<VIDEOID>&adloc= 

之后重复请求,直到 status 的值为'正在服务',然后通过获取密钥的值 h 从上一个请求的JSON响应中,这将下载一个mp3文件。

  http://www.youtube -mp3.org/get?video_id=<VIDEOID>&h=<JSON字符串值h> 

现在第一个请求总是没有返回。如果所请求的视频缓存在其服务器上(如流行音乐视频),则第二和第三个请求只能成功。如果不是这种情况,那么第二个请求将返回无效,因此第三个请求无法启动,因为第二个请求中缺少 h 值。任何人都可以帮助我让网站开始转换一些需要错误的第一个URL,我只是不知道什么。谢谢

解决方案

我刚刚测试过。对于第一个请求,您需要发送一个标题:

 接受位置:* 

否则,将返回500(内部服务器错误)。但是使用该标题,它将返回一个youtube视频ID的字符串,您可以使用第二个api来检查进度。



这是我用于的C#代码测试:

  HttpWebRequest wr =(HttpWebRequest)WebRequest.Create(FIRST_API_URL); 
wr.UserAgent =Mozilla / 5.0(Windows NT 6.1; WOW64)AppleWebKit / 535.7(KHTML,像Gecko)Chrome / 16.0.912.75 Safari / 535.7;
wr.Headers.Add(Accept-Location,*);
string res =(new StreamReader(wr.GetResponse()。GetResponseStream()))。ReadToEnd();您可以在浏览器的网络(Chrome)调试标签中跟踪标题。

p>

问候


Previously i was able to download YouTube videos as mp3 via youtube-mp3.org Using this method:

http://www.youtube-mp3.org/api/pushItem/?item=http%3A//www.youtube.com/watch%3Fv%3D<VIDEOID>&xy=_

Then it returned the video id and they started converting the video on their servers. Then this request would return a JSON string with info about the video and the current conversion status:

http://www.youtube-mp3.org/api/itemInfo/?video_id=<VIDEOID>&adloc=

After repeating the request until the value for status is 'serving' I then started the last request by taking the value for key h from the JSON response from the previous request, and this would download a the mp3 file.

http://www.youtube-mp3.org/get?video_id=<VIDEOID>&h=<JSON string value for h>

Now the first request always returns nothing. The second and third requests only succeed if the requested video is cached on their servers (like popular music videos). If thats not the case then the second request would return nil and so the 3rd request can't be started because of the missing hvalue from the second request. Could anybody help me with getting the website to start a conversion something needs to be wrong with the first URL i just dont know what. Thanks

解决方案

I just tested it. For the first request, you need to send with it a header of:

Accept-Location: *

Otherwise, it will return a 500 (Internal Server Error). But with that header, it will return a string of the youtube video id, and you can use the 2nd api for checking the progress.

Here's the C# code I used for testing:

HttpWebRequest wr = (HttpWebRequest)WebRequest.Create("FIRST_API_URL");
wr.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7";
wr.Headers.Add("Accept-Location", "*");
string res = (new StreamReader(wr.GetResponse().GetResponseStream())).ReadToEnd();

Btw, you can keep track of the headers in the browser's Network (Chrome) debug tab.

Regards

这篇关于youtube-mp3.org api无法正常工作,只能下载缓存的视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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