imputnet / cobalt

best way to save what you love
https://cobalt.tools
GNU Affero General Public License v3.0
14.36k stars 1.14k forks source link

Allow GET requests to the API via query string. #707

Closed SmilerRyan closed 1 week ago

SmilerRyan commented 1 week ago

Allow GET requests to the API via query string

Currently in order to use this for my needs, i need to have a direct url in order to download video/audio and i'd like the ability to not have to host my own relay to convert GET request (in my case with just a youtube video id) to a POST request, then redirect with the url provided.

Additional Context

For example, the Discord bot I use seems to work great when using a direct url to media rather to music now, so I have to run an API of my own that calls the Cobalt API purely to receive the URL and redirect the user to it.

Example Code

Here is how this currently looks like as a POST request vs a GET request.

// POST request get get a stream URL
await fetch("https://api.cobalt.tools/api/json", {
    headers: {
        "Accept": "application/json",
        "Content-Type": "application/json",
    },
    body: JSON.stringify({
        aFormat: "best",
        filenamePattern: "nerdy",
        isAudioOnly: "true",
        url: "https://www.youtube.com/watch?v=wcT7zgL6gug"
    }),
    method: "POST",
})
.then(response => response.json())
.then(data => console.log(data.url))

// GET Request for YouTube Stream URL
await fetch("https://api.cobalt.tools/api/json?aFormat=best&filenamePattern=nerdy&isAudioOnly=true&url=https://youtu.be/wcT7zgL6gug").then(r=>{r.json();console.log(r.url)});
lostdusty commented 1 week ago

for anyone reading before the comment gets deleted, DO NOT run this on your computer, its malware. @wukko spam ^ @dumbmoron

wukko commented 1 week ago

we will not implement GET requests for main processing endpoint.