2024-01-11, 17:49
[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.
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 []