Fix GH-251

This commit is contained in:
krateng 2023-10-16 12:55:56 +02:00
parent 7c5099da8d
commit b64771b5c9
2 changed files with 12 additions and 7 deletions

View File

@ -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)

View File

@ -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":