[gnome-music/wip/jfelder/lastfm-ui-v1: 2/6] schema: Add an option to enable Last.fm scrobbler
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/lastfm-ui-v1: 2/6] schema: Add an option to enable Last.fm scrobbler
- Date: Sun, 5 Jan 2020 20:31:48 +0000 (UTC)
commit 792535e3b6f4435d2286cdcfa628b84a35cbae06
Author: Jean Felder <jfelder src gnome org>
Date: Sat Jan 4 15:18:14 2020 +0100
schema: Add an option to enable Last.fm scrobbler
data/org.gnome.Music.gschema.xml | 5 +++++
gnomemusic/player.py | 2 +-
gnomemusic/scrobbler.py | 27 ++++++++++++++++++++++++---
3 files changed, 30 insertions(+), 4 deletions(-)
---
diff --git a/data/org.gnome.Music.gschema.xml b/data/org.gnome.Music.gschema.xml
index c54c9280..71b49822 100644
--- a/data/org.gnome.Music.gschema.xml
+++ b/data/org.gnome.Music.gschema.xml
@@ -43,5 +43,10 @@
<summary>Inhibit system suspend</summary>
<description>Enables or disables inhibiting system suspend while playing music</description>
</key>
+ <key type="b" name="report-music">
+ <default>false</default>
+ <summary>Report music historty to Last.fm</summary>
+ <description>Enables or disables sending scrobbles to Last.fm</description>
+ </key>
</schema>
</schemalist>
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index f91fdefb..1a62a70f 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -404,7 +404,7 @@ class Player(GObject.GObject):
self._gst_player.bind_property(
'state', self, 'state', GObject.BindingFlags.SYNC_CREATE)
- self._lastfm = LastFmScrobbler()
+ self._lastfm = LastFmScrobbler(application)
@GObject.Property(
type=bool, default=False, flags=GObject.ParamFlags.READABLE)
diff --git a/gnomemusic/scrobbler.py b/gnomemusic/scrobbler.py
index 646a5e60..d2105dfa 100644
--- a/gnomemusic/scrobbler.py
+++ b/gnomemusic/scrobbler.py
@@ -143,13 +143,34 @@ class LastFmScrobbler(GObject.GObject):
return '<LastFmScrobbler>'
@log
- def __init__(self):
+ def __init__(self, application):
+ """Intialize LastFm Scrobbler
+
+ :param Application application: Application object
+ """
super().__init__()
+ self._settings = application.props.settings
+ self._report = self._settings.get_boolean("report-music")
+
self._scrobbled = False
self._goa_lastfm = GoaLastFM()
self._soup_session = Soup.Session.new()
+ @GObject.Property(
+ type=bool, default=False, flags=GObject.ParamFlags.READABLE)
+ def can_scrobble(self):
+ """Get can scrobble status
+
+ Music is reported to Last.fm if the "report-music" setting is
+ True and if a Goa Last.fm account is configured with music
+ support enabled.
+
+ :returns: True is music is reported to Last.fm
+ :rtype: bool
+ """
+ return not self._goa_lastfm.props.disabled and self._report is True
+
@GObject.Property(type=bool, default=False)
def scrobbled(self):
"""Bool indicating current scrobble status"""
@@ -237,7 +258,7 @@ class LastFmScrobbler(GObject.GObject):
"""
self.scrobbled = True
- if self._goa_lastfm.disabled:
+ if not self.props.can_scrobble:
return
media = coresong.props.media
@@ -253,7 +274,7 @@ class LastFmScrobbler(GObject.GObject):
"""
self.scrobbled = False
- if self._goa_lastfm.disabled:
+ if not self.props.can_scrobble:
return
media = coresong.props.media
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]