[tracker] Fixes for extractors, ontology usage



commit 8cc9f6fc8c5308e7260205403770b5d6909ba5fe
Author: Ottela Mikael <mikael ottela ixonos com>
Date:   Thu Apr 16 22:31:51 2009 +0200

    Fixes for extractors, ontology usage
---
 src/tracker-extract/tracker-extract-gstreamer.c |   57 ++++++++++++-----------
 src/tracker-extract/tracker-extract-jpeg.c      |   16 ++----
 src/tracker-extract/tracker-extract-tiff.c      |   16 ++----
 src/tracker-extract/tracker-iptc.c              |   15 +++---
 4 files changed, 50 insertions(+), 54 deletions(-)

diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index 2cd7e8b..69dc367 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -257,26 +257,6 @@ extract_metadata (MetadataExtractor *extractor,
 		add_string_gst_tag (metadata, uri, DC_PREFIX "coverage", extractor->tagcache, GST_TAG_LOCATION);
 
 		/* Audio */
-		gst_tag_list_get_string (extractor->tagcache, GST_TAG_ALBUM, &s);
-		if (s) {
-			gchar *canonical_uri = tracker_uri_printf_escaped ("urn:album:%s", s);
-			tracker_statement_list_insert (metadata, canonical_uri, RDF_TYPE, NMM_PREFIX "MusicAlbum");
-			tracker_statement_list_insert (metadata, canonical_uri, NMM_PREFIX "albumTitle", s);
-			tracker_statement_list_insert (metadata, uri, NMM_PREFIX "musicAlbum", canonical_uri);
-			g_free (canonical_uri);
-			*album = s;
-		}
-
-		add_uint_gst_tag   (metadata, uri, NMM_PREFIX "albumTrackCount", extractor->tagcache, GST_TAG_TRACK_COUNT);
-
-
-		if (gst_tag_list_get_uint (extractor->tagcache, GST_TAG_TRACK_COUNT, &n)) {
-			*scount = g_strdup_printf ("%d", n);
-		}
-
-		add_uint_gst_tag   (metadata, uri, NMM_PREFIX "trackNumber", extractor->tagcache, GST_TAG_TRACK_NUMBER);
-
-		add_uint_gst_tag   (metadata, uri, NMM_PREFIX "setNumber", extractor->tagcache, GST_TAG_ALBUM_VOLUME_NUMBER);
 
 		gst_tag_list_get_string (extractor->tagcache, GST_TAG_PERFORMER, &s);
 		if (s) {
@@ -309,10 +289,10 @@ extract_metadata (MetadataExtractor *extractor,
 
 			gst_tag_list_get_string (extractor->tagcache, GST_TAG_ARTIST, &s);
 			if (s) {
-				gchar *canonical_uri = tracker_uri_printf_escaped ("urn:artist:%s", s);
-				tracker_statement_list_insert (metadata, canonical_uri, RDF_TYPE, NMM_PREFIX "Artist");
-				tracker_statement_list_insert (metadata, canonical_uri, NMM_PREFIX "artistName", s);
-				tracker_statement_list_insert (metadata, uri, NMM_PREFIX "performer", canonical_uri);
+				gchar *canonical_uri = tracker_uri_printf_escaped ("urn:contact:%s", s);
+				tracker_statement_list_insert (metadata, canonical_uri, RDF_TYPE, NCO_PREFIX "Contact");
+				tracker_statement_list_insert (metadata, canonical_uri, NCO_PREFIX "fullName", s);
+				tracker_statement_list_insert (metadata, uri, NCO_PREFIX "director", canonical_uri);
 				g_free (canonical_uri);
 				g_free (s);
 			}
@@ -326,15 +306,38 @@ extract_metadata (MetadataExtractor *extractor,
 				gchar *canonical_uri = tracker_uri_printf_escaped ("urn:artist:%s", s);
 				tracker_statement_list_insert (metadata, canonical_uri, RDF_TYPE, NMM_PREFIX "Artist");
 				tracker_statement_list_insert (metadata, canonical_uri, NMM_PREFIX "artistName", s);
-				tracker_statement_list_insert (metadata, uri, NMM_PREFIX "performer", canonical_uri);
+				tracker_statement_list_insert (metadata, uri, NMM_PREFIX "director", canonical_uri);
 				g_free (canonical_uri);
 				g_free (s);
 			}
-
+			
 			add_string_gst_tag (metadata, uri, DC_PREFIX "source", extractor->tagcache, GST_TAG_CLASSIFICATION);
 		} else if (extractor->mime == EXTRACT_MIME_AUDIO) {
 			add_string_gst_tag (metadata, uri, NIE_PREFIX "title", extractor->tagcache, GST_TAG_TITLE);
+			
+			gst_tag_list_get_string (extractor->tagcache, GST_TAG_ALBUM, &s);
 
+			if (s) {
+				gchar *canonical_uri = tracker_uri_printf_escaped ("urn:album:%s", s);
+				tracker_statement_list_insert (metadata, canonical_uri, RDF_TYPE, NMM_PREFIX "MusicAlbum");
+				tracker_statement_list_insert (metadata, canonical_uri, NMM_PREFIX "albumTitle", s);
+				tracker_statement_list_insert (metadata, uri, NMM_PREFIX "musicAlbum", canonical_uri);
+				g_free (canonical_uri);
+				*album = s;
+			}
+			
+			add_uint_gst_tag   (metadata, uri, NMM_PREFIX "albumTrackCount", extractor->tagcache, GST_TAG_TRACK_COUNT);
+			
+			
+			if (gst_tag_list_get_uint (extractor->tagcache, GST_TAG_TRACK_COUNT, &n)) {
+				*scount = g_strdup_printf ("%d", n);
+			}
+			
+			add_uint_gst_tag   (metadata, uri, NMM_PREFIX "trackNumber", extractor->tagcache, GST_TAG_TRACK_NUMBER);
+			
+			add_uint_gst_tag   (metadata, uri, NMM_PREFIX "setNumber", extractor->tagcache, GST_TAG_ALBUM_VOLUME_NUMBER);
+			
+			
 			gst_tag_list_get_string (extractor->tagcache, GST_TAG_ARTIST, &s);
 			if (s) {
 				gchar *canonical_uri = tracker_uri_printf_escaped ("urn:artist:%s", s);
@@ -344,7 +347,7 @@ extract_metadata (MetadataExtractor *extractor,
 				g_free (canonical_uri);
 				g_free (s);
 			}
-
+			
 			if (gst_tag_list_get_string (extractor->tagcache, GST_TAG_ARTIST, &s)) {
 				*artist = s;
 			}
diff --git a/src/tracker-extract/tracker-extract-jpeg.c b/src/tracker-extract/tracker-extract-jpeg.c
index 89f0e16..9c2f87f 100644
--- a/src/tracker-extract/tracker-extract-jpeg.c
+++ b/src/tracker-extract/tracker-extract-jpeg.c
@@ -205,14 +205,12 @@ fix_focal_length (const gchar *fl, gboolean *free_it)
 static gchar *
 fix_flash (const gchar *flash, gboolean *free_it)
 {
-	/* Found in the field: Auto, Did not fire, Red-eye reduction */
-
 	*free_it = FALSE;
 	
-	if (strcasestr (flash, "not fire")) {
-		return (gchar *) "nmm:flash-off";
-	} else {
+	if (strcasestr (flash, "flash fired")) {
 		return (gchar *) "nmm:flash-on";
+	} else {
+		return (gchar *) "nmm:flash-off";
 	}
 }
 
@@ -289,11 +287,11 @@ fix_orientation (const gchar *orientation, gboolean *free_it)
 				case 0:
 				return (gchar *) "nfo:orientation-top";
 				case 1:
-				return (gchar *) "nfo:orientation-top-mirror"; // not sure
+				return (gchar *) "nfo:orientation-top-mirror";
 				case 2:
-				return (gchar *) "nfo:orientation-bottom-mirror"; // not sure
-				case 3:
 				return (gchar *) "nfo:orientation-bottom";
+				case 3:
+				return (gchar *) "nfo:orientation-bottom-mirror";
 				case 4:
 				return (gchar *) "nfo:orientation-left-mirror";
 				case 5:
@@ -313,8 +311,6 @@ fix_orientation (const gchar *orientation, gboolean *free_it)
 static gchar *
 fix_metering_mode (const gchar *metering_mode, gboolean *free_it)
 {
-	/* Found in the field: Multi-segment. These will yield as other */
-
 	*free_it = FALSE;
 	
 	if (strcasestr (metering_mode, "center")) {
diff --git a/src/tracker-extract/tracker-extract-tiff.c b/src/tracker-extract/tracker-extract-tiff.c
index cf1fc4b..417e5d7 100644
--- a/src/tracker-extract/tracker-extract-tiff.c
+++ b/src/tracker-extract/tracker-extract-tiff.c
@@ -184,14 +184,12 @@ fix_focal_length (const gchar *fl, gboolean *free_it)
 static gchar *
 fix_flash (const gchar *flash, gboolean *free_it)
 {
-	/* Found in the field: Auto, Did not fire, Red-eye reduction */
-
 	*free_it = FALSE;
 	
-	if (strcasestr (flash, "not fire")) {
-		return (gchar *) "nmm:flash-off";
-	} else {
+	if (strcasestr (flash, "flash fired")) {
 		return (gchar *) "nmm:flash-on";
+	} else {
+		return (gchar *) "nmm:flash-off";
 	}
 }
 
@@ -269,11 +267,11 @@ fix_orientation (const gchar *orientation, gboolean *free_it)
 				case 0:
 				return (gchar *) "nfo:orientation-top";
 				case 1:
-				return (gchar *) "nfo:orientation-top-mirror"; // not sure
+				return (gchar *) "nfo:orientation-top-mirror";
 				case 2:
-				return (gchar *) "nfo:orientation-bottom-mirror"; // not sure
-				case 3:
 				return (gchar *) "nfo:orientation-bottom";
+				case 3:
+				return (gchar *) "nfo:orientation-bottom-mirror";
 				case 4:
 				return (gchar *) "nfo:orientation-left-mirror";
 				case 5:
@@ -293,8 +291,6 @@ fix_orientation (const gchar *orientation, gboolean *free_it)
 static gchar *
 fix_metering_mode (const gchar *metering_mode, gboolean *free_it)
 {
-	/* Found in the field: Multi-segment. These will yield as other */
-
 	*free_it = FALSE;
 	
 	if (strcasestr (metering_mode, "center")) {
diff --git a/src/tracker-extract/tracker-iptc.c b/src/tracker-extract/tracker-iptc.c
index 0e19a89..f811713 100644
--- a/src/tracker-extract/tracker-iptc.c
+++ b/src/tracker-extract/tracker-iptc.c
@@ -30,6 +30,7 @@
 #define RDF_TYPE RDF_PREFIX "type"
 #define NIE_PREFIX TRACKER_NIE_PREFIX
 #define NCO_PREFIX TRACKER_NCO_PREFIX
+#define NFO_PREFIX TRACKER_NFO_PREFIX
 
 #include <glib.h>
 #include <string.h>
@@ -56,15 +57,15 @@ static const gchar *fix_iptc_orientation (const gchar *orientation);
 static IptcTagType iptctags[] = {
         { 2, IPTC_TAG_KEYWORDS, NIE_PREFIX "keyword", NULL, NULL, NULL, NULL }, /* We might have to strtok_r this one? */
 	/*	{ 2, IPTC_TAG_CONTENT_LOC_NAME, "Image:Location", NULL, NULL, NULL, NULL }, */
-	{ 2, IPTC_TAG_SUBLOCATION, "Image:Location", NULL, NULL, NULL, NULL },
+	/*{ 2, IPTC_TAG_SUBLOCATION, "Image:Location", NULL, NULL, NULL, NULL },*/
         { 2, IPTC_TAG_DATE_CREATED, NIE_PREFIX "contentCreated", NULL, NULL, NULL, NULL },
-        { 2, IPTC_TAG_ORIGINATING_PROGRAM, "Image:Software", NULL, NULL, NULL, NULL },
+        /*{ 2, IPTC_TAG_ORIGINATING_PROGRAM, "Image:Software", NULL, NULL, NULL, NULL },*/
         { 2, IPTC_TAG_BYLINE, NCO_PREFIX "creator", NULL, ":", NCO_PREFIX "Contact", NCO_PREFIX "fullname" },
-        { 2, IPTC_TAG_CITY, "Image:City", NULL, NULL, NULL, NULL },
-        { 2, IPTC_TAG_COUNTRY_NAME, "Image:Country", NULL, NULL, NULL, NULL },
+        /*{ 2, IPTC_TAG_CITY, "Image:City", NULL, NULL, NULL, NULL },*/
+        /*{ 2, IPTC_TAG_COUNTRY_NAME, "Image:Country", NULL, NULL, NULL, NULL },*/
 	{ 2, IPTC_TAG_CREDIT, NCO_PREFIX "creator", NULL, ":", NCO_PREFIX "Contact", NCO_PREFIX "fullname" },
         { 2, IPTC_TAG_COPYRIGHT_NOTICE, NIE_PREFIX "copyright", NULL, NULL, NULL, NULL },
-        { 2, IPTC_TAG_IMAGE_ORIENTATION, "Image:Orientation", fix_iptc_orientation, NULL, NULL, NULL },
+        { 2, IPTC_TAG_IMAGE_ORIENTATION, NFO_PREFIX "orientation", fix_iptc_orientation, NULL, NULL, NULL },
 	{ -1, -1, NULL, NULL, NULL, NULL, NULL }
 };
 
@@ -72,10 +73,10 @@ static const gchar *
 fix_iptc_orientation (const gchar *orientation)
 {
 	if (strcmp(orientation, "P")==0) {
-		return "3";
+		return "nfo:orientation-left";
 	}
 	
-	return "1"; /* We take this as default */
+	return "nfo:orientation-top"; /* We take this as default */
 }
 
 #endif



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