youtube-mp3.org api 无法正常工作,仅下载缓存的视频

发布于 2024-12-25 14:19:03 字数 776 浏览 2 评论 0原文

以前我可以通过 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 的值为“正在服务”后,我通过获取 的值来启动最后一个请求key h 来自先前请求的 JSON 响应,这将下载 mp3 文件。

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

现在第一个请求总是不返回任何内容。仅当请求的视频缓存在其服务器上(如流行音乐视频)时,第二个和第三个请求才会成功。如果情况并非如此,那么第二个请求将返回 nil,因此由于第二个请求中缺少 h 值,因此无法启动第三个请求。任何人都可以帮助我让网站开始转换吗?第一个 URL 需要出问题,我只是不知道是什么。谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

未央 2025-01-01 14:19:03

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

Accept-Location: *

否则,它将返回 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, like Gecko) Chrome/16.0.912.75 Safari/535.7";
wr.Headers.Add("Accept-Location", "*");
string res = (new StreamReader(wr.GetResponse().GetResponseStream())).ReadToEnd();

顺便说一句,您可以在浏览器的网络 (Chrome) 调试选项卡中跟踪标头。

问候

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文