ivandotv / radio-browser-api

Wrapper around free and open-source radio browser API. It simplifies the task of querying the API
https://api.radio-browser.info/
MIT License
48 stars 17 forks source link

404 response on each request for method getStationByUrl #109

Closed lorenzovianello-vivaldigroup closed 1 month ago

lorenzovianello-vivaldigroup commented 2 years ago

Hi, I'm using the package with mpc in linux, and i'm trying to fetch webradio's favicon with the following code

///url is the field urlResolved of Station
async function getFaviconFromPlayback(url:string):Promise<string>{
    api = new RadioBrowserApi("generic-api", true)
    return await api.getStationByUrl(url).then((stations)=>{
        if(stations.length>0){
            return stations[0].favicon
        }else{
            return ""
        }
    }).catch(e => {
        console.error(e)
        return ""
    })
}

After each call its return the same error

Sep 14 15:11:16 PIETRO node[16014]: Response {
Sep 14 15:11:16 PIETRO node[16014]:   size: 0,
Sep 14 15:11:16 PIETRO node[16014]:   timeout: 0,
Sep 14 15:11:16 PIETRO node[16014]:   [Symbol(Body internals)]: {
Sep 14 15:11:16 PIETRO node[16014]:     body: PassThrough {
Sep 14 15:11:16 PIETRO node[16014]:       _readableState: [ReadableState],
Sep 14 15:11:16 PIETRO node[16014]:       _events: [Object: null prototype],
Sep 14 15:11:16 PIETRO node[16014]:       _eventsCount: 2,
Sep 14 15:11:16 PIETRO node[16014]:       _maxListeners: undefined,
Sep 14 15:11:16 PIETRO node[16014]:       _writableState: [WritableState],
Sep 14 15:11:16 PIETRO node[16014]:       allowHalfOpen: true,
Sep 14 15:11:16 PIETRO node[16014]:       [Symbol(kCapture)]: false,
Sep 14 15:11:16 PIETRO node[16014]:       [Symbol(kCallback)]: null
Sep 14 15:11:16 PIETRO node[16014]:     },
Sep 14 15:11:16 PIETRO node[16014]:     disturbed: false,
Sep 14 15:11:16 PIETRO node[16014]:     error: null
Sep 14 15:11:16 PIETRO node[16014]:   },
Sep 14 15:11:16 PIETRO node[16014]:   [Symbol(Response internals)]: {
Sep 14 15:11:16 PIETRO node[16014]:     url: 'https://de1.api.radio-browser.info/json/stations/byurl/http://149.13.0.81/bgestrada',
Sep 14 15:11:16 PIETRO node[16014]:     status: 404,
Sep 14 15:11:16 PIETRO node[16014]:     statusText: 'Not Found',
Sep 14 15:11:16 PIETRO node[16014]:     headers: Headers { [Symbol(map)]: [Object: null prototype] },
Sep 14 15:11:16 PIETRO node[16014]:     counter: 0
Sep 14 15:11:16 PIETRO node[16014]:   }
Sep 14 15:11:16 PIETRO node[16014]: }

The error persists even if using different urls of WORKING radios

Any idea about?

svedue commented 7 months ago

there is a bug: https://de1.api.radio-browser.info/json/stations/byurl/http://149.13.0.81/bgestrada must be https://de1.api.radio-browser.info/json/stations/byurl?url=http://149.13.0.81/bgestrada

ivandotv commented 7 months ago

@svedue Would you like to submit a PR?

svedue commented 7 months ago

@svedue Would you like to submit a PR?

sure. Just lacking permissions. Fixed it in fork over here: https://github.com/svedue/radio-browser-api

ivandotv commented 7 months ago

@svedue Please read the docs for creating a pull request against a public repository https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork