diff --git a/maloja/apis/native_v1.py b/maloja/apis/native_v1.py index 94ac451..48c4c84 100644 --- a/maloja/apis/native_v1.py +++ b/maloja/apis/native_v1.py @@ -305,6 +305,7 @@ def get_charts_tracks_external(**keys): :return: list (List) :rtype: Dictionary""" k_filter, k_time, _, _, _ = uri_to_internal(keys,forceArtist=True) + # force artist because track charts can never be of a track or album, only of an artist or global ckeys = {**k_filter, **k_time} result = database.get_charts_tracks(**ckeys) diff --git a/maloja/malojauri.py b/maloja/malojauri.py index 350a7e4..287f504 100644 --- a/maloja/malojauri.py +++ b/maloja/malojauri.py @@ -12,14 +12,18 @@ def uri_to_internal(keys,forceTrack=False,forceArtist=False,forceAlbum=False,api # 3 keys that define interal time ranges # 4 keys that define amount limits - type = None - if forceTrack: type = "track" - if forceArtist: type = "artist" - if forceAlbum: type = "album" + # if we force a type, that only means that the other types are not allowed + # it could still have no type at all (any call that isn't filtering by entity) - if not type and "title" in keys: type = "track" - if not type and "albumtitle" in keys: type = "album" - if not type and "artist" in keys: type = "artist" + type = None + if forceTrack and "title" in keys: type = "track" + if forceArtist and "artist" in keys: type = "artist" + if forceAlbum and "albumtitle" in keys: type = "album" + + if (not forceTrack) and (not forceAlbum) and (not forceArtist) and (not type): + if "title" in keys: type = "track" + if "albumtitle" in keys: type = "album" + if "artist" in keys: type = "artist" # 1 if type == "track":