[tracker-miners: 2/4] tracker-extract-vorbis.c: Extract MusicBrainz IDs for ogg files



commit f4872ef4aae671f436a782c6e9c096b1a9825a40
Author: Sumaid Syed <sumaidsyed gmail com>
Date:   Mon Jun 3 22:23:48 2019 +0530

    tracker-extract-vorbis.c: Extract MusicBrainz IDs for ogg files
    
    Tracker needs to store MusicBrainz IDs to allow retrieval of tags and cover-art in GNOME Music.
    If a file already has MusicBrainz IDs, then extractor should detect and index them.
    Extraction of MusicBrainz IDs is done based on tags used by Picard.
    Tags Mapping : https://picard.musicbrainz.org/docs/mappings/
    
    Closes https://gitlab.gnome.org/GNOME/tracker-miners/issues/70

 src/tracker-extract/tracker-extract-vorbis.c | 49 ++++++++++++++++------------
 1 file changed, 28 insertions(+), 21 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-vorbis.c b/src/tracker-extract/tracker-extract-vorbis.c
index 28c640759..1a86aa44d 100644
--- a/src/tracker-extract/tracker-extract-vorbis.c
+++ b/src/tracker-extract/tracker-extract-vorbis.c
@@ -57,10 +57,11 @@ typedef struct {
        gchar *codec_version;
        gchar *sample_rate;
        gchar *channels;
-       gchar *mb_album_id;
-       gchar *mb_artist_id;
-       gchar *mb_album_artist_id;
+       gchar *mb_release_id;
+       gchar *mb_release_group_id;
        gchar *mb_track_id;
+       gchar *mb_artist_id;
+       gchar *mb_recording_id;
        gchar *lyrics;
        gchar *copyright;
        gchar *license;
@@ -147,10 +148,11 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
                vd.codec_version = ogg_get_comment (comment, "CodecVersion");
                vd.sample_rate = ogg_get_comment (comment, "SampleRate");
                vd.channels = ogg_get_comment (comment, "Channels");
-               vd.mb_album_id = ogg_get_comment (comment, "MBAlbumID");
-               vd.mb_artist_id = ogg_get_comment (comment, "MBArtistID");
-               vd.mb_album_artist_id = ogg_get_comment (comment, "MBAlbumArtistID");
-               vd.mb_track_id = ogg_get_comment (comment, "MBTrackID");
+               vd.mb_release_id = ogg_get_comment (comment, "MUSICBRAINZ_ALBUMID");
+               vd.mb_release_group_id = ogg_get_comment (comment, "MUSICBRAINZ_RELEASEGROUPID");
+               vd.mb_artist_id = ogg_get_comment (comment, "MUSICBRAINZ_ARTISTID");
+               vd.mb_track_id = ogg_get_comment (comment, "MUSICBRAINZ_RELEASETRACKID");
+               vd.mb_recording_id = ogg_get_comment (comment, "MUSICBRAINZ_TRACKID");
                vd.lyrics = ogg_get_comment (comment, "Lyrics");
                vd.copyright = ogg_get_comment (comment, "Copyright");
                vd.license = ogg_get_comment (comment, "License");
@@ -166,6 +168,11 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
        if (md.creator_name) {
                md.creator = tracker_extract_new_artist (md.creator_name);
 
+               if (vd.mb_artist_id) {
+                       tracker_resource_set_string (md.creator, "nmm:mbArtistID", vd.mb_artist_id);
+                       g_free (vd.mb_artist_id);
+               }
+
                tracker_resource_set_relation (metadata, "nmm:performer", md.creator);
        }
 
@@ -200,6 +207,16 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
                        tracker_resource_set_double (album, "nmm:albumPeakGain", atof (vd.album_peak_gain));
                }
 
+               if (vd.mb_release_id) {
+                       tracker_resource_set_string (album, "nmm:mbReleaseID", vd.mb_release_id);
+                       g_free (vd.mb_release_id);
+               }
+
+               if (vd.mb_release_group_id) {
+                       tracker_resource_set_string (album, "nmm:mbReleaseGroupID", vd.mb_release_group_id);
+                       g_free (vd.mb_release_group_id);
+               }
+
                tracker_resource_set_relation (metadata, "nmm:musicAlbum", album);
                tracker_resource_set_relation (metadata, "nmm:musicAlbumDisc", album_disc);
 
@@ -266,23 +283,13 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
                g_free (vd.channels);
        }
 
-       if (vd.mb_album_id) {
-               /* TODO */
-               g_free (vd.mb_album_id);
-       }
-
-       if (vd.mb_artist_id) {
-               /* TODO */
-               g_free (vd.mb_artist_id);
-       }
-
-       if (vd.mb_album_artist_id) {
-               /* TODO */
-               g_free (vd.mb_album_artist_id);
+       if (vd.mb_recording_id) {
+               tracker_resource_set_string (metadata, "nmm:mbRecordingID", vd.mb_recording_id);
+               g_free (vd.mb_recording_id);
        }
 
        if (vd.mb_track_id) {
-               /* TODO */
+               tracker_resource_set_string (metadata, "nmm:mbTrackID", vd.mb_track_id);
                g_free (vd.mb_track_id);
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]