added equality functions for tracks and currently playing
This commit is contained in:
parent
2ef5e9c1c4
commit
de5da3e057
@ -94,5 +94,20 @@ class CurrentlyPlaying:
|
||||
f'context({self.context}) track({self.track}) device({self.device}) shuffle({self.shuffle}) ' \
|
||||
f'repeat({self.repeat}) time({self.timestamp})'
|
||||
|
||||
def __eq__(self, other):
|
||||
return isinstance(other, CurrentlyPlaying) and other.track == self.track
|
||||
|
||||
@staticmethod
|
||||
def _format_duration(duration):
|
||||
total_seconds = duration / 1000
|
||||
minutes = int((total_seconds/60) % 60)
|
||||
seconds = int(total_seconds % 60)
|
||||
return f'{minutes}:{seconds}'
|
||||
|
||||
def __str__(self):
|
||||
return f'playing: {self.is_playing} - {self.track} on {self.device}'
|
||||
if self.is_playing:
|
||||
playing = 'playing'
|
||||
else:
|
||||
playing = '(paused)'
|
||||
|
||||
return f'{playing} {self.track} on {self.device} ({self._format_duration(self.progress_ms)})'
|
||||
|
@ -53,6 +53,9 @@ class Track:
|
||||
return Color.YELLOW + Color.BOLD + 'Track' + Color.END + \
|
||||
f': {self.name}, ({self.album}), {self.artists}'
|
||||
|
||||
def __eq__(self, other):
|
||||
return isinstance(other, Track) and other.name == self.name and other.artists == self.artists
|
||||
|
||||
@staticmethod
|
||||
def wrap(name: str = None,
|
||||
artists: List[str] = None,
|
||||
@ -110,6 +113,9 @@ class SpotifyTrack(Track):
|
||||
|
||||
return string
|
||||
|
||||
def __eq__(self, other):
|
||||
return isinstance(other, SpotifyTrack) and other.uri == self.uri
|
||||
|
||||
@staticmethod
|
||||
def wrap(uri: Uri = None,
|
||||
name: str = None,
|
||||
|
Loading…
Reference in New Issue
Block a user