From 121b86603c7ddbcf82c3a9c0fbf70bf095bdde36 Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Sat, 1 Aug 2020 10:50:42 -0600 Subject: [PATCH] Try again to fix #253 --- sublime/adapters/api_objects.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sublime/adapters/api_objects.py b/sublime/adapters/api_objects.py index 772d94e..cf34310 100644 --- a/sublime/adapters/api_objects.py +++ b/sublime/adapters/api_objects.py @@ -211,16 +211,23 @@ class SearchResult: def artists(self) -> List[Artist]: return self._to_result(self._artists, lambda a: (a.name,)) + def _try_get_artist_name(self, obj: Union[Album, Song]) -> Optional[str]: + try: + assert obj.artist + return obj.artist.name + except Exception: + return None + @property def albums(self) -> List[Album]: return self._to_result( - self._albums, lambda a: (a.name, a.artist.name if a.artist else None) + self._albums, lambda a: (a.name, self._try_get_artist_name(a)) ) @property def songs(self) -> List[Song]: return self._to_result( - self._songs, lambda s: (s.title, s.artist.name if s.artist else None) + self._songs, lambda s: (s.title, self._try_get_artist_name(s)) ) @property