Skip to content
This repository has been archived by the owner on Dec 20, 2022. It is now read-only.

YouTube MP3 API

Kofel edited this page Jun 7, 2012 · 2 revisions

YouTube MP3 API:

This gem was build on top of YouTube-Mp3.org. Every MP3 file convertion are made by them.

Every request must have Accept-Location: * in headers

Request video conversion

http://www.youtube-mp3.org/api/pushItem/?item=#{video_url}&xy=yx&bf=false&r=#{Time.now.to_i} => video_id

HTTParty.get("http://www.youtube-mp3.org/api/pushItem/?item=http%3A//www.youtube.com/watch%3Fv%3D41L3a0QUzwY%26feature%3Dg-all-u&xy=yx&bf=false&r=#{Time.now.to_i}").body
=> "41L3a0QUzwY"

Get video info (we need it to get a hash). Repeat until status is "serving".

http://www.youtube-mp3.org/api/itemInfo/?video_id=#{video_id}&ac=www&r=#{Time.now.to_i} => info JSON fetched by response.body.match(/\Ainfo = (.*?);\z/)[1]

response = HTTParty.get("http://www.youtube-mp3.org/api/itemInfo/?video_id=3D41L3a0QUzwY&ac=www&r=#{Time.now.to_i}")
response.body.match(/\Ainfo = (.*?);\z/)[1]
=> INFO JSON