fixed str method checking existence of child objects
This commit is contained in:
parent
57eee7a474
commit
1a2970bc5d
@ -3,6 +3,7 @@ import functools
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from spotframework.util.console import Color
|
||||
from spotframework.net.network import Network
|
||||
from spotframework.listener.thread import ListenerThread
|
||||
|
||||
@ -75,7 +76,8 @@ class ListenCmd(Cmd):
|
||||
:param tracks: list of target track objects
|
||||
:return: None
|
||||
"""
|
||||
[print(f'({i.played_at.strftime(self.dt_format)}) {i.name} / {i.artists_names}')
|
||||
[print(f'({i.played_at.strftime(self.dt_format)}) {Color.BOLD}{Color.RED}{i.name}{Color.END} / '
|
||||
f'{i.album.name} / {Color.BOLD}{Color.BLUE}{i.artists_names}{Color.END}')
|
||||
for i in tracks]
|
||||
|
||||
def print(self):
|
||||
|
@ -27,7 +27,7 @@ class Album:
|
||||
return ', '.join(string_list)
|
||||
|
||||
def __str__(self):
|
||||
artists = ', '.join([i.name for i in self.artists]) if self.artists else 'n/a'
|
||||
artists = ', '.join([i.name for i in self.artists]) if self.artists is not None else 'n/a'
|
||||
|
||||
return f'{self.name} / {artists}'
|
||||
|
||||
|
@ -44,8 +44,8 @@ class Track:
|
||||
return ', '.join(string_list)
|
||||
|
||||
def __str__(self):
|
||||
album = self.album.name if self.album else 'n/a'
|
||||
artists = ', '.join([i.name for i in self.artists]) if self.artists else 'n/a'
|
||||
album = self.album.name if self.album is not None else 'n/a'
|
||||
artists = ', '.join([i.name for i in self.artists]) if self.artists is not None else 'n/a'
|
||||
|
||||
return f'{self.name} / {album} / {artists}'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user