Kodi Community Forum
Solved Can somebody help a newbie out with a json call. Please. - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+---- Forum: JSON-RPC (https://forum.kodi.tv/forumdisplay.php?fid=174)
+---- Thread: Solved Can somebody help a newbie out with a json call. Please. (/showthread.php?tid=375744)



Can somebody help a newbie out with a json call. Please. - woodside - 2024-01-11

[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 []



RE: Can somebody help a newbie out with a json call. Please. - scott967 - 2024-01-13

Think you are looking for "and":

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

scott s.
.


RE: Can somebody help a newbie out with a json call. Please. - woodside - 2024-01-14

(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.