Playlist search and creator fixed, version added to search

This commit is contained in:
Dniel97
2022-03-11 00:23:39 +01:00
parent 186c6f7e10
commit 29c0ca3ff6

View File

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