[tracker-miners/wip/carlosg/split-dataobject-informationelement: 36/38] tracker-extract: Make multi-track FLAC extraction work with the split
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners/wip/carlosg/split-dataobject-informationelement: 36/38] tracker-extract: Make multi-track FLAC extraction work with the split
- Date: Thu, 30 Apr 2020 11:18:37 +0000 (UTC)
commit 22e3b44cc0b063d10c0a55d5ef26ace8745493ff
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Apr 23 17:45:05 2020 +0200
tracker-extract: Make multi-track FLAC extraction work with the split
The extract module will get an URN corresponding to the InformationElement
that tracker-miner-fs did set up for the content of this file. Make it
sure it is reused for the first track, instead of left lingering.
src/tracker-extract/tracker-extract-gstreamer.c | 36 +++++-----
tests/functional-tests/extractor-flac-cuesheet.py | 82 +++++++++++------------
2 files changed, 59 insertions(+), 59 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index ca61e5634..2f193c041 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -631,21 +631,18 @@ extractor_apply_video_metadata (MetadataExtractor *extractor,
set_keywords_from_gst_tag (video, tag_list);
}
-static TrackerResource *
-extract_track (MetadataExtractor *extractor,
+static void
+extract_track (TrackerResource *track,
+ MetadataExtractor *extractor,
TrackerTocEntry *toc_entry,
const gchar *file_url,
TrackerResource *album_disc)
{
- TrackerResource *track;
TrackerResource *track_performer = NULL, *track_composer = NULL;
- gchar *track_uri;
-
- track_uri = tracker_sparql_get_uuid_urn ();
- track = tracker_resource_new (track_uri);
tracker_resource_add_uri (track, "rdf:type", "nmm:MusicPiece");
tracker_resource_add_uri (track, "rdf:type", "nfo:Audio");
+ tracker_resource_add_string (track, "nie:generator", TRACKER_PREFIX_TRACKER "extractor-data-source");
extractor_apply_general_metadata (extractor,
toc_entry->tag_list,
@@ -674,10 +671,6 @@ extract_track (MetadataExtractor *extractor,
}
tracker_resource_set_double (track, "nfo:audioOffset", toc_entry->start);
-
- g_free (track_uri);
-
- return track;
}
#define CHUNK_N_BYTES (2 << 15)
@@ -850,16 +843,27 @@ extract_metadata (MetadataExtractor *extractor,
* concrete nfo:FileDataObject using nie:isStoredAs.
*/
if (extractor->toc && g_list_length (extractor->toc->entry_list) > 1) {
+ TrackerResource *file_resource;
+
+ file_resource = tracker_resource_new (file_url);
+
for (node = extractor->toc->entry_list; node; node = node->next) {
TrackerResource *track;
- track = extract_track (extractor, node->data, file_url, album_disc);
- tracker_resource_set_relation (track, "nie:isStoredAs", resource);
- tracker_resource_set_relation (track, "nie:isLogicalPartOf",
resource);
- tracker_resource_add_take_relation (resource, "nie:hasLogicalPart",
track);
+ /* Reuse the "root" InformationElement resource for the first track,
+ * so there's no spare ones.
+ */
+ if (node == extractor->toc->entry_list)
+ track = resource;
+ else
+ track = tracker_resource_new (NULL);
+
+ extract_track (track, extractor, node->data, file_url, album_disc);
+ tracker_resource_set_relation (track, "nie:isStoredAs",
file_resource);
+ tracker_resource_add_take_relation (file_resource,
"nie:interpretedAs", track);
}
- tracker_resource_set_string (resource, "nie:url", file_url);
+ g_object_unref (file_resource);
} else {
extractor_apply_audio_metadata (extractor,
extractor->tagcache,
diff --git a/tests/functional-tests/extractor-flac-cuesheet.py
b/tests/functional-tests/extractor-flac-cuesheet.py
index 2497ae0de..37a2a6902 100755
--- a/tests/functional-tests/extractor-flac-cuesheet.py
+++ b/tests/functional-tests/extractor-flac-cuesheet.py
@@ -34,51 +34,47 @@ class FlacCuesheetTest(fixtures.TrackerExtractTestCase):
def spec(self, audio_path):
audio_uri = audio_path.as_uri()
return {
- '@type': ['nfo:Audio'],
- 'nie:url': audio_uri,
+ '@type': ['nfo:Audio', 'nmm:MusicPiece', 'nfo:Audio'],
+ 'nfo:audioOffset': 0.0,
'nfo:duration': 360,
+ 'nie:title': 'Only Shallow',
+ 'nmm:trackNumber': 1,
'nfo:sampleRate': 44100,
- 'nie:hasLogicalPart': [
- {
- '@type': ['nmm:MusicPiece', 'nfo:Audio'],
- 'nfo:audioOffset': 0.0,
- 'nfo:duration': 257,
- 'nie:isLogicalPartOf': audio_uri,
- 'nie:isStoredAs': audio_uri,
- 'nie:title': 'Only Shallow',
- 'nmm:trackNumber': 1,
- 'nmm:musicAlbum': {
- '@id': 'urn:album:Loveless:My%20Bloody%20Valentine',
- '@type': 'nmm:MusicAlbum',
- 'nmm:albumTrackCount': 2,
- 'nmm:albumArtist': ['urn:artist:My%20Bloody%20Valentine'],
- 'nie:title': 'Loveless',
- },
- 'nmm:musicAlbumDisc': {
- '@id': 'urn:album-disc:Loveless:My%20Bloody%20Valentine:Disc1',
- '@type': 'nmm:MusicAlbumDisc',
- 'nmm:setNumber': 1,
- 'nmm:albumDiscAlbum': 'urn:album:Loveless:My%20Bloody%20Valentine',
- },
- 'nmm:performer': {
- '@id': 'urn:artist:My%20Bloody%20Valentine',
- '@type': 'nmm:Artist',
- 'nmm:artistName': 'My Bloody Valentine',
- },
- },
- {
- '@type': ['nmm:MusicPiece', 'nfo:Audio'],
- 'nfo:audioOffset': 257.6933333333333,
- 'nfo:duration': 102,
- 'nie:isLogicalPartOf': audio_uri,
- 'nie:isStoredAs': audio_uri,
- 'nmm:musicAlbum': 'urn:album:Loveless:My%20Bloody%20Valentine',
- 'nmm:musicAlbumDisc': 'urn:album-disc:Loveless:My%20Bloody%20Valentine:Disc1',
- 'nmm:performer': 'urn:artist:My%20Bloody%20Valentine',
- 'nie:title': 'Loomer',
- 'nmm:trackNumber': 2,
- }
- ],
+ 'nmm:musicAlbum': 'urn:album:Loveless:My%20Bloody%20Valentine',
+ 'nmm:musicAlbumDisc': 'urn:album-disc:Loveless:My%20Bloody%20Valentine:Disc1',
+ 'nie:isStoredAs': {
+ '@id': audio_uri,
+ 'nie:interpretedAs': [
+ audio_uri,
+ {
+ '@type': ['nmm:MusicPiece', 'nfo:Audio'],
+ 'nfo:audioOffset': 257.6933333333333,
+ 'nfo:duration': 102,
+ 'nmm:trackNumber': 2,
+ 'nmm:performer': 'urn:artist:My%20Bloody%20Valentine',
+ 'nie:isStoredAs': audio_uri,
+ 'nie:title': 'Loomer',
+ 'nmm:musicAlbum': {
+ '@id': 'urn:album:Loveless:My%20Bloody%20Valentine',
+ 'nie:title': 'Loveless',
+ 'nmm:albumTrackCount': 2,
+ '@type': 'nmm:MusicAlbum',
+ 'nmm:albumArtist': ['urn:artist:My%20Bloody%20Valentine']
+ },
+ 'nmm:musicAlbumDisc': {
+ '@id': 'urn:album-disc:Loveless:My%20Bloody%20Valentine:Disc1',
+ 'nmm:setNumber': 1,
+ 'nmm:albumDiscAlbum': 'urn:album:Loveless:My%20Bloody%20Valentine',
+ '@type': 'nmm:MusicAlbumDisc'
+ }
+ }
+ ]
+ },
+ 'nmm:performer': {
+ '@id': 'urn:artist:My%20Bloody%20Valentine',
+ 'nmm:artistName': 'My Bloody Valentine',
+ '@type': 'nmm:Artist'
+ }
}
def test_external_cue_sheet(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]