Es handelt sich hierbei um einen Freemium-Zugang, d.h. die Basis-Funktion ist kostenlos, jedoch mit Einschränkungen verbunden (sowas hieß früher mal 'ShareWare' ).
Die Quota beinhaltet 50 Anfragen pro Tag, bei maximal 10 Anfragen pro Minute.
Überschreitungen dieser Vorgaben resultieren mit einem entsprechenden Hinweis als Output.
Also alles im grünen Bereich.
Code: Select all
; https://rapidapi.com/Prasadbro/api/Youtube To Mp3
; Quota: 50/day, 10/minute
;
; Parameter
; reqType: <videoID>
; format: "json" (optional)
#SingleInstance, Force
#Include JSON().ahk
myAPIKey := "<your API key here>" ; get your API key from https://rapidapi.com
MsgBox % URLDownloadToVar("edPREMPZ5RA","json") ; requesting all key-values for that specific videoID as JSON string
MsgBox % URLDownloadToVar("edPREMPZ5RA").Download_url ; requesting key-value for 'Download_url'
MsgBox % URLDownloadToVar("supported_sites").1 ; requesting 1st key-value of 'supported sites'
yt := URLDownloadToVar("edPREMPZ5RA") ; requesting all key-values for that specific videoID as object
MsgBox % yt.Status "`n" ; show content of that object
. yt.Status_Code "`n"
. yt.Title "`n"
. yt.Download_Size "`n"
. yt.Video_Thumbnail "`n"
. yt.Full_Video_Link "`n"
. yt.Download_url
UrlDownloadToVar(reqType,format="") {
reqType := (reqType="supported_sites") ? "supported_sites" : "yt_to_mp3?video_id=" . reqType
req := ComObjCreate("Msxml2.XMLHTTP")
req.open("GET", "https://youtube-to-mp32.p.rapidapi.com/" . reqType, False)
req.setRequestHeader("x-rapidapi-key", myAPIKey)
req.setRequestHeader("x-rapidapi-host","youtube-to-mp32.p.rapidapi.com")
req.setRequestHeader("Content-Type","application/json; charset=utf-8")
req.Send(data)
yt := JSON.Load(req.responseText)
if (format="json") ; if 'json'-parameter has been set ..
Return req.responseText ; .. return output as JSON code, else ..
else
Return yt ; .. return output as an object.
}