[tracker/cuesheets: 16/22] tracker-extract-gstreamer: Remove existing tracks for a file when extracting



commit c8bf568203d44002c9bfd4b7191332e62daa18c4
Author: Sam Thursfield <sam thursfield codethink co uk>
Date:   Thu Sep 22 18:56:18 2011 +0100

    tracker-extract-gstreamer: Remove existing tracks for a file when extracting

 src/tracker-extract/tracker-extract-gstreamer.c |   38 +++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index b217318..479c015 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -856,6 +856,42 @@ extract_track_metadata (MetadataExtractor    *extractor,
 }
 
 static void
+delete_existing_tracks (TrackerSparqlBuilder *postupdate,
+                        const gchar          *graph,
+                        const gchar          *file_url)
+{
+	gchar *sparql;
+
+	/* Delete existing tracks */
+
+	tracker_sparql_builder_delete_open (postupdate, NULL);
+	if (graph) {
+		tracker_sparql_builder_graph_open (postupdate, graph);
+	}
+
+	tracker_sparql_builder_subject_variable (postupdate, "track");
+	tracker_sparql_builder_predicate (postupdate, "a");
+	tracker_sparql_builder_object (postupdate, "rdfs:Resource");
+
+	if (graph) {
+		tracker_sparql_builder_graph_close (postupdate);
+	}
+	tracker_sparql_builder_delete_close (postupdate);
+
+	sparql = g_strdup_printf ("WHERE { "
+	                          "  ?track a nmm:MusicPiece . "
+	                          "  ?file a nfo:FileDataObject ; "
+	                          "        nie:url \"%s\" . "
+	                          "  ?track nie:isStoredAs ?file "
+	                          "} \n",
+	                          file_url);
+	tracker_sparql_builder_append (postupdate, sparql);
+	g_free (sparql);
+}
+
+
+
+static void
 extract_metadata (MetadataExtractor      *extractor,
                   const gchar            *file_url,
                   TrackerSparqlBuilder   *preupdate,
@@ -962,6 +998,8 @@ extract_metadata (MetadataExtractor      *extractor,
 			 * concrete nfo:FileDataObject using nie:isStoredAs.
 			 */
 			if (extractor->toc && g_list_length (extractor->toc->entry_list) > 1) {
+				delete_existing_tracks (postupdate, graph, file_url);
+
 				tracker_sparql_builder_insert_open (postupdate, NULL);
 				if (graph) {
 					tracker_sparql_builder_graph_open (postupdate, graph);



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