tidal: Add track number to results when tracks are part of an album in artist search

This commit is contained in:
Manuel Cortez 2019-10-06 11:26:09 -05:00
parent 16d99aaaac
commit 10d60e3aa2
2 changed files with 12 additions and 1 deletions

View File

@ -4,6 +4,7 @@
* changes in Tidal:
* In the settings dialog, you can control wether Albums, compilations and singles will be added when searching by artist (by using artist://...).
* When searching by artists, results that belong to an album will be numbered.
## Version 0.6

View File

@ -81,10 +81,14 @@ class interface(base.baseInterface):
for album in singles:
tracks = self.session.get_album_tracks(album.id)
for track in tracks:
track.single = True
data.append(track)
for search_result in data:
s = base.song(self)
s.title = search_result.name
if not hasattr(search_result, "single"):
s.title = "{0}. {1}".format(self.format_number(search_result.track_num), search_result.name)
else:
s.title = search_result.name
s.artist = search_result.artist.name
s.duration = seconds_to_string(search_result.duration)
s.url = search_result.id
@ -92,6 +96,12 @@ class interface(base.baseInterface):
self.results.append(s)
log.debug("{0} results found.".format(len(self.results)))
def format_number(self, number):
if number < 10:
return "0%d" % (number)
else:
return number
def get_download_url(self, url):
url = self.session.get_media_url(url)
if url.startswith("https://") or url.startswith("http://") == False: