Possible to start a Qobuz playlist and/or WiiM preset from the HTTP API?

RSF

Member
Joined
May 15, 2023
Messages
29
I'm trying to create shortcuts on my phone to start playing various Qobuz playlists via the HTTP API for WiiM. I see the "play" and "playlist" commands in the API documentation but can't figure out how to use them to start a Qobuz personal playlist, or, alternatively, to start a WiiM Preset (which would be an acceptable alternative).

Has anyone figured this out? Examples would be very helpful.

Thanks in advance.
 
Last edited:
You can try the UPnP interface, which is much more full featured.

An excerpt from my wmq terminal app:

Python:
def do_search(query="",node="playlist"):
  
    dev=conf['dev']
    app_id=conf['app_id']
              
    url=f'https://www.qobuz.com/api.json/0.2/{node}/search?query={query}&limit=100&offset=0&app_id={app_id}'
    try:
        ret = requests.get(url).json()
        items = ret[f"{node}s"]["items"]
    except:
        return ""
  
    options=[]
    idx=1
    for item in items:
        if node=="album":
            preview=[str(item["id"]),str(item["artist"]["id"]),f'Tracks: {item["tracks_count"]}',f'Released: {item["release_date_original"]}', f'Quality: {item["maximum_bit_depth"]}/{item["maximum_sampling_rate"]}']
            preview="~".join(preview)
      
            option = f'{idx} {item["artist"]["name"]} - {item["title"]}|{preview}'
        else:
            preview=f'{item["name"]}^Tracks: {item["tracks_count"]}^{item["description"]}'
            option = f'{idx} {item["name"]}|{preview}'
                                      
        options.append(option)
        idx = idx+1
      
      
    terminal_menu = TerminalMenu(options,
                                 clear_screen=True,
                                 title="Enter:Play Esc:Exit",
                                 preview_command=from_title,
                                 preview_size=0.5)
                              
    menu_entry_index = terminal_menu.show()
              
    if menu_entry_index == None:
        return
    else:
        if node=="album":           
            list_name=items[menu_entry_index]["title"].replace("&","&")
            extra=""       
        else:
            list_name=items[menu_entry_index]["name"].replace("&","&")
            extra="&extra=tracks,subscribers&limit=100&"       

        list_name = list_name.upper()
        item_id=items[menu_entry_index]["id"]
        user_auth_token=conf["accessToken"]
        Login_username=conf["Login_username"]
      

        xml = f'<?xml version="1.0"?><PlayList><ListName>{list_name}</ListName><ListInfo><SourceName>Qobuz</SourceName><requestQuality>6</requestQuality> <SearchUrl>https://www.qobuz.com/api.json/0.2/{node}/get?{node}_id={item_id}{extra}</SearchUrl><Login_username>{Login_username}</Login_username></ListInfo></PlayList>'

        #### Populate the WiiM Queue
        dev.PlayQueue.CreateQueue(QueueContext=xml)

        #### Play
        dev.PlayQueue.PlayQueueWithIndex(QueueName=list_name,Index=0)

...and a query for Qobuz "cool jazz" playlists:

Screenshot 2023-05-17 9.41.40 PM.png
 
Last edited:
  • Like
Reactions: RSF
I'm trying to create shortcuts on my phone to start playing various Qobuz playlists via the HTTP API for WiiM. I see the "play" and "playlist" commands in the API documentation but can't figure out how to use them to start a Qobuz personal playlist, or, alternatively, to start a WiiM Preset (which would be an acceptable alternative).

Has anyone figured this out? Examples would be very helpful.

Thanks in advance.
MCUKeyShortClick:x for calling a preset.
 
  • Love
Reactions: RSF
@onlyoneme - Thanks very much! Works perfectly.

I'd seen a reference to that in this thread, but tried it with syntax https://<ip>/httpapi.asp?command=setPlayerCmd:MCUKeyShortClick:x, since the Play stream and Play playlist commands had that setPlayerCmd prefix. That didn't work. so I assumed it worked only with Home Assistant, mentioned in that thread.

But trying just https://<ip>/httpapi.asp?command=MCUKeyShortClick:x (no setPlayerCmd: prefix) worked. Thanks again.


@cc_rider - Thanks as well. I'll look into that UPnP interface more over time.
 
Back
Top