[tracker-miners/sam/album-urns-shorter: 6/6] libtracker-extract: Use only date bits in album/disc URN



commit 6af5a6cad931d81070be4e830e35a0ee3c5db4ed
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Aug 4 21:15:29 2018 +0200

    libtracker-extract: Use only date bits in album/disc URN
    
    The full date+time will be more prone to inexactitudes, as it's not likely
    to be the actual release time of the album (not to the *second*, anyway).
    If minutes/seconds are found, it's more likely creation/ripping time.
    
    In that case, the tag still could be based on wrong metadata, but songs
    won't be split in multiple albums.

 src/libtracker-extract/tracker-resource-helpers.c             | 11 +++++++++--
 .../test-extraction-data/audio/flac-musicbrainz.expected.json |  6 +++---
 .../test-extraction-data/audio/flac.expected.json             |  4 ++--
 .../test-extraction-data/audio/mp3-id3v2.4-1.expected.json    |  4 ++--
 .../test-extraction-data/audio/vorbis.expected.json           |  6 +++---
 5 files changed, 19 insertions(+), 12 deletions(-)
---
diff --git a/src/libtracker-extract/tracker-resource-helpers.c 
b/src/libtracker-extract/tracker-resource-helpers.c
index 36525a5e1..bf0d4d579 100644
--- a/src/libtracker-extract/tracker-resource-helpers.c
+++ b/src/libtracker-extract/tracker-resource-helpers.c
@@ -316,8 +316,15 @@ tracker_extract_new_music_album_disc (const char      *album_title,
        if (album_artist_name)
                g_string_append_printf (shared, ":%s", album_artist_name);
 
-       if (date)
-               g_string_append_printf (shared, ":%s", date);
+       if (date) {
+               g_string_append_c (shared, ':');
+
+               /* Only use date from ISO8601 string */
+               if (strlen (date) > 10)
+                       g_string_append_len (shared, date, 10);
+               else
+                       g_string_append (shared, date);
+       }
 
        album_uri = g_string_new ("urn:album:");
        g_string_append (album_uri, shared->str);
diff --git a/tests/functional-tests/test-extraction-data/audio/flac-musicbrainz.expected.json 
b/tests/functional-tests/test-extraction-data/audio/flac-musicbrainz.expected.json
index b74fb19ff..303e9a7b2 100644
--- a/tests/functional-tests/test-extraction-data/audio/flac-musicbrainz.expected.json
+++ b/tests/functional-tests/test-extraction-data/audio/flac-musicbrainz.expected.json
@@ -12,12 +12,12 @@
         "nfo:genre": "Rock",
         "nfo:sampleRate": "44100",
         "nie:comment": "no comment",
-        "nie:contentCreated": "2020-01-01T00:00:00+00:00",
+        "nie:contentCreated": "2020-01-01",
         "nie:copyright": "none",
         "nie:title": "track title",
         "nmm:trackNumber": "12",
         "nmm:musicAlbum": {
-            "@id": "urn:album:awesome%20album:my%20album%20artist:2020-01-01T00:00:00+00:00",
+            "@id": "urn:album:awesome%20album:my%20album%20artist:2020-01-01",
             "@type": "nmm:MusicAlbum",
             "nie:title": "awesome album",
             "nmm:albumTrackCount": "28",
@@ -43,7 +43,7 @@
             ]
         },
         "nmm:musicAlbumDisc": {
-            "@id": "urn:album-disc:awesome%20album:my%20album%20artist:2020-01-01T00:00:00+00:00:Disc1",
+            "@id": "urn:album-disc:awesome%20album:my%20album%20artist:2020-01-01",
             "@type": "nmm:MusicAlbumDisc",
             "nmm:setNumber": 1
         },
diff --git a/tests/functional-tests/test-extraction-data/audio/flac.expected.json 
b/tests/functional-tests/test-extraction-data/audio/flac.expected.json
index 92667951f..7c51fd28f 100644
--- a/tests/functional-tests/test-extraction-data/audio/flac.expected.json
+++ b/tests/functional-tests/test-extraction-data/audio/flac.expected.json
@@ -17,7 +17,7 @@
         "nie:title": "track title",
         "nmm:trackNumber": "12",
         "nmm:musicAlbum": {
-            "@id": "urn:album:awesome%20album:my%20album%20artist:2020-01-01T00:00:00+00:00",
+            "@id": "urn:album:awesome%20album:my%20album%20artist:2020-01-01",
             "@type": "nmm:MusicAlbum",
             "nie:title": "awesome album",
             "nmm:albumTrackCount": "28",
@@ -37,7 +37,7 @@
             ]
         },
         "nmm:musicAlbumDisc": {
-            "@id": "urn:album-disc:awesome%20album:my%20album%20artist:2020-01-01T00:00:00+00:00:Disc1",
+            "@id": "urn:album-disc:awesome%20album:my%20album%20artist:2020-01-01:Disc1",
             "@type": "nmm:MusicAlbumDisc",
             "nmm:setNumber": 1
         },
diff --git a/tests/functional-tests/test-extraction-data/audio/mp3-id3v2.4-1.expected.json 
b/tests/functional-tests/test-extraction-data/audio/mp3-id3v2.4-1.expected.json
index 2c55e7033..bef58c9f1 100644
--- a/tests/functional-tests/test-extraction-data/audio/mp3-id3v2.4-1.expected.json
+++ b/tests/functional-tests/test-extraction-data/audio/mp3-id3v2.4-1.expected.json
@@ -29,7 +29,7 @@
             ]
         },
         "nmm:musicAlbum": {
-            "@id": "urn:album:SinCos:2008-01-01T00:00:00Z",
+            "@id": "urn:album:SinCos:2008-01-01",
             "@type": "nmm:MusicAlbum",
             "nie:title": "SinCos",
             "tracker:hasExternalReference": [
@@ -48,7 +48,7 @@
             ]
         },
         "nmm:musicAlbumDisc": {
-            "@id": "urn:album-disc:SinCos:2008-01-01T00:00:00Z:Disc1",
+            "@id": "urn:album-disc:SinCos:2008-01-01:Disc1",
             "@type": "nmm:MusicAlbumDisc",
             "nmm:setNumber": 1
         },
diff --git a/tests/functional-tests/test-extraction-data/audio/vorbis.expected.json 
b/tests/functional-tests/test-extraction-data/audio/vorbis.expected.json
index 5c6e7f94e..77d724b3b 100644
--- a/tests/functional-tests/test-extraction-data/audio/vorbis.expected.json
+++ b/tests/functional-tests/test-extraction-data/audio/vorbis.expected.json
@@ -31,7 +31,7 @@
             "nmm:artistName": "Ab"
         },
         "nmm:musicAlbum": {
-            "@id": "urn:album:SinCos:2008-01-01T00:00:00+00:00",
+            "@id": "urn:album:SinCos:2008-01-01",
             "@type": "nmm:MusicAlbum",
             "nie:title": "SinCos",
             "tracker:hasExternalReference": [
@@ -44,9 +44,9 @@
             ]
         },
         "nmm:musicAlbumDisc": {
-            "@id": "urn:album-disc:SinCos:2008-01-01T00:00:00+00:00:Disc1",
+            "@id": "urn:album-disc:SinCos:2008-01-01:Disc1",
             "@type": "nmm:MusicAlbumDisc",
-            "nmm:albumDiscAlbum": "urn:album:SinCos:2008-01-01T00:00:00+00:00",
+            "nmm:albumDiscAlbum": "urn:album:SinCos:2008-01-01",
             "nmm:setNumber": 1
         },
         "tracker:hasExternalReference": [


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