Solved Can somebody help a newbie out with a json call. Please.
#1
[edit] Nevermind. I'm dumb and I didn't think about using the album id as a filter instead of album name until just now. Oyyyyy!

I can't for the life of me figure out how to filter a json call to get songs from an album using album and artist. I figured out the call to get songs from an album by album name with the code below but the problem is if the album is named "Greatest Hits" I get all songs from all albums in the database with an album named "Greatest Hits". I tried several different ways of adding another filter in the call with the artist name but I just can't seem to get it to work. Can somebody please help me out with the correct code. Thanks in advance.

python:
def get_album_songs(album):
    properties = [ "artist", "duration", "album", "track", "thumbnail" ]
    data = get_json(method="AudioLibrary.GetSongs",
                    params= {"properties": properties,"filter":{"field":"album", "operator":"is", "value":"%s" % album,"sort": { "order": "ascending", "method": "track" } }})

    if "result" in data and "songs" in data["result"]:
        return data["result"]["songs"]
    return []
Reply
#2
Think you are looking for "and":

json:
"filter":{"and":[{"field":"album", "operator"...}, {"field":"artist", "operator"...}]}

scott s.
.
Reply
#3
(2024-01-13, 03:11)scott967 Wrote: Think you are looking for "and":

json:
"filter":{"and":[{"field":"album", "operator"...}, {"field":"artist", "operator"...}]}

scott s.
.
Thank you. Much appreciated. I will use this.
Reply

Logout Mark Read Team Forum Stats Members Help
Can somebody help a newbie out with a json call. Please.0