[tracker-miners/sam/libav-testing: 9/14] tracker-extract-libav: Extract albumTrackCount for Vorbis metadata




commit 13047af0dfd8934978e7d1c49e9607254f6478f1
Author: Sam Thursfield <sam thursfield codethink co uk>
Date:   Wed Aug 31 12:36:38 2022 +0200

    tracker-extract-libav: Extract albumTrackCount for Vorbis metadata

 src/tracker-extract/tracker-extract-libav.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/src/tracker-extract/tracker-extract-libav.c b/src/tracker-extract/tracker-extract-libav.c
index 8da07b098..0b324fc1c 100644
--- a/src/tracker-extract/tracker-extract-libav.c
+++ b/src/tracker-extract/tracker-extract-libav.c
@@ -240,6 +240,7 @@ extract_music_album_info(TrackerResource *metadata,
        const char *album_title = NULL;
        const char *content_created;
        int disc_number = 1;
+       int album_track_count = 0;
        AVDictionaryEntry *tag = NULL;
 
        if ((tag = find_tag (format, audio_stream, NULL, "album"))) {
@@ -267,6 +268,21 @@ extract_music_album_info(TrackerResource *metadata,
        tracker_resource_set_relation (metadata, "nmm:musicAlbumDisc", album_disc);
        tracker_resource_set_relation (metadata, "nmm:musicAlbum", tracker_resource_get_first_relation 
(album_disc, "nmm:albumDiscAlbum"));
 
+       /* There is no officially specified 'total tracks' field, these two names
+        * are taken from MusicBrainz Picard tag mapping for Vorbis comments.
+        *
+        * https://picard-docs.musicbrainz.org/en/appendices/tag_mapping.html
+        */
+       if ((tag = find_tag (format, audio_stream, NULL, "TOTALTRACKS"))) {
+               album_track_count = atoi (tag->value);
+       } else if ((tag = find_tag (format, audio_stream, NULL, "TRACKTOTAL"))) {
+               album_track_count = atoi (tag->value);
+       }
+
+       if (album_track_count > 0) {
+               tracker_resource_set_int (album, "nmm:albumTrackCount", album_track_count);
+       }
+
        if ((tag = find_tag (format, audio_stream, NULL, "MUSICBRAINZ_ALBUMID"))) {
                const char *mb_release_id = tag->value;
                g_autofree char *mb_release_uri = g_strdup_printf("https://musicbrainz.org/release/%s";, 
mb_release_id);


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