Get webradio URL by API

Is it possibe to get the URL from the current played Webradio?

Example: I started Radio Gong by

POST http://127.0.0.1:3000/api/v1/replaceAndPlay
    {
                "service": "webradio",
                "type": "webradio",
                "title": "Gong 97.1",
                "uri": "http://opml.radiotime.com/Tune.ashx?id=s78373"
    }

then I switch the radio station by the WebGUI and want to get the

http://opml.radiotime.com/Tune.ashx?id=xxxxx

URL (not the stream URL) from the new station. Is this possible?

Background I’m want to control my volumio by physical button (raspberry, i2c mcp23017 input) and want to save the current radio station by a long press on a button.

you can see it in http://<your ip>/dev
btw your still missing albumart in your example if not added you will not see it in volumio.

 { "service": "webradio",
 "type": "webradio", "title": "Arrow Classic Rock",
 "albumart": "http://cdn-profiles.tunein.com/s6702/images/logoq.jpg",
 "uri": "https://www.mp3streams.nl/zender/arrow-classic-rock/stream/13-mp3-128" }

http://<your ip>/dev
unfortunately does not show the http://opml.radiotime.com... URL.

Example: I search for
http://localhost:3000/api/v1/search?query=Gong
Answer is:
{ "service": "webradio", "type": "webradio", "title": "Gong 97.1", "artist": "", "album": "", "albumart": "http://cdn-profiles.tunein.com/s78373/images/logoq.jpg?t=155265", "icon": "", "uri": "http://opml.radiotime.com/Tune.ashx?id=s78373" }

I start playing this json with
http://127.0.0.1:3000/api/v1/replaceAndPlay

Then dev says as state:
{"status":"play","position":0,"title":"U2 - Beautiful day","artist":"Gong 97.1","album":null,"albumart":"http://cdn-profiles.tunein.com/s78373/images/logoq.jpg?t=155265","uri":"http://addrad.io/44552sq?DIST=TuneIn&TGT=TuneIn&maxServers=2&partnertok=eyJhbGciOiJIUzI1NiIsImtpZCI6InR1bmVpbiIsInR5cCI6IkpXVCJ9.eyJ0cnVzdGVkX3BhcnRuZXIiOnRydWUsImlhdCI6MTYzMzAxNzQxNywiaXNzIjoidGlzcnYifQ.qQzflil8EU6NxZOiYCRnegT4d7RTpky-93OwDh_6G48","trackType":"webradio","seek":80002,"duration":0,"samplerate":"","bitdepth":"","channels":2,"bitrate":"128 Kbps","random":null,"repeat":null,"repeatSingle":false,"consume":true,"volume":100,"mute":false,"disableVolumeControl":true,"stream":true,"updatedb":false,"volatile":false,"service":"webradio"}
And the queue:
Gong 97.1Remove Service: webradio Uri: http://addrad.io/44552sq?DIST=TuneIn&TGT=TuneIn&maxServers=2&partnertok=eyJhbGciOiJIUzI1NiIsImtpZCI6InR1bmVpbiIsInR5cCI6IkpXVCJ9.eyJ0cnVzdGVkX3BhcnRuZXIiOnRydWUsImlhdCI6MTYzMzAxNzQxNywiaXNzIjoidGlzcnYifQ.qQzflil8EU6NxZOiYCRnegT4d7RTpky-93OwDh_6G48 Albumart: http://cdn-profiles.tunein.com/s78373/images/logoq.jpg?t=155265

and the
http://opml.radiotime.com/Tune.ashx URL is not shown, just the http://addrad.i..URL but this is the stream URL.

BTW: If you use the http://opml.radiotime.com/Tune.ashx?id=s78373 URL you to not need to specify a albumart. Volumio gets this automatically.

  1. opml… url will open the other one that is included in the m3u that is the http://addrad.io
    that’s why you don’t see it because the addrad.io is the real url

oke you do it local i do it remote should be the same ony i use no local ip

in the dev is all that is playing most of the time i remove the token.

http://opml.radiotime.com/Tune.ashx?id=s78373 redirects to a .m3u with the real link.

uri: http://addrad.io/44552sq?DIST=TuneIn&TGT=TuneIn&maxServers=2

albumart you have to add if you do it remote:
albumart: http://cdn-profiles.tunein.com/s78373/images/logoq.jpg

Ok, got i working :slight_smile:
But you agree with me, the .m3u link ( http://opml.radiotime.com/Tune.ashx?id=s78373) is not included in the dev page (I also call the dev page over LAN) ?

Thats working for me:
Read the state by /api/v1/getState this returns:

{
‘repeatSingle’: False,
‘stream’: True,
‘bitdepth’: ‘’,
‘duration’: 0,
‘consume’: True,
‘status’: ‘play’,
‘artist’: ‘Gong 97.1’,
‘uri’: ‘http://addrad.io/44552sq?DIST=TuneIn&TGT=TuneIn&maxServers=2&partnertok=eyJhbGciOiJIUzI1NiIsImtpZCI6InR1bmVpbiIsInR5cCI6IkpXVCJ9.eyJ0cnVzdGVkX3BhcnRuZXIiOnRydWUsImlhdCI6MTYzMzA2NjY3NywiaXNzIjoidGlzcnYifQ.Ue6UoihBwv8cxh8IC8fwrUrTFCcOOyRH_qroVMHOHXU’,
‘samplerate’: ‘’,
‘position’: 0,
‘service’: ‘webradio’,
‘album’: None,
‘volatile’: False,
‘random’: None,
‘mute’: False,
‘bitrate’: ‘128 Kbps’,
‘albumart’: ‘myhttp://cdn-profiles.tunein.com/s78373/images/logoq.jpg?t=155265’,
‘volume’: 100,
‘updatedb’: False,
‘title’: ‘INXS - New sensation’,
‘disableVolumeControl’: True,
‘repeat’: None, ‘channels’: 2,
‘seek’: 15708,
‘trackType’: ‘webradio’
}

then I transform and save it to

{
‘type’: ‘webradio’,
‘albumart’: ‘myhttp://cdn-profiles.tunein.com/s78373/images/logoq.jpg?t=155265’,
‘title’: ‘Gong 97.1’,
‘uri’: ‘http://addrad.io/44552sq’,
‘service’: ‘webradio’
}

by

HTTPResponse = requests.get(self._url+'/api/v1/getState')
if HTTPResponse.status_code==200:
    State=json.loads(HTTPResponse.text)
    if State.__contains__("artist"):
        print("getState:{0}".format(str(State)))
        print("Artist: "+State["artist"])
        OnAir=dict()
        # print(str(State))
        for Prop in Volumio.RequieredPropertiesForPlay:
            OnAir[Prop]=State[Prop]
        URL=urllib.parse.urlparse(OnAir["uri"])
        OnAir["uri"]=URL.scheme+"://"+URL.netloc+URL.path
        OnAir["type"]=OnAir["service"]
        OnAir["title"]=State["artist"]
        self.State=State        
        return(OnAir)
        # Search in List, urlencode (%20..) makes requests
    else:
        print("No artist found in current volumio state")
else:
    self.State=None
    print("Error occured during getting current volumio state") 

I replaced here the album art URL http to myhttp because as a new user in this forum I could only post 2 Links…