[gnome-music/wip/mschraal/tageditor-13feb2020: 3/12] 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: 3/12] coresong: Add support to query musicbrainz tags
- Date: Thu, 13 Feb 2020 23:00:00 +0000 (UTC)
commit 5aab3fb2d675ab4a23605d8d3001cd6709440057
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 fd0e6a5b..83b58d46 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -253,6 +253,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]