2019-10-03 19:06:44 +01:00
|
|
|
from fmframework.model.fm import LastFM, Wiki
|
|
|
|
from fmframework.model.album import Album
|
|
|
|
from fmframework.model.artist import Artist
|
|
|
|
from fmframework.util.console import Color
|
|
|
|
|
|
|
|
|
|
|
|
class Track(LastFM):
|
|
|
|
def __init__(self,
|
|
|
|
name: str = None,
|
|
|
|
url: str = None,
|
|
|
|
mbid: str = None,
|
2019-10-03 21:14:49 +01:00
|
|
|
listeners: int = 0,
|
|
|
|
play_count: int = 0,
|
|
|
|
user_scrobbles: int = 0,
|
2019-10-03 19:06:44 +01:00
|
|
|
wiki: Wiki = None,
|
|
|
|
album: Album = None,
|
|
|
|
artist: Artist = None,
|
|
|
|
):
|
|
|
|
super().__init__(name=name,
|
|
|
|
url=url,
|
|
|
|
mbid=mbid,
|
|
|
|
listeners=listeners,
|
|
|
|
play_count=play_count,
|
|
|
|
user_scrobbles=user_scrobbles,
|
|
|
|
wiki=wiki)
|
|
|
|
self.album = album
|
|
|
|
self.artist = artist
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return f'{self.name} / {self.album} / {self.artist}'
|
|
|
|
|
|
|
|
def __repr__(self):
|
2019-10-03 21:14:49 +01:00
|
|
|
return Color.YELLOW + Color.BOLD + 'Track' + Color.END + \
|
2019-10-06 09:17:31 +01:00
|
|
|
f': {self.name} album({repr(self.album)}), artist({repr(self.artist)}) ' + super().__repr__()
|
2019-10-03 19:06:44 +01:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def wrap(name: str = None,
|
|
|
|
artist: str = None,
|
|
|
|
album: str = None,
|
|
|
|
album_artist: str = None,
|
|
|
|
url: str = None,
|
|
|
|
mbid: str = None,
|
|
|
|
listeners: int = None,
|
|
|
|
play_count: int = None,
|
|
|
|
user_scrobbles: int = None):
|
|
|
|
return Track(name=name,
|
|
|
|
album=Album.wrap(name=album, artist=album_artist),
|
|
|
|
artist=Artist(artist),
|
|
|
|
url=url,
|
|
|
|
mbid=mbid,
|
|
|
|
listeners=listeners,
|
|
|
|
play_count=play_count,
|
|
|
|
user_scrobbles=user_scrobbles)
|