replace exception logging with exception level method
This commit is contained in:
parent
2f3f22de0d
commit
b6a7d3afe3
@ -371,4 +371,5 @@ def image(user=None):
|
|||||||
try:
|
try:
|
||||||
return jsonify({'images': net.get_playlist(uri_string=_playlist.uri).images, 'status': 'success'}), 200
|
return jsonify({'images': net.get_playlist(uri_string=_playlist.uri).images, 'status': 'success'}), 200
|
||||||
except SpotifyNetworkException as e:
|
except SpotifyNetworkException as e:
|
||||||
|
logger.exception(f'error occured during {_playlist.name} / {user.username} playlist retrieval')
|
||||||
return jsonify({'error': f"spotify error occured: {e.http_code}"}), 404
|
return jsonify({'error': f"spotify error occured: {e.http_code}"}), 404
|
||||||
|
@ -53,6 +53,7 @@ def play(user=None):
|
|||||||
else:
|
else:
|
||||||
return jsonify({'error': f"playlist {request_json['playlist_name']} not found"}), 404
|
return jsonify({'error': f"playlist {request_json['playlist_name']} not found"}), 404
|
||||||
except SpotifyNetworkException:
|
except SpotifyNetworkException:
|
||||||
|
logger.exception(f'error occured during {user.username} playlists retrieval')
|
||||||
return jsonify({'error': "playlists not returned"}), 400
|
return jsonify({'error': "playlists not returned"}), 400
|
||||||
|
|
||||||
elif 'tracks' in request_json:
|
elif 'tracks' in request_json:
|
||||||
|
@ -63,6 +63,7 @@ def count(user=None):
|
|||||||
else:
|
else:
|
||||||
return jsonify({'error': f'playlist {playlist_name} not found'}), 404
|
return jsonify({'error': f'playlist {playlist_name} not found'}), 404
|
||||||
except SpotifyNetworkException:
|
except SpotifyNetworkException:
|
||||||
|
logger.exception(f'error occured during {user.username} playlists retrieval')
|
||||||
return jsonify({'error': f'playlist {playlist_name} not found'}), 404
|
return jsonify({'error': f'playlist {playlist_name} not found'}), 404
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,8 +52,8 @@ def get_authed_spotify_network(user):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
net.refresh_user_info()
|
net.refresh_user_info()
|
||||||
except SpotifyNetworkException as e:
|
except SpotifyNetworkException:
|
||||||
logger.error(f'error refreshing user info for {user.username} = {e}')
|
logger.exception(f'error refreshing user info for {user.username}')
|
||||||
|
|
||||||
return net
|
return net
|
||||||
else:
|
else:
|
||||||
|
@ -17,6 +17,6 @@ def create_playlist(user, name):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
return net.create_playlist(net.user.user.display_name, name)
|
return net.create_playlist(net.user.user.display_name, name)
|
||||||
except SpotifyNetworkException as e:
|
except SpotifyNetworkException:
|
||||||
logger.error(f'error ocurred {user.username} / {name} - {e}')
|
logger.exception(f'error ocurred {user.username} / {name}')
|
||||||
return
|
return
|
||||||
|
@ -38,8 +38,8 @@ def refresh_lastfm_track_stats(username, playlist_name):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
spotify_playlist = spotnet.get_playlist(uri=Uri(playlist.uri))
|
spotify_playlist = spotnet.get_playlist(uri=Uri(playlist.uri))
|
||||||
except SpotifyNetworkException as e:
|
except SpotifyNetworkException:
|
||||||
logger.error(f'error retrieving spotify playlist {username} / {playlist_name} - {e}')
|
logger.exception(f'error retrieving spotify playlist {username} / {playlist_name}')
|
||||||
return
|
return
|
||||||
track_count = counter.count_playlist(playlist=spotify_playlist)
|
track_count = counter.count_playlist(playlist=spotify_playlist)
|
||||||
|
|
||||||
@ -49,8 +49,8 @@ def refresh_lastfm_track_stats(username, playlist_name):
|
|||||||
percent = round((track_count * 100) / user_count, 2)
|
percent = round((track_count * 100) / user_count, 2)
|
||||||
else:
|
else:
|
||||||
percent = 0
|
percent = 0
|
||||||
except LastFMNetworkException as e:
|
except LastFMNetworkException:
|
||||||
logger.error(f'error while retrieving user scrobble count - {e}')
|
logger.exception(f'error while retrieving user scrobble count {username} / {playlist_name}')
|
||||||
percent = 0
|
percent = 0
|
||||||
|
|
||||||
playlist.lastfm_stat_count = track_count
|
playlist.lastfm_stat_count = track_count
|
||||||
@ -84,8 +84,8 @@ def refresh_lastfm_album_stats(username, playlist_name):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
spotify_playlist = spotnet.get_playlist(uri=Uri(playlist.uri))
|
spotify_playlist = spotnet.get_playlist(uri=Uri(playlist.uri))
|
||||||
except SpotifyNetworkException as e:
|
except SpotifyNetworkException:
|
||||||
logger.error(f'error retrieving spotify playlist {username} / {playlist_name} - {e}')
|
logger.exception(f'error retrieving spotify playlist {username} / {playlist_name}')
|
||||||
return
|
return
|
||||||
album_count = counter.count_playlist(playlist=spotify_playlist, query_album=True)
|
album_count = counter.count_playlist(playlist=spotify_playlist, query_album=True)
|
||||||
|
|
||||||
@ -95,8 +95,8 @@ def refresh_lastfm_album_stats(username, playlist_name):
|
|||||||
album_percent = round((album_count * 100) / user_count, 2)
|
album_percent = round((album_count * 100) / user_count, 2)
|
||||||
else:
|
else:
|
||||||
album_percent = 0
|
album_percent = 0
|
||||||
except LastFMNetworkException as e:
|
except LastFMNetworkException:
|
||||||
logger.error(f'error while retrieving user scrobble count - {e}')
|
logger.exception(f'error while retrieving user scrobble count {username} / {playlist_name}')
|
||||||
album_percent = 0
|
album_percent = 0
|
||||||
|
|
||||||
playlist.lastfm_stat_album_count = album_count
|
playlist.lastfm_stat_album_count = album_count
|
||||||
@ -130,8 +130,8 @@ def refresh_lastfm_artist_stats(username, playlist_name):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
spotify_playlist = spotnet.get_playlist(uri=Uri(playlist.uri))
|
spotify_playlist = spotnet.get_playlist(uri=Uri(playlist.uri))
|
||||||
except SpotifyNetworkException as e:
|
except SpotifyNetworkException:
|
||||||
logger.error(f'error retrieving spotify playlist {username} / {playlist_name} - {e}')
|
logger.exception(f'error retrieving spotify playlist {username} / {playlist_name}')
|
||||||
return
|
return
|
||||||
artist_count = counter.count_playlist(playlist=spotify_playlist, query_artist=True)
|
artist_count = counter.count_playlist(playlist=spotify_playlist, query_artist=True)
|
||||||
|
|
||||||
@ -141,8 +141,8 @@ def refresh_lastfm_artist_stats(username, playlist_name):
|
|||||||
artist_percent = round((artist_count * 100) / user_count, 2)
|
artist_percent = round((artist_count * 100) / user_count, 2)
|
||||||
else:
|
else:
|
||||||
artist_percent = 0
|
artist_percent = 0
|
||||||
except LastFMNetworkException as e:
|
except LastFMNetworkException:
|
||||||
logger.error(f'error while retrieving user scrobble count - {e}')
|
logger.exception(f'error while retrieving user scrobble count {username} / {playlist_name}')
|
||||||
artist_percent = 0
|
artist_percent = 0
|
||||||
|
|
||||||
playlist.lastfm_stat_artist_count = artist_count
|
playlist.lastfm_stat_artist_count = artist_count
|
||||||
|
@ -52,8 +52,8 @@ def run_user_playlist(username, playlist_name):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
user_playlists = net.get_user_playlists()
|
user_playlists = net.get_user_playlists()
|
||||||
except SpotifyNetworkException as e:
|
except SpotifyNetworkException:
|
||||||
logger.error(f'error occured while retrieving playlists {username} / {playlist_name} - {e}')
|
logger.exception(f'error occured while retrieving playlists {username} / {playlist_name}')
|
||||||
return
|
return
|
||||||
|
|
||||||
part_generator = PartGenerator(user=user)
|
part_generator = PartGenerator(user=user)
|
||||||
@ -77,8 +77,8 @@ def run_user_playlist(username, playlist_name):
|
|||||||
playlist_tracks += _tracks
|
playlist_tracks += _tracks
|
||||||
else:
|
else:
|
||||||
logger.warning(f'no tracks returned for {uri} {username} / {playlist_name}')
|
logger.warning(f'no tracks returned for {uri} {username} / {playlist_name}')
|
||||||
except SpotifyNetworkException as e:
|
except SpotifyNetworkException:
|
||||||
logger.error(f'error occured while retrieving {uri} {username} / {playlist_name} - {e}')
|
logger.exception(f'error occured while retrieving {uri} {username} / {playlist_name}')
|
||||||
|
|
||||||
except ValueError: # is a playlist name
|
except ValueError: # is a playlist name
|
||||||
part_playlist = next((i for i in user_playlists if i.name == part_name), None)
|
part_playlist = next((i for i in user_playlists if i.name == part_name), None)
|
||||||
@ -92,8 +92,8 @@ def run_user_playlist(username, playlist_name):
|
|||||||
playlist_tracks += part_playlist_tracks
|
playlist_tracks += part_playlist_tracks
|
||||||
else:
|
else:
|
||||||
logger.warning(f'no tracks returned for {part_playlist.name} {username} / {playlist_name}')
|
logger.warning(f'no tracks returned for {part_playlist.name} {username} / {playlist_name}')
|
||||||
except SpotifyNetworkException as e:
|
except SpotifyNetworkException:
|
||||||
logger.error(f'error occured while retrieving {part_name} {username} / {playlist_name} - {e}')
|
logger.exception(f'error occured while retrieving {part_name} {username} / {playlist_name}')
|
||||||
|
|
||||||
playlist_tracks = remove_local(playlist_tracks)
|
playlist_tracks = remove_local(playlist_tracks)
|
||||||
|
|
||||||
@ -105,8 +105,8 @@ def run_user_playlist(username, playlist_name):
|
|||||||
playlist_tracks += library_tracks
|
playlist_tracks += library_tracks
|
||||||
else:
|
else:
|
||||||
logger.error(f'error getting library tracks {username} / {playlist_name}')
|
logger.error(f'error getting library tracks {username} / {playlist_name}')
|
||||||
except SpotifyNetworkException as e:
|
except SpotifyNetworkException:
|
||||||
logger.error(f'error occured while retrieving library tracks {username} / {playlist_name} - {e}')
|
logger.exception(f'error occured while retrieving library tracks {username} / {playlist_name}')
|
||||||
|
|
||||||
# PLAYLIST TYPE SPECIFIC
|
# PLAYLIST TYPE SPECIFIC
|
||||||
if playlist.type == 'recents':
|
if playlist.type == 'recents':
|
||||||
@ -159,8 +159,8 @@ def run_user_playlist(username, playlist_name):
|
|||||||
playlist_tracks += recommendations.tracks
|
playlist_tracks += recommendations.tracks
|
||||||
else:
|
else:
|
||||||
logger.error(f'error getting recommendations {username} / {playlist_name}')
|
logger.error(f'error getting recommendations {username} / {playlist_name}')
|
||||||
except SpotifyNetworkException as e:
|
except SpotifyNetworkException:
|
||||||
logger.error(f'error occured while generating recommendations {username} / {playlist_name} - {e}')
|
logger.exception(f'error occured while generating recommendations {username} / {playlist_name}')
|
||||||
|
|
||||||
# DEDUPLICATE
|
# DEDUPLICATE
|
||||||
playlist_tracks = deduplicate_by_name(playlist_tracks)
|
playlist_tracks = deduplicate_by_name(playlist_tracks)
|
||||||
@ -184,11 +184,11 @@ def run_user_playlist(username, playlist_name):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
net.change_playlist_details(Uri(playlist.uri), description=string)
|
net.change_playlist_details(Uri(playlist.uri), description=string)
|
||||||
except SpotifyNetworkException as e:
|
except SpotifyNetworkException:
|
||||||
logger.error(f'error changing description for {username} / {playlist_name} - {e}')
|
logger.exception(f'error changing description for {username} / {playlist_name}')
|
||||||
|
|
||||||
except SpotifyNetworkException as e:
|
except SpotifyNetworkException:
|
||||||
logger.error(f'error executing {username} / {playlist_name} - {e}')
|
logger.exception(f'error executing {username} / {playlist_name}')
|
||||||
|
|
||||||
playlist.last_updated = datetime.datetime.utcnow()
|
playlist.last_updated = datetime.datetime.utcnow()
|
||||||
playlist.update()
|
playlist.update()
|
||||||
|
@ -37,8 +37,8 @@ def update_tag(username, tag_id):
|
|||||||
tag_count = 0
|
tag_count = 0
|
||||||
try:
|
try:
|
||||||
user_scrobbles = net.get_user_scrobble_count()
|
user_scrobbles = net.get_user_scrobble_count()
|
||||||
except LastFMNetworkException as e:
|
except LastFMNetworkException:
|
||||||
logger.error(f'error retrieving scrobble count - {e}')
|
logger.exception(f'error retrieving scrobble count {username} / {tag_id}')
|
||||||
user_scrobbles = 0
|
user_scrobbles = 0
|
||||||
|
|
||||||
artists = []
|
artists = []
|
||||||
@ -49,8 +49,8 @@ def update_tag(username, tag_id):
|
|||||||
if net_artist is not None:
|
if net_artist is not None:
|
||||||
artist['count'] = net_artist.user_scrobbles
|
artist['count'] = net_artist.user_scrobbles
|
||||||
tag_count += net_artist.user_scrobbles
|
tag_count += net_artist.user_scrobbles
|
||||||
except LastFMNetworkException as e:
|
except LastFMNetworkException:
|
||||||
logger.error(f'error during artist retrieval - {e}')
|
logger.exception(f'error during artist retrieval {username} / {tag_id}')
|
||||||
|
|
||||||
artists.append(artist)
|
artists.append(artist)
|
||||||
|
|
||||||
@ -64,8 +64,8 @@ def update_tag(username, tag_id):
|
|||||||
|
|
||||||
if album['artist'].lower() not in [i.lower() for i in [j['name'] for j in artists]]:
|
if album['artist'].lower() not in [i.lower() for i in [j['name'] for j in artists]]:
|
||||||
tag_count += net_album.user_scrobbles
|
tag_count += net_album.user_scrobbles
|
||||||
except LastFMNetworkException as e:
|
except LastFMNetworkException:
|
||||||
logger.error(f'error during album retrieval - {e}')
|
logger.exception(f'error during album retrieval {username} / {tag_id}')
|
||||||
|
|
||||||
albums.append(album)
|
albums.append(album)
|
||||||
|
|
||||||
@ -79,8 +79,8 @@ def update_tag(username, tag_id):
|
|||||||
|
|
||||||
if track['artist'].lower() not in [i.lower() for i in [j['name'] for j in artists]]:
|
if track['artist'].lower() not in [i.lower() for i in [j['name'] for j in artists]]:
|
||||||
tag_count += net_track.user_scrobbles
|
tag_count += net_track.user_scrobbles
|
||||||
except LastFMNetworkException as e:
|
except LastFMNetworkException:
|
||||||
logger.error(f'error during track retrieval - {e}')
|
logger.exception(f'error during track retrieval {username} / {tag_id}')
|
||||||
|
|
||||||
tracks.append(track)
|
tracks.append(track)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user