[tracker/wip/sam/resource: 12/13] tracker-extract: Convert MP3 extractor to TrackerResource
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/sam/resource: 12/13] tracker-extract: Convert MP3 extractor to TrackerResource
- Date: Thu, 7 Apr 2016 17:36:05 +0000 (UTC)
commit e5234bfd61246d46cd3203c0105859f2a5741e8f
Author: Sam Thursfield <sam afuera me uk>
Date: Thu Apr 7 18:34:00 2016 +0100
tracker-extract: Convert MP3 extractor to TrackerResource
src/tracker-extract/tracker-extract-mp3.c | 378 ++++++++++-------------------
1 files changed, 129 insertions(+), 249 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-mp3.c b/src/tracker-extract/tracker-extract-mp3.c
index 04c4c09..96b3b9c 100644
--- a/src/tracker-extract/tracker-extract-mp3.c
+++ b/src/tracker-extract/tracker-extract-mp3.c
@@ -151,12 +151,12 @@ typedef struct {
size_t id3v2_size;
const gchar *title;
- const gchar *performer;
- gchar *performer_uri;
- const gchar *lyricist;
- gchar *lyricist_uri;
- const gchar *album;
- gchar *album_uri;
+ const gchar *performer_name;
+ TrackerResource *performer;
+ const gchar *lyricist_name;
+ TrackerResource *lyricist;
+ const gchar *album_name;
+ TrackerResource *album;
const gchar *genre;
const gchar *text;
const gchar *recording_time;
@@ -164,8 +164,8 @@ typedef struct {
const gchar *copyright;
const gchar *publisher;
const gchar *comment;
- const gchar *composer;
- gchar *composer_uri;
+ const gchar *composer_name;
+ TrackerResource *composer;
gint track_number;
gint track_count;
gint set_number;
@@ -854,7 +854,7 @@ mp3_parse_header (const gchar *data,
size_t size,
size_t seek_pos,
const gchar *uri,
- TrackerSparqlBuilder *metadata,
+ TrackerResource *resource,
MP3Data *filedata)
{
const gchar *dlna_profile, *dlna_mimetype;
@@ -971,13 +971,11 @@ mp3_parse_header (const gchar *data,
return FALSE;
}
- tracker_sparql_builder_predicate (metadata, "nfo:codec");
- tracker_sparql_builder_object_string (metadata, "MPEG");
+ tracker_resource_set_string (resource, "nfo:codec", "MPEG");
n_channels = ((header & ch_mask) == ch_mask) ? 1 : 2;
- tracker_sparql_builder_predicate (metadata, "nfo:channels");
- tracker_sparql_builder_object_int64 (metadata, n_channels);
+ tracker_resource_set_int (resource, "nfo:channels", n_channels);
avg_bps /= frames;
@@ -990,21 +988,15 @@ mp3_parse_header (const gchar *data,
length = spfp8 * 8 * frames / sample_rate;
}
- tracker_sparql_builder_predicate (metadata, "nfo:duration");
- tracker_sparql_builder_object_int64 (metadata, length);
-
- tracker_sparql_builder_predicate (metadata, "nfo:sampleRate");
- tracker_sparql_builder_object_int64 (metadata, sample_rate);
- tracker_sparql_builder_predicate (metadata, "nfo:averageBitrate");
- tracker_sparql_builder_object_int64 (metadata, avg_bps*1000);
+ tracker_resource_set_int64 (resource, "nfo:duration", length);
+ tracker_resource_set_int64 (resource, "nfo:sampleRate", sample_rate);
+ tracker_resource_set_int64 (resource, "nfo:averageBitrate", avg_bps*1000);
if (guess_dlna_profile (bitrate, sample_rate,
mpeg_ver, layer_ver, n_channels,
&dlna_profile, &dlna_mimetype)) {
- tracker_sparql_builder_predicate (metadata, "nmm:dlnaProfile");
- tracker_sparql_builder_object_string (metadata, dlna_profile);
- tracker_sparql_builder_predicate (metadata, "nmm:dlnaMime");
- tracker_sparql_builder_object_string (metadata, dlna_mimetype);
+ tracker_resource_set_string (resource, "nmm:dlnaProfile", dlna_profile);
+ tracker_resource_set_string (resource, "nmm:dlnaMime", dlna_mimetype);
}
return TRUE;
@@ -1015,7 +1007,7 @@ mp3_parse (const gchar *data,
size_t size,
size_t offset,
const gchar *uri,
- TrackerSparqlBuilder *metadata,
+ TrackerResource *resource,
MP3Data *filedata)
{
guint header;
@@ -1032,7 +1024,7 @@ mp3_parse (const gchar *data,
if ((header & sync_mask) == sync_mask) {
/* Found header sync */
- if (mp3_parse_header (data, size, pos, uri, metadata, filedata)) {
+ if (mp3_parse_header (data, size, pos, uri, resource, filedata)) {
return TRUE;
}
}
@@ -1244,7 +1236,7 @@ get_id3v24_tags (id3v24frame frame,
size_t csize,
id3tag *info,
const gchar *uri,
- TrackerSparqlBuilder *metadata,
+ TrackerResource *resource,
MP3Data *filedata)
{
id3v2tag *tag = &filedata->id3v24;
@@ -1434,7 +1426,7 @@ get_id3v23_tags (id3v24frame frame,
size_t csize,
id3tag *info,
const gchar *uri,
- TrackerSparqlBuilder *metadata,
+ TrackerResource *resource,
MP3Data *filedata)
{
id3v2tag *tag = &filedata->id3v23;
@@ -1619,7 +1611,7 @@ get_id3v20_tags (id3v2frame frame,
size_t csize,
id3tag *info,
const gchar *uri,
- TrackerSparqlBuilder *metadata,
+ TrackerResource *resource,
MP3Data *filedata)
{
id3v2tag *tag = &filedata->id3v22;
@@ -1749,7 +1741,7 @@ parse_id3v24 (const gchar *data,
size_t size,
id3tag *info,
const gchar *uri,
- TrackerSparqlBuilder *metadata,
+ TrackerResource *resource,
MP3Data *filedata,
size_t *offset_delta)
{
@@ -1936,10 +1928,10 @@ parse_id3v24 (const gchar *data,
gchar *body;
un_unsync (&data[pos], csize, (unsigned char **) &body, &unsync_size);
- get_id3v24_tags (frame, body, unsync_size, info, uri, metadata, filedata);
+ get_id3v24_tags (frame, body, unsync_size, info, uri, resource, filedata);
g_free (body);
} else {
- get_id3v24_tags (frame, &data[pos], csize, info, uri, metadata, filedata);
+ get_id3v24_tags (frame, &data[pos], csize, info, uri, resource, filedata);
}
pos += csize;
@@ -1953,7 +1945,7 @@ parse_id3v23 (const gchar *data,
size_t size,
id3tag *info,
const gchar *uri,
- TrackerSparqlBuilder *metadata,
+ TrackerResource *resource,
MP3Data *filedata,
size_t *offset_delta)
{
@@ -2133,10 +2125,10 @@ parse_id3v23 (const gchar *data,
gchar *body;
un_unsync (&data[pos], csize, (unsigned char **) &body, &unsync_size);
- get_id3v23_tags (frame, body, unsync_size, info, uri, metadata, filedata);
+ get_id3v23_tags (frame, body, unsync_size, info, uri, resource, filedata);
g_free (body);
} else {
- get_id3v23_tags (frame, &data[pos], csize, info, uri, metadata, filedata);
+ get_id3v23_tags (frame, &data[pos], csize, info, uri, resource, filedata);
}
pos += csize;
@@ -2150,7 +2142,7 @@ parse_id3v20 (const gchar *data,
size_t size,
id3tag *info,
const gchar *uri,
- TrackerSparqlBuilder *metadata,
+ TrackerResource *resource,
MP3Data *filedata,
size_t *offset_delta)
{
@@ -2234,10 +2226,10 @@ parse_id3v20 (const gchar *data,
gchar *body;
un_unsync (&data[pos], csize, (unsigned char **) &body, &unsync_size);
- get_id3v20_tags (frame, body, unsync_size, info, uri, metadata, filedata);
+ get_id3v20_tags (frame, body, unsync_size, info, uri, resource, filedata);
g_free (body);
} else {
- get_id3v20_tags (frame, &data[pos], csize, info, uri, metadata, filedata);
+ get_id3v20_tags (frame, &data[pos], csize, info, uri, resource, filedata);
}
pos += csize;
@@ -2251,7 +2243,7 @@ parse_id3v2 (const gchar *data,
size_t size,
id3tag *info,
const gchar *uri,
- TrackerSparqlBuilder *metadata,
+ TrackerResource *resource,
MP3Data *filedata)
{
gboolean done = FALSE;
@@ -2259,9 +2251,9 @@ parse_id3v2 (const gchar *data,
do {
size_t offset_delta = 0;
- parse_id3v24 (data + offset, size - offset, info, uri, metadata, filedata, &offset_delta);
- parse_id3v23 (data + offset, size - offset, info, uri, metadata, filedata, &offset_delta);
- parse_id3v20 (data + offset, size - offset, info, uri, metadata, filedata, &offset_delta);
+ parse_id3v24 (data + offset, size - offset, info, uri, resource, filedata, &offset_delta);
+ parse_id3v23 (data + offset, size - offset, info, uri, resource, filedata, &offset_delta);
+ parse_id3v20 (data + offset, size - offset, info, uri, resource, filedata, &offset_delta);
if (offset_delta == 0) {
done = TRUE;
@@ -2286,14 +2278,9 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
goffset buffer_size;
goffset audio_offset;
MP3Data md = { 0 };
- TrackerSparqlBuilder *metadata, *preupdate;
GFile *file;
- const gchar *graph;
gboolean parsed;
-
- graph = tracker_extract_info_get_graph (info);
- metadata = tracker_extract_info_get_metadata_builder (info);
- preupdate = tracker_extract_info_get_preupdate_builder (info);
+ TrackerResource *main_resource;
file = tracker_extract_info_get_file (info);
filename = g_file_get_path (file);
@@ -2343,36 +2330,38 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
g_free (id3v1_buffer);
+ main_resource = tracker_resource_new (NULL);
+
/* Get other embedded tags */
uri = g_file_get_uri (file);
- audio_offset = parse_id3v2 (buffer, buffer_size, &md.id3v1, uri, metadata, &md);
+ audio_offset = parse_id3v2 (buffer, buffer_size, &md.id3v1, uri, main_resource, &md);
md.title = tracker_coalesce_strip (4, md.id3v24.title2,
md.id3v23.title2,
md.id3v22.title2,
md.id3v1.title);
- md.lyricist = tracker_coalesce_strip (4, md.id3v24.text,
- md.id3v23.toly,
- md.id3v23.text,
- md.id3v22.text);
+ md.lyricist_name = tracker_coalesce_strip (4, md.id3v24.text,
+ md.id3v23.toly,
+ md.id3v23.text,
+ md.id3v22.text);
- md.composer = tracker_coalesce_strip (3, md.id3v24.composer,
- md.id3v23.composer,
- md.id3v22.composer);
+ md.composer_name = tracker_coalesce_strip (3, md.id3v24.composer,
+ md.id3v23.composer,
+ md.id3v22.composer);
- md.performer = tracker_coalesce_strip (7, md.id3v24.performer1,
- md.id3v24.performer2,
- md.id3v23.performer1,
- md.id3v23.performer2,
- md.id3v22.performer1,
- md.id3v22.performer2,
- md.id3v1.artist);
+ md.performer_name = tracker_coalesce_strip (7, md.id3v24.performer1,
+ md.id3v24.performer2,
+ md.id3v23.performer1,
+ md.id3v23.performer2,
+ md.id3v22.performer1,
+ md.id3v22.performer2,
+ md.id3v1.artist);
- md.album = tracker_coalesce_strip (4, md.id3v24.album,
- md.id3v23.album,
- md.id3v22.album,
- md.id3v1.album);
+ md.album_name = tracker_coalesce_strip (4, md.id3v24.album,
+ md.id3v23.album,
+ md.id3v22.album,
+ md.id3v1.album);
md.genre = tracker_coalesce_strip (7, md.id3v24.content_type,
md.id3v24.title1,
@@ -2444,251 +2433,137 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
md.set_count = md.id3v22.set_count;
}
- if (md.performer) {
- md.performer_uri = tracker_sparql_escape_uri_printf ("urn:artist:%s", md.performer);
+ if (md.performer_name) {
+ char *performer_uri = tracker_sparql_escape_uri_printf ("urn:artist:%s", md.performer_name);
+ md.performer = tracker_resource_new (uri);
- tracker_sparql_builder_insert_open (preupdate, NULL);
- if (graph) {
- tracker_sparql_builder_graph_open (preupdate, graph);
- }
+ tracker_resource_set_uri (md.performer, "rdf:type", "nmm:Artist");
+ tracker_resource_set_string (md.performer, "nmm:artistName", md.performer_name);
- tracker_sparql_builder_subject_iri (preupdate, md.performer_uri);
- tracker_sparql_builder_predicate (preupdate, "a");
- tracker_sparql_builder_object (preupdate, "nmm:Artist");
- tracker_sparql_builder_predicate (preupdate, "nmm:artistName");
- tracker_sparql_builder_object_unvalidated (preupdate, md.performer);
-
- if (graph) {
- tracker_sparql_builder_graph_close (preupdate);
- }
- tracker_sparql_builder_insert_close (preupdate);
+ g_free (performer_uri);
}
- if (md.composer) {
- md.composer_uri = tracker_sparql_escape_uri_printf ("urn:artist:%s", md.composer);
-
- tracker_sparql_builder_insert_open (preupdate, NULL);
- if (graph) {
- tracker_sparql_builder_graph_open (preupdate, graph);
- }
+ if (md.composer_name) {
+ char *composer_uri = tracker_sparql_escape_uri_printf ("urn:artist:%s", md.composer_name);
+ md.composer = tracker_resource_new (uri);
- tracker_sparql_builder_subject_iri (preupdate, md.composer_uri);
- tracker_sparql_builder_predicate (preupdate, "a");
- tracker_sparql_builder_object (preupdate, "nmm:Artist");
- tracker_sparql_builder_predicate (preupdate, "nmm:artistName");
- tracker_sparql_builder_object_unvalidated (preupdate, md.composer);
+ tracker_resource_set_uri (md.composer, "rdf:type", "nmm:Artist");
+ tracker_resource_set_string (md.composer, "nmm:artistName", md.composer_name);
- if (graph) {
- tracker_sparql_builder_graph_close (preupdate);
- }
- tracker_sparql_builder_insert_close (preupdate);
+ g_free (composer_uri);
}
- if (md.lyricist) {
- md.lyricist_uri = tracker_sparql_escape_uri_printf ("urn:artist:%s", md.lyricist);
-
- tracker_sparql_builder_insert_open (preupdate, NULL);
- if (graph) {
- tracker_sparql_builder_graph_open (preupdate, graph);
- }
+ if (md.lyricist_name) {
+ char *lyricist_uri = tracker_sparql_escape_uri_printf ("urn:artist:%s", md.lyricist_name);
+ md.lyricist = tracker_resource_new (uri);
- tracker_sparql_builder_subject_iri (preupdate, md.lyricist_uri);
- tracker_sparql_builder_predicate (preupdate, "a");
- tracker_sparql_builder_object (preupdate, "nmm:Artist");
- tracker_sparql_builder_predicate (preupdate, "nmm:artistName");
- tracker_sparql_builder_object_unvalidated (preupdate, md.lyricist);
+ tracker_resource_set_uri (md.lyricist, "rdf:type", "nmm:Artist");
+ tracker_resource_set_string (md.lyricist, "nmm:artistName", md.lyricist_name);
- if (graph) {
- tracker_sparql_builder_graph_close (preupdate);
- }
- tracker_sparql_builder_insert_close (preupdate);
+ g_free (lyricist_uri);
}
- if (md.album) {
- md.album_uri = tracker_sparql_escape_uri_printf ("urn:album:%s", md.album);
-
- tracker_sparql_builder_insert_open (preupdate, NULL);
- if (graph) {
- tracker_sparql_builder_graph_open (preupdate, graph);
- }
+ if (md.album_name) {
+ char *album_uri = tracker_sparql_escape_uri_printf ("urn:album:%s", md.album_name);
+ md.album = tracker_resource_new (album_uri);
- tracker_sparql_builder_subject_iri (preupdate, md.album_uri);
- tracker_sparql_builder_predicate (preupdate, "a");
- tracker_sparql_builder_object (preupdate, "nmm:MusicAlbum");
+ tracker_resource_set_uri (md.album, "rdf:type", "nmm:MusicAlbum");
/* FIXME: nmm:albumTitle is now deprecated
* tracker_sparql_builder_predicate (preupdate, "nie:title");
*/
- tracker_sparql_builder_predicate (preupdate, "nmm:albumTitle");
- tracker_sparql_builder_object_unvalidated (preupdate, md.album);
+ tracker_resource_set_string (md.album, "nmm:albumTitle", md.album_name);
- if (md.performer_uri) {
- tracker_sparql_builder_predicate (preupdate, "nmm:albumArtist");
- tracker_sparql_builder_object_iri (preupdate, md.performer_uri);
+ if (md.performer) {
+ tracker_resource_set_relation (md.album, "nmm:albumArtist", md.performer);
}
- if (graph) {
- tracker_sparql_builder_graph_close (preupdate);
- }
- tracker_sparql_builder_insert_close (preupdate);
-
if (md.track_count > 0) {
- tracker_sparql_builder_delete_open (preupdate, NULL);
- tracker_sparql_builder_subject_iri (preupdate, md.album_uri);
- tracker_sparql_builder_predicate (preupdate, "nmm:albumTrackCount");
- tracker_sparql_builder_object_variable (preupdate, "unknown");
- tracker_sparql_builder_delete_close (preupdate);
- tracker_sparql_builder_where_open (preupdate);
- tracker_sparql_builder_subject_iri (preupdate, md.album_uri);
- tracker_sparql_builder_predicate (preupdate, "nmm:albumTrackCount");
- tracker_sparql_builder_object_variable (preupdate, "unknown");
- tracker_sparql_builder_where_close (preupdate);
-
- tracker_sparql_builder_insert_open (preupdate, NULL);
- if (graph) {
- tracker_sparql_builder_graph_open (preupdate, graph);
- }
-
- tracker_sparql_builder_subject_iri (preupdate, md.album_uri);
- tracker_sparql_builder_predicate (preupdate, "nmm:albumTrackCount");
- tracker_sparql_builder_object_int64 (preupdate, md.track_count);
-
- if (graph) {
- tracker_sparql_builder_graph_close (preupdate);
- }
- tracker_sparql_builder_insert_close (preupdate);
+ tracker_resource_set_int (md.album, "nmm:albumTrackCount", md.track_count);
}
}
- tracker_sparql_builder_predicate (metadata, "a");
- tracker_sparql_builder_object (metadata, "nmm:MusicPiece");
- tracker_sparql_builder_object (metadata, "nfo:Audio");
+ tracker_resource_set_uri (main_resource, "rdf:type", "nmm:MusicPiece");
+ tracker_resource_add_uri (main_resource, "rdf:type", "nfo:Audio");
- tracker_guarantee_title_from_file (metadata,
- "nie:title",
- md.title,
- uri,
- NULL);
+ tracker_guarantee_resource_title_from_file (main_resource,
+ "nie:title",
+ md.title,
+ uri,
+ NULL);
- if (md.lyricist_uri) {
- tracker_sparql_builder_predicate (metadata, "nmm:lyricist");
- tracker_sparql_builder_object_iri (metadata, md.lyricist_uri);
- g_free (md.lyricist_uri);
+ if (md.lyricist) {
+ tracker_resource_set_relation (main_resource, "nmm:lyricist", md.lyricist);
+ g_object_unref (md.lyricist);
}
- if (md.performer_uri) {
- tracker_sparql_builder_predicate (metadata, "nmm:performer");
- tracker_sparql_builder_object_iri (metadata, md.performer_uri);
- g_free (md.performer_uri);
+ if (md.performer) {
+ tracker_resource_set_relation (main_resource, "nmm:performer", md.performer);
+ g_object_unref (md.performer);
}
- if (md.composer_uri) {
- tracker_sparql_builder_predicate (metadata, "nmm:composer");
- tracker_sparql_builder_object_iri (metadata, md.composer_uri);
- g_free (md.composer_uri);
+ if (md.composer) {
+ tracker_resource_set_relation (main_resource, "nmm:composer", md.composer);
+ g_object_unref (md.composer);
}
- if (md.album_uri) {
- tracker_sparql_builder_predicate (metadata, "nmm:musicAlbum");
- tracker_sparql_builder_object_iri (metadata, md.album_uri);
+ if (md.album) {
+ tracker_resource_set_relation (main_resource, "nmm:musicAlbum", md.album);
}
if (md.recording_time) {
- tracker_sparql_builder_predicate (metadata, "nie:contentCreated");
- tracker_sparql_builder_object_unvalidated (metadata, md.recording_time);
+ tracker_resource_set_string (main_resource, "nie:contentCreated", md.recording_time);
}
if (md.genre) {
- tracker_sparql_builder_predicate (metadata, "nfo:genre");
- tracker_sparql_builder_object_unvalidated (metadata, md.genre);
+ tracker_resource_set_string (main_resource, "nfo:genre", md.genre);
}
if (md.copyright) {
- tracker_sparql_builder_predicate (metadata, "nie:copyright");
- tracker_sparql_builder_object_unvalidated (metadata, md.copyright);
+ tracker_resource_set_string (main_resource, "nie:copyright", md.copyright);
}
if (md.comment) {
- tracker_sparql_builder_predicate (metadata, "nie:comment");
- tracker_sparql_builder_object_unvalidated (metadata, md.comment);
+ tracker_resource_set_string (main_resource, "nie:comment", md.comment);
}
if (md.publisher) {
- tracker_sparql_builder_predicate (metadata, "nco:publisher");
- tracker_sparql_builder_object_blank_open (metadata);
- tracker_sparql_builder_predicate (metadata, "a");
- tracker_sparql_builder_object (metadata, "nco:Contact");
- tracker_sparql_builder_predicate (metadata, "nco:fullname");
- tracker_sparql_builder_object_unvalidated (metadata, md.publisher);
- tracker_sparql_builder_object_blank_close (metadata);
+ TrackerResource *publisher = tracker_resource_new (NULL);
+ tracker_resource_set_uri (publisher, "rdf:type", "nmm:Contact");
+ tracker_resource_set_string (publisher, "nco:fullname", md.publisher);
+
+ tracker_resource_set_relation (main_resource, "nco:publisher", publisher);
+ g_object_unref(publisher);
}
if (md.encoded_by) {
- tracker_sparql_builder_predicate (metadata, "nfo:encodedBy");
- tracker_sparql_builder_object_unvalidated (metadata, md.encoded_by);
+ tracker_resource_set_string (main_resource, "nfo:encodedBy", md.encoded_by);
}
if (md.track_number > 0) {
- tracker_sparql_builder_predicate (metadata, "nmm:trackNumber");
- tracker_sparql_builder_object_int64 (metadata, md.track_number);
+ tracker_resource_set_int (main_resource, "nmm:trackNumber", md.track_number);
}
if (md.album) {
+ TrackerResource *album_disc;
gchar *album_disc_uri;
album_disc_uri = tracker_sparql_escape_uri_printf ("urn:album-disc:%s:Disc%d",
md.album,
md.set_number > 0 ? md.set_number : 1);
- tracker_sparql_builder_delete_open (preupdate, NULL);
- tracker_sparql_builder_subject_iri (preupdate, album_disc_uri);
- tracker_sparql_builder_predicate (preupdate, "nmm:setNumber");
- tracker_sparql_builder_object_variable (preupdate, "unknown");
- tracker_sparql_builder_delete_close (preupdate);
- tracker_sparql_builder_where_open (preupdate);
- tracker_sparql_builder_subject_iri (preupdate, album_disc_uri);
- tracker_sparql_builder_predicate (preupdate, "nmm:setNumber");
- tracker_sparql_builder_object_variable (preupdate, "unknown");
- tracker_sparql_builder_where_close (preupdate);
-
- tracker_sparql_builder_delete_open (preupdate, NULL);
- tracker_sparql_builder_subject_iri (preupdate, album_disc_uri);
- tracker_sparql_builder_predicate (preupdate, "nmm:albumDiscAlbum");
- tracker_sparql_builder_object_variable (preupdate, "unknown");
- tracker_sparql_builder_delete_close (preupdate);
- tracker_sparql_builder_where_open (preupdate);
- tracker_sparql_builder_subject_iri (preupdate, album_disc_uri);
- tracker_sparql_builder_predicate (preupdate, "nmm:albumDiscAlbum");
- tracker_sparql_builder_object_variable (preupdate, "unknown");
- tracker_sparql_builder_where_close (preupdate);
-
- tracker_sparql_builder_insert_open (preupdate, NULL);
- if (graph) {
- tracker_sparql_builder_graph_open (preupdate, graph);
- }
+ album_disc = tracker_resource_new (album_disc_uri);
+ tracker_resource_set_uri (album_disc, "rdf:type", "nmm:MusicAlbumDisc");
+ tracker_resource_set_int (album_disc, "nmm:setNumber", md.set_number > 0 ? md.set_number : 1);
+ tracker_resource_set_relation (album_disc, "nmm:albumDiscAlbum", md.album);
- tracker_sparql_builder_subject_iri (preupdate, album_disc_uri);
- tracker_sparql_builder_predicate (preupdate, "a");
- tracker_sparql_builder_object (preupdate, "nmm:MusicAlbumDisc");
- tracker_sparql_builder_predicate (preupdate, "nmm:setNumber");
- tracker_sparql_builder_object_int64 (preupdate, md.set_number > 0 ? md.set_number : 1);
- tracker_sparql_builder_predicate (preupdate, "nmm:albumDiscAlbum");
- tracker_sparql_builder_object_iri (preupdate, md.album_uri);
-
- if (graph) {
- tracker_sparql_builder_graph_close (preupdate);
- }
- tracker_sparql_builder_insert_close (preupdate);
-
- tracker_sparql_builder_predicate (metadata, "nmm:musicAlbumDisc");
- tracker_sparql_builder_object_iri (metadata, album_disc_uri);
+ tracker_resource_set_relation (main_resource, "nmm:musicAlbumDisc", album_disc);
g_free (album_disc_uri);
+ g_object_unref (md.album);
}
- g_free (md.album_uri);
-
/* Get mp3 stream info */
- parsed = mp3_parse (buffer, buffer_size, audio_offset, uri, metadata, &md);
+ parsed = mp3_parse (buffer, buffer_size, audio_offset, uri, main_resource, &md);
#ifdef HAVE_LIBMEDIAART
if (parsed && (md.performer || md.album)) {
@@ -2706,8 +2581,8 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
md.media_art_data,
md.media_art_size,
md.media_art_mime,
- md.performer,
- md.album,
+ md.performer_name,
+ md.album_name,
NULL,
&error);
} else {
@@ -2715,8 +2590,8 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
MEDIA_ART_ALBUM,
MEDIA_ART_PROCESS_FLAGS_NONE,
file,
- md.performer,
- md.album,
+ md.performer_name,
+ md.album_name,
NULL,
&error);
}
@@ -2741,6 +2616,11 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
munmap (buffer, buffer_size);
#endif
+ if (main_resource) {
+ tracker_extract_info_add_resource (info, main_resource);
+ g_object_unref (main_resource);
+ }
+
g_free (filename);
g_free (uri);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]