From 29c0ca3ff669af39471324dbd7d1acafa72eb50d Mon Sep 17 00:00:00 2001 From: Dniel97 <6324072+Dniel97@users.noreply.github.com> Date: Fri, 11 Mar 2022 00:23:39 +0100 Subject: [PATCH] Playlist search and creator fixed, version added to search --- interface.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/interface.py b/interface.py index 44cdb90..72f99ea 100644 --- a/interface.py +++ b/interface.py @@ -185,21 +185,29 @@ class ModuleInterface: artists = None year = None elif query_type is DownloadTypeEnum.playlist: - name = i.get('title') - artists = [i.get('creator').get('name')] - year = "" + if 'name' in i.get('creator'): + artists = [i.get('creator').get('name')] + elif i.get('type') == 'EDITORIAL': + artists = ['TIDAL'] + else: + artists = ['Unknown'] + + # TODO: Use playlist creation date or lastUpdated? + year = i.get('created')[:4] elif query_type is DownloadTypeEnum.track: - name = i.get('title') artists = [j.get('name') for j in i.get('artists')] # Getting the year from the album? year = i.get('album').get('releaseDate')[:4] elif query_type is DownloadTypeEnum.album: - name = i.get('title') artists = [j.get('name') for j in i.get('artists')] year = i.get('releaseDate')[:4] else: raise Exception('Query type is invalid') + if query_type is not DownloadTypeEnum.artist: + name = i.get('title') + name += f' ({i.get("version")})' if i.get("version") else '' + additional = None if query_type is not DownloadTypeEnum.artist: if i.get('audioModes') == ['DOLBY_ATMOS']: @@ -215,7 +223,7 @@ class ModuleInterface: name=name, artists=artists, year=year, - result_id=str(i.get('id')), + result_id=str(i.get('id')) if query_type is not DownloadTypeEnum.playlist else i.get('uuid'), explicit=i.get('explicit'), additional=[additional] if additional else None ) @@ -232,7 +240,7 @@ class ModuleInterface: if 'name' in playlist_data.get('creator'): creator_name = playlist_data.get('creator').get('name') - elif playlist_data.get('creator').get('id') == 0: + elif playlist_data.get('type') == 'EDITORIAL': creator_name = 'TIDAL' else: creator_name = 'Unknown' @@ -606,7 +614,7 @@ class ModuleInterface: # get lyrics data for current track id lyrics_data = self.session.get_lyrics(track_id) - if 'error' in lyrics_data: + if 'error' in lyrics_data and track_data: # search for title and artist to find a matching track (non Atmos) results = self.search( DownloadTypeEnum.track,