[gnome-music/wip/jfelder/3-34-scrobbler-session-key-fix] scrobbler: Do not crash if the session key is unavailable
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/3-34-scrobbler-session-key-fix] scrobbler: Do not crash if the session key is unavailable
- Date: Sat, 2 Nov 2019 11:39:49 +0000 (UTC)
commit 6f9ebf9e42f942d0119cee41a4bd7f56e3834a79
Author: Jean Felder <jfelder src gnome org>
Date: Wed Oct 30 22:13:53 2019 +0100
scrobbler: Do not crash if the session key is unavailable
Related: #328
(cherry picked from commit ea417152d542468c75ffcb183e279c44248a24e4)
gnomemusic/scrobbler.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/scrobbler.py b/gnomemusic/scrobbler.py
index 6cb4e986..cefdc052 100644
--- a/gnomemusic/scrobbler.py
+++ b/gnomemusic/scrobbler.py
@@ -128,7 +128,12 @@ class GoaLastFM(GObject.GObject):
@GObject.Property
def session_key(self):
"""Retrieve the Last.fm session key"""
- return self._authentication.call_get_access_token_sync(None)[0]
+ try:
+ return self._authentication.call_get_access_token_sync(None)[0]
+ except GLib.Error as e:
+ logger.warning(
+ "Error: Unable to retrieve last.fm session key", e.message)
+ return None
class LastFmScrobbler(GObject.GObject):
@@ -160,6 +165,10 @@ class LastFmScrobbler(GObject.GObject):
"""Internal method called by self.scrobble"""
api_key = self._goa_lastfm.client_id
sk = self._goa_lastfm.session_key
+ if sk is None:
+ logger.warning(
+ "Error: Unable to perform last.fm api call", request_type_key)
+ return
secret = self._goa_lastfm.secret
artist = utils.get_artist_name(media)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]