[gnome-music/wip/mschraal/tageditor-13feb2020: 34/41] coresong: Add support to query musicbrainz tags
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/tageditor-13feb2020: 34/41] coresong: Add support to query musicbrainz tags
- Date: Sat, 15 Feb 2020 21:40:12 +0000 (UTC)
commit 593c624f3485ca635850ac52a71b4b044c8416f1
Author: Sumaid Syed <sumaidsyed gmail com>
Date: Sat Nov 23 14:53:17 2019 +0100
coresong: Add support to query musicbrainz tags
The following framework is used:
1. Compute the chromaprint (a fingerprint) of the song with the
chromaprint source
2. Use the chromaprint to identify the song with the acoustid source
gnomemusic/coregrilo.py | 25 +++++++++++++++++++++++++
gnomemusic/coresong.py | 14 ++++++++++++++
2 files changed, 39 insertions(+)
---
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index 7e715b51..4d94dbc2 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -248,6 +248,31 @@ class CoreGrilo(GObject.GObject):
wrapper.create_playlist(playlist_title, callback)
break
+ def get_chromaprint(self, coresong, callback):
+ """Retrieve the chromaprint for the given CoreSong
+
+ :param CoreSong coresong: The CoreSong to chromaprint
+ :param callback: Metadata retrieval callback
+ """
+ if "grl-chromaprint" not in self._mb_wrappers:
+ callback(None)
+ return
+
+ self._mb_wrappers["grl-chromaprint"].get_chromaprint(
+ coresong, callback)
+
+ def get_tags(self, coresong, callback):
+ """Retrieve Musicbrainz tags for the given CoreSong
+
+ :param CoreSong coresong: The CoreSong to retrieve tags for
+ :param callback: Metadata retrieval callback
+ """
+ if "grl-acoustid" not in self._mb_wrappers:
+ callback(None)
+ return
+
+ self._mb_wrappers["grl-acoustid"].get_tags(coresong, callback)
+
@GObject.Property(
type=Grl.Registry, default=None, flags=GObject.ParamFlags.READABLE)
def registry(self):
diff --git a/gnomemusic/coresong.py b/gnomemusic/coresong.py
index c2befcb6..f8d5d422 100644
--- a/gnomemusic/coresong.py
+++ b/gnomemusic/coresong.py
@@ -136,3 +136,17 @@ class CoreSong(GObject.GObject):
self.props.media.set_last_played(GLib.DateTime.new_now_utc())
self._grilo.writeback(self.props.media, Grl.METADATA_KEY_LAST_PLAYED)
+
+ def query_musicbrainz_tags(self, callback):
+ """Retrieves metadata keys for this CoreSong
+
+ :param callback: Metadata retrieval callback
+ """
+ def chromaprint_retrieved(media):
+ if not media:
+ callback(None)
+ return
+
+ self._grilo.get_tags(self, callback)
+
+ self._grilo.get_chromaprint(self, chromaprint_retrieved)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]