catch no object response on count (for obscure items?)

This commit is contained in:
aj 2020-06-29 20:00:27 +01:00
parent 94075b14a8
commit b35b4c2b8c

View File

@ -100,7 +100,11 @@ class Counter:
fmtrack = self.fmnet.get_track(name=track.name, fmtrack = self.fmnet.get_track(name=track.name,
artist=track.artists[0].name, artist=track.artists[0].name,
username=username or self.fmnet.username) username=username or self.fmnet.username)
return fmtrack.user_scrobbles if fmtrack is not None:
return fmtrack.user_scrobbles
else:
logger.error(f'no track returned for {track}')
return 0
except LastFMNetworkException as e: except LastFMNetworkException as e:
logger.error(f'error occured during track retrieval - {e}') logger.error(f'error occured during track retrieval - {e}')
return 0 return 0
@ -123,7 +127,11 @@ class Counter:
fmalbum = self.fmnet.get_album(name=album.name, fmalbum = self.fmnet.get_album(name=album.name,
artist=album.artists[0].name, artist=album.artists[0].name,
username=username or self.fmnet.username) username=username or self.fmnet.username)
return fmalbum.user_scrobbles if fmalbum is not None:
return fmalbum.user_scrobbles
else:
logger.error(f'no track returned for {album}')
return 0
except LastFMNetworkException as e: except LastFMNetworkException as e:
logger.error(f'error occured during album retrieval - {e}') logger.error(f'error occured during album retrieval - {e}')
return 0 return 0
@ -144,7 +152,11 @@ class Counter:
try: try:
fmartist = self.fmnet.get_artist(name=artist.name, username=username or self.fmnet.username) fmartist = self.fmnet.get_artist(name=artist.name, username=username or self.fmnet.username)
return fmartist.user_scrobbles if fmartist is not None:
return fmartist.user_scrobbles
else:
logger.error(f'no track returned for {artist}')
return 0
except LastFMNetworkException as e: except LastFMNetworkException as e:
logger.error(f'error occured during artist retrieval - {e}') logger.error(f'error occured during artist retrieval - {e}')
return 0 return 0