youtube-mp3.org api not working properly, only dow

2019-06-09 12:19发布

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

1条回答
小情绪 Triste *
2楼-- · 2019-06-09 12:43

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

查看更多
登录 后发表回答