[tracker/guarantee: 3/3] libtracker-extract: Update API to allow one function call from extractors
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/guarantee: 3/3] libtracker-extract: Update API to allow one function call from extractors
- Date: Wed, 15 Dec 2010 09:14:54 +0000 (UTC)
commit edee223134b60d809bf441d443acb7d095e3139f
Author: Martyn Russell <martyn lanedo com>
Date: Fri Dec 10 13:23:14 2010 +0000
libtracker-extract: Update API to allow one function call from extractors
The idea here is that we don't do the NULL checks, etc everywhere, but
instead we pass a value in and the uri so we can retrieve the data and
guarantee a value *if* it wasn't in the value passed in in the first
place.
src/libtracker-extract/tracker-guarantee.c | 133 +++++++++++++++++-----
src/libtracker-extract/tracker-guarantee.h | 12 ++-
src/tracker-extract/tracker-extract-flac.c | 22 +----
src/tracker-extract/tracker-extract-gif.c | 38 ++-----
src/tracker-extract/tracker-extract-gstreamer.c | 63 ++++-------
src/tracker-extract/tracker-extract-gupnp-dlna.c | 58 ++++------
src/tracker-extract/tracker-extract-jpeg.c | 34 ++----
src/tracker-extract/tracker-extract-mp3.c | 36 ++-----
src/tracker-extract/tracker-extract-png.c | 38 ++-----
src/tracker-extract/tracker-extract-tiff.c | 34 ++----
10 files changed, 203 insertions(+), 265 deletions(-)
---
diff --git a/src/libtracker-extract/tracker-guarantee.c b/src/libtracker-extract/tracker-guarantee.c
index bb5374a..c3982d5 100644
--- a/src/libtracker-extract/tracker-guarantee.c
+++ b/src/libtracker-extract/tracker-guarantee.c
@@ -27,67 +27,138 @@
#include "tracker-guarantee.h"
+static gchar *
+get_title_from_filename (const gchar *uri)
+{
+ gchar *filename;
+ gchar *basename;
+ gchar *p;
+
+ filename = g_filename_from_uri (uri, NULL, NULL);
+ basename = g_filename_display_basename (filename);
+ g_free (filename);
+
+ p = strchr (basename, '.');
+ if (p) {
+ *p = '\0';
+ }
+
+ return g_strdelimit (basename, "_", ' ');
+}
+
+static gchar *
+get_date_from_filename_mtime (const gchar *uri)
+{
+ gchar *filename;
+ gchar *date;
+ guint64 mtime;
+
+ filename = g_filename_from_uri (uri, NULL, NULL);
+ mtime = tracker_file_get_mtime (filename);
+ g_free (filename);
+
+ date = tracker_date_to_string ((time_t) mtime);
+
+ return date;
+}
+
/**
* tracker_guarantee_title_from_filename:
+ * @metadata: the metadata object to insert the data into
+ * @key: the key to insert into @metadata
+ * @current_value: the current data to check before looking at @uri
* @uri: a string representing a URI to use
*
+ * Checks @current_value to make sure it is sane (i.e. not %NULL or an
+ * empty string). If it is, then @uri is parsed to guarantee a
+ * metadata value for @key.
+ *
* Parses the filename pointed to by @uri and uses the basename
* (before the "." and extension of the file) as the title. If the
* title has any "_" characters, they are also converted into spaces.
*
- * Returns: A newly allocated string which must be freed with g_free()
- * or %NULL on error.
+ * Returns: %TRUE on success, otherwise %FALSE.
*
* Since: 0.10
**/
-gchar *
-tracker_guarantee_title_from_filename (const gchar *uri)
+gboolean
+tracker_guarantee_title_from_filename (TrackerSparqlBuilder *metadata,
+ const gchar *key,
+ const gchar *current_value,
+ const gchar *uri)
{
- gchar *filename;
- gchar *basename;
- gchar *p;
+#ifdef GUARANTEE_METADATA
+ g_return_val_if_fail (metadata != NULL, FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
+ g_return_val_if_fail (uri != NULL, FALSE);
- g_return_val_if_fail (uri != NULL, NULL);
+ tracker_sparql_builder_predicate (metadata, key);
- filename = g_filename_from_uri (uri, NULL, NULL);
- basename = g_filename_display_basename (filename);
- g_free (filename);
+ if (current_value && *current_value != '\0') {
+ tracker_sparql_builder_object_unvalidated (metadata, current_value);
+ } else {
+ gchar *value;
- p = strchr (basename, '.');
- if (p) {
- *p = '\0';
+ value = get_title_from_filename (uri);
+ tracker_sparql_builder_object_unvalidated (metadata, value);
+ g_free (value);
}
+#else /* GUARANTEE_METADATA */
+ if (current_value && *current_value != '\0') {
+ tracker_sparql_builder_predicate (metadata, key);
+ tracker_sparql_builder_object_unvalidated (metadata, current_value);
+ }
+#endif /* GUARANTEE_METADATA */
- return g_strdelimit (basename, "_", ' ');
-
+ return TRUE;
}
/**
* tracker_guarantee_date_from_filename_mtime:
+ * @metadata: the metadata object to insert the data into
+ * @key: the key to insert into @metadata
+ * @current_value: the current data to check before looking at @uri
* @uri: a string representing a URI to use
*
- * Calls stat() on the filename pointed to by @uri to create a date
- * based on the file's mtime.
+ * Checks @current_value to make sure it is sane (i.e. not %NULL or an
+ * empty string). If it is, then @uri is parsed to guarantee a
+ * metadata value for @key.
*
- * Returns: A newly allocated string which must be freed with g_free()
- * or %NULL on error. The string represents the date in ISO8160.
+ * When parsing @uri, stat() is called on the filename to create a
+ * date based on the file's mtime.
+ *
+ * Returns: %TRUE on success, otherwise %FALSE.
*
* Since: 0.10
**/
-gchar *
-tracker_guarantee_date_from_filename_mtime (const gchar *uri)
+gboolean
+tracker_guarantee_date_from_filename_mtime (TrackerSparqlBuilder *metadata,
+ const gchar *key,
+ const gchar *current_value,
+ const gchar *uri)
{
- gchar *filename;
- gchar *date;
- guint64 mtime;
+#ifdef GUARANTEE_METADATA
+ g_return_val_if_fail (metadata != NULL, FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
+ g_return_val_if_fail (uri != NULL, FALSE);
- g_return_val_if_fail (uri != NULL, NULL);
+ tracker_sparql_builder_predicate (metadata, key);
- filename = g_filename_from_uri (uri, NULL, NULL);
- mtime = tracker_file_get_mtime (filename);
- g_free (filename);
+ if (current_value && *current_value != '\0') {
+ tracker_sparql_builder_object_unvalidated (metadata, current_value);
+ } else {
+ gchar *value;
- date = tracker_date_to_string ((time_t) mtime);
+ value = get_date_from_filename_mtime (uri);
+ tracker_sparql_builder_object_unvalidated (metadata, value);
+ g_free (value);
+ }
+#else /* GUARANTEE_METADATA */
+ if (current_value && *current_value != '\0') {
+ tracker_sparql_builder_predicate (metadata, key);
+ tracker_sparql_builder_object_unvalidated (metadata, current_value);
+ }
+#endif /* GUARANTEE_METADATA */
- return date;
+ return TRUE;
}
diff --git a/src/libtracker-extract/tracker-guarantee.h b/src/libtracker-extract/tracker-guarantee.h
index a215ccc..d662f62 100644
--- a/src/libtracker-extract/tracker-guarantee.h
+++ b/src/libtracker-extract/tracker-guarantee.h
@@ -26,10 +26,18 @@
#error "only <libtracker-extract/tracker-extract.h> must be included directly."
#endif
+#include "tracker-data.h"
+
G_BEGIN_DECLS
-gchar *tracker_guarantee_title_from_filename (const gchar *uri);
-gchar *tracker_guarantee_date_from_filename_mtime (const gchar *uri);
+gboolean tracker_guarantee_title_from_filename (TrackerSparqlBuilder *metadata,
+ const gchar *key,
+ const gchar *current_value,
+ const gchar *uri);
+gboolean tracker_guarantee_date_from_filename_mtime (TrackerSparqlBuilder *metadata,
+ const gchar *key,
+ const gchar *current_value,
+ const gchar *uri);
G_END_DECLS
diff --git a/src/tracker-extract/tracker-extract-flac.c b/src/tracker-extract/tracker-extract-flac.c
index 9d5cc1f..a60d179 100644
--- a/src/tracker-extract/tracker-extract-flac.c
+++ b/src/tracker-extract/tracker-extract-flac.c
@@ -323,16 +323,7 @@ extract_flac (const gchar *uri,
add_tuple (metadata, "nmm:musicAlbum", album_uri);
g_free (album_uri);
- add_tuple (metadata, "nie:title", fd.title);
-#ifdef GUARANTEE_METADATA
- if (!fd.title) {
- gchar *title;
-
- title = tracker_guarantee_title_from_filename (uri);
- add_tuple (metadata, "nie:title", title);
- g_free (title);
- }
-#endif
+ tracker_guarantee_title_from_filename (metadata, "nie:title", fd.title, uri);
add_tuple (metadata, "nmm:trackNumber", fd.tracknumber);
if (fd.album && album_uri) {
@@ -383,16 +374,7 @@ extract_flac (const gchar *uri,
/* FIXME: Trackgain/Trackpeakgain: commented out in vorbis */
add_tuple (metadata, "nie:comment", fd.comment);
- add_tuple (metadata, "nie:contentCreated", fd.date);
-#ifdef GUARANTEE_METADATA
- if (!fd.date) {
- gchar *date;
-
- date = tracker_guarantee_date_from_filename_mtime (uri);
- add_tuple (metadata, "nie:contentCreated", date);
- g_free (date);
- }
-#endif
+ tracker_guarantee_date_from_filename_mtime (metadata, "nie:contentCreated", fd.date, uri);
add_tuple (metadata, "nfo:genre", fd.genre);
add_tuple (metadata, "nie:plainTextContent", fd.lyrics);
add_tuple (metadata, "nie:copyright", fd.copyright);
diff --git a/src/tracker-extract/tracker-extract-gif.c b/src/tracker-extract/tracker-extract-gif.c
index 545f59f..4dfc1c6 100644
--- a/src/tracker-extract/tracker-extract-gif.c
+++ b/src/tracker-extract/tracker-extract-gif.c
@@ -229,20 +229,11 @@ read_metadata (TrackerSparqlBuilder *preupdate,
g_free (uri);
}
- if (md.date) {
- tracker_sparql_builder_predicate (metadata, "nie:contentCreated");
- tracker_sparql_builder_object_unvalidated (metadata, md.date);
- }
-#ifdef GUARANTEE_METADATA
- else {
- gchar *date;
+ tracker_guarantee_date_from_filename_mtime (metadata,
+ "nie:contentCreated",
+ md.date,
+ uri);
- date = tracker_guarantee_date_from_filename_mtime (uri);
- tracker_sparql_builder_predicate (metadata, "nie:contentCreated");
- tracker_sparql_builder_object_unvalidated (metadata, date);
- g_free (date);
- }
-#endif
if (xd->description) {
tracker_sparql_builder_predicate (metadata, "nie:description");
tracker_sparql_builder_object_unvalidated (metadata, xd->description);
@@ -279,20 +270,11 @@ read_metadata (TrackerSparqlBuilder *preupdate,
g_free (equip_uri);
}
- if (md.title) {
- tracker_sparql_builder_predicate (metadata, "nie:title");
- tracker_sparql_builder_object_unvalidated (metadata, md.title);
- }
-#ifdef GUARANTEE_METADATA
- else {
- gchar *title;
+ tracker_guarantee_title_from_filename (metadata,
+ "nie:title",
+ md.title,
+ uri);
- title = tracker_guarantee_title_from_filename (uri);
- tracker_sparql_builder_predicate (metadata, "nie:title");
- tracker_sparql_builder_object_unvalidated (metadata, title);
- g_free (title);
- }
-#endif
if (md.artist) {
gchar *uri = tracker_sparql_escape_uri_printf ("urn:contact:%s", md.artist);
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index 51f6433..5f1227b 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -282,45 +282,40 @@ add_y_date_gst_tag (TrackerSparqlBuilder *metadata,
GstTagList *tag_list,
const gchar *tag)
{
- GDate *date;
- gboolean ret;
+ GDate *date;
+ gchar buf[25];
date = NULL;
- ret = gst_tag_list_get_date (tag_list, tag, &date);
+ buf[0] = '\0';
+
+ if (gst_tag_list_get_date (tag_list, tag, &date)) {
+ gboolean ret;
- if (ret) {
if (date && g_date_valid (date)) {
if (date->julian)
ret = g_date_valid_julian (date->julian_days);
if (date->dmy)
ret = g_date_valid_dmy (date->day, date->month, date->year);
- } else
+ } else {
ret = FALSE;
- }
-
- if (ret) {
- gchar buf[25];
+ }
- if (g_date_strftime (buf, 25, "%Y-%m-%dT%H:%M:%S%z", date)) {
- tracker_sparql_builder_predicate (metadata, key);
- tracker_sparql_builder_object_unvalidated (metadata, buf);
+ if (ret) {
+ if (g_date_strftime (buf, 25, "%Y-%m-%dT%H:%M:%S%z", date)) {
+ tracker_sparql_builder_predicate (metadata, key);
+ tracker_sparql_builder_object_unvalidated (metadata, buf);
+ }
}
}
if (date) {
g_date_free (date);
}
-#ifdef GUARANTEE_METADATA
- else {
- gchar *date;
-
- date = tracker_guarantee_date_from_filename_mtime (uri);
- tracker_sparql_builder_predicate (metadata, key);
- tracker_sparql_builder_object_unvalidated (metadata, date);
- g_free (date);
- }
-#endif
+ tracker_guarantee_date_from_filename_mtime (metadata,
+ key,
+ buf,
+ uri);
}
static void
@@ -522,6 +517,7 @@ extract_metadata (MetadataExtractor *extractor,
gchar *composer_uri = NULL;
gchar *album_uri = NULL;
gchar *album_disc_uri = NULL;
+ gchar *s;
if (extractor->mime == EXTRACT_MIME_GUESS) {
gchar *video_codec = NULL, *audio_codec = NULL;
@@ -772,23 +768,12 @@ extract_metadata (MetadataExtractor *extractor,
s = NULL;
gst_tag_list_get_string (extractor->tagcache, GST_TAG_TITLE, &s);
- if (s) {
- if (ret && s[0] != '\0') {
- tracker_sparql_builder_predicate (metadata, "nie:title");
- tracker_sparql_builder_object_unvalidated (metadata, s);
- }
- g_free (s);
- }
-#ifdef GUARANTEE_METADATA
- else {
- gchar *title;
-
- title = tracker_guarantee_title_from_filename (uri);
- tracker_sparql_builder_predicate (metadata, "nie:title");
- tracker_sparql_builder_object_unvalidated (metadata, title);
- g_free (title);
- }
-#endif
+ tracker_guarantee_title_from_filename (metadata,
+ "nie:title",
+ s,
+ uri);
+ g_free (s);
+
add_string_gst_tag (metadata, uri, "nie:copyright", extractor->tagcache, GST_TAG_COPYRIGHT);
add_string_gst_tag (metadata, uri, "nie:license", extractor->tagcache, GST_TAG_LICENSE);
add_string_gst_tag (metadata, uri, "dc:coverage", extractor->tagcache, GST_TAG_LOCATION);
diff --git a/src/tracker-extract/tracker-extract-gupnp-dlna.c b/src/tracker-extract/tracker-extract-gupnp-dlna.c
index b686bf5..07a80ab 100644
--- a/src/tracker-extract/tracker-extract-gupnp-dlna.c
+++ b/src/tracker-extract/tracker-extract-gupnp-dlna.c
@@ -265,43 +265,39 @@ add_y_date_gst_tag (TrackerSparqlBuilder *metadata,
const gchar *tag)
{
GDate *date;
- gboolean ret;
+ gchar buf[25];
date = NULL;
- ret = gst_tag_list_get_date (tag_list, tag, &date);
+ buf[0] = '\0';
+
+ if (gst_tag_list_get_date (tag_list, tag, &date)) {
+ gboolean ret;
- if (ret) {
if (date && g_date_valid (date)) {
if (date->julian)
ret = g_date_valid_julian (date->julian_days);
if (date->dmy)
ret = g_date_valid_dmy (date->day, date->month, date->year);
- } else
+ } else {
ret = FALSE;
- }
-
- if (ret) {
- gchar buf[25];
+ }
- if (g_date_strftime (buf, 25, "%Y-%m-%dT%H:%M:%S%z", date)) {
- tracker_sparql_builder_predicate (metadata, key);
- tracker_sparql_builder_object_unvalidated (metadata, buf);
+ if (ret) {
+ if (g_date_strftime (buf, 25, "%Y-%m-%dT%H:%M:%S%z", date)) {
+ tracker_sparql_builder_predicate (metadata, key);
+ tracker_sparql_builder_object_unvalidated (metadata, buf);
+ }
}
}
if (date) {
g_date_free (date);
}
-#ifdef GUARANTEE_METADATA
- else {
- gchar *date;
- date = tracker_guarantee_date_from_filename_mtime (uri);
- tracker_sparql_builder_predicate (metadata, key);
- tracker_sparql_builder_object_unvalidated (metadata, date);
- g_free (date);
- }
-#endif
+ tracker_guarantee_date_from_filename_mtime (metadata,
+ key,
+ buf,
+ uri);
}
static void
@@ -613,23 +609,11 @@ extract_metadata (MetadataExtractor *extractor,
s = NULL;
ret = gst_tag_list_get_string (extractor->tags, GST_TAG_TITLE, &s);
- if (s) {
- if (ret && s[0] != '\0') {
- tracker_sparql_builder_predicate (metadata, "nie:title");
- tracker_sparql_builder_object_unvalidated (metadata, s);
- }
- g_free (s);
- }
-#ifdef GUARANTEE_METADATA
- else {
- gchar *title;
-
- title = tracker_guarantee_title_from_filename (uri);
- tracker_sparql_builder_predicate (metadata, "nie:title");
- tracker_sparql_builder_object_unvalidated (metadata, title);
- g_free (title);
- }
-#endif
+ tracker_guarantee_title_from_filename (metadata,
+ "nie:title",
+ s,
+ uri);
+ g_free (s);
add_string_gst_tag (metadata, uri, "nie:copyright", extractor->tags, GST_TAG_COPYRIGHT);
add_string_gst_tag (metadata, uri, "nie:license", extractor->tags, GST_TAG_LICENSE);
diff --git a/src/tracker-extract/tracker-extract-jpeg.c b/src/tracker-extract/tracker-extract-jpeg.c
index 133eb11..409f25d 100644
--- a/src/tracker-extract/tracker-extract-jpeg.c
+++ b/src/tracker-extract/tracker-extract-jpeg.c
@@ -403,20 +403,11 @@ extract_jpeg (const gchar *uri,
g_free (equip_uri);
}
- if (md.title) {
- tracker_sparql_builder_predicate (metadata, "nie:title");
- tracker_sparql_builder_object_unvalidated (metadata, md.title);
- }
-#ifdef GUARANTEE_METADATA
- else {
- gchar *title;
+ tracker_guarantee_title_from_filename (metadata,
+ "nie:title",
+ md.title,
+ uri);
- title = tracker_guarantee_title_from_filename (uri);
- tracker_sparql_builder_predicate (metadata, "nie:title");
- tracker_sparql_builder_object_unvalidated (metadata, title);
- g_free (title);
- }
-#endif
if (md.orientation) {
tracker_sparql_builder_predicate (metadata, "nfo:orientation");
tracker_sparql_builder_object (metadata, md.orientation);
@@ -485,20 +476,11 @@ extract_jpeg (const gchar *uri,
tracker_sparql_builder_object_double (metadata, value);
}
- if (md.date) {
- tracker_sparql_builder_predicate (metadata, "nie:contentCreated");
- tracker_sparql_builder_object_unvalidated (metadata, md.date);
- }
-#ifdef GUARANTEE_METADATA
- else {
- gchar *date;
+ tracker_guarantee_date_from_filename_mtime (metadata,
+ "nie:contentCreated",
+ md.date,
+ uri);
- date = tracker_guarantee_date_from_filename_mtime (uri);
- tracker_sparql_builder_predicate (metadata, "nie:contentCreated");
- tracker_sparql_builder_object_unvalidated (metadata, date);
- g_free (date);
- }
-#endif
if (md.description) {
tracker_sparql_builder_predicate (metadata, "nie:description");
tracker_sparql_builder_object_unvalidated (metadata, md.description);
diff --git a/src/tracker-extract/tracker-extract-mp3.c b/src/tracker-extract/tracker-extract-mp3.c
index 6d72ad0..b976495 100644
--- a/src/tracker-extract/tracker-extract-mp3.c
+++ b/src/tracker-extract/tracker-extract-mp3.c
@@ -2269,20 +2269,10 @@ extract_mp3 (const gchar *uri,
tracker_sparql_builder_object (metadata, "nmm:MusicPiece");
tracker_sparql_builder_object (metadata, "nfo:Audio");
- if (md.title) {
- tracker_sparql_builder_predicate (metadata, "nie:title");
- tracker_sparql_builder_object_unvalidated (metadata, md.title);
- }
-#ifdef GUARANTEE_METADATA
- else {
- gchar *title;
-
- title = tracker_guarantee_title_from_filename (uri);
- tracker_sparql_builder_predicate (metadata, "nie:title");
- tracker_sparql_builder_object_unvalidated (metadata, title);
- g_free (title);
- }
-#endif
+ tracker_guarantee_title_from_filename (metadata,
+ "nie:title",
+ md.title,
+ uri);
if (md.lyricist_uri) {
tracker_sparql_builder_predicate (metadata, "nmm:lyricist");
@@ -2307,20 +2297,10 @@ extract_mp3 (const gchar *uri,
tracker_sparql_builder_object_iri (metadata, md.album_uri);
}
- if (md.recording_time) {
- tracker_sparql_builder_predicate (metadata, "nie:contentCreated");
- tracker_sparql_builder_object_unvalidated (metadata, md.recording_time);
- }
-#ifdef GUARANTEE_METADATA
- else {
- gchar *date;
-
- date = tracker_guarantee_date_from_filename_mtime (uri);
- tracker_sparql_builder_predicate (metadata, "nie:contentCreated");
- tracker_sparql_builder_object_unvalidated (metadata, date);
- g_free (date);
- }
-#endif
+ tracker_guarantee_date_from_filename_mtime (metadata,
+ "nie:contentCreated",
+ md.recording_time,
+ uri);
if (md.genre) {
tracker_sparql_builder_predicate (metadata, "nfo:genre");
diff --git a/src/tracker-extract/tracker-extract-png.c b/src/tracker-extract/tracker-extract-png.c
index f747ad3..8e780d2 100644
--- a/src/tracker-extract/tracker-extract-png.c
+++ b/src/tracker-extract/tracker-extract-png.c
@@ -241,20 +241,11 @@ read_metadata (TrackerSparqlBuilder *preupdate,
g_free (uri);
}
- if (md.date) {
- tracker_sparql_builder_predicate (metadata, "nie:contentCreated");
- tracker_sparql_builder_object_unvalidated (metadata, md.date);
- }
-#ifdef GUARANTEE_METADATA
- else {
- gchar *date;
+ tracker_guarantee_date_from_filename_mtime (metadata,
+ "nie:contentCreated",
+ md.date,
+ uri);
- date = tracker_guarantee_date_from_filename_mtime (uri);
- tracker_sparql_builder_predicate (metadata, "nie:contentCreated");
- tracker_sparql_builder_object_unvalidated (metadata, date);
- g_free (date);
- }
-#endif
if (md.description) {
tracker_sparql_builder_predicate (metadata, "nie:description");
tracker_sparql_builder_object_unvalidated (metadata, md.description);
@@ -265,20 +256,11 @@ read_metadata (TrackerSparqlBuilder *preupdate,
tracker_sparql_builder_object_unvalidated (metadata, md.copyright);
}
- if (md.title) {
- tracker_sparql_builder_predicate (metadata, "nie:title");
- tracker_sparql_builder_object_unvalidated (metadata, md.title);
- }
-#ifdef GUARANTEE_METADATA
- else {
- gchar *title;
+ tracker_guarantee_title_from_filename (metadata,
+ "nie:title",
+ md.title,
+ uri);
- title = tracker_guarantee_title_from_filename (uri);
- tracker_sparql_builder_predicate (metadata, "nie:title");
- tracker_sparql_builder_object_unvalidated (metadata, title);
- g_free (title);
- }
-#endif
if (md.make || md.model) {
gchar *equip_uri;
diff --git a/src/tracker-extract/tracker-extract-tiff.c b/src/tracker-extract/tracker-extract-tiff.c
index 2191047..274a899 100644
--- a/src/tracker-extract/tracker-extract-tiff.c
+++ b/src/tracker-extract/tracker-extract-tiff.c
@@ -598,20 +598,11 @@ extract_tiff (const gchar *uri,
g_free (equip_uri);
}
- if (md.title) {
- tracker_sparql_builder_predicate (metadata, "nie:title");
- tracker_sparql_builder_object_unvalidated (metadata, md.title);
- }
-#ifdef GUARANTEE_METADATA
- else {
- gchar *title;
+ tracker_guarantee_title_from_filename (metadata,
+ "nie:title",
+ md.title,
+ uri);
- title = tracker_guarantee_title_from_filename (uri);
- tracker_sparql_builder_predicate (metadata, "nie:title");
- tracker_sparql_builder_object_unvalidated (metadata, title);
- g_free (title);
- }
-#endif
if (md.orientation) {
tracker_sparql_builder_predicate (metadata, "nfo:orientation");
tracker_sparql_builder_object_unvalidated (metadata, md.orientation);
@@ -668,20 +659,11 @@ extract_tiff (const gchar *uri,
tracker_sparql_builder_object_unvalidated (metadata, md.iso_speed_ratings);
}
- if (md.date) {
- tracker_sparql_builder_predicate (metadata, "nie:contentCreated");
- tracker_sparql_builder_object_unvalidated (metadata, md.date);
- }
-#ifdef GUARANTEE_METADATA
- else {
- gchar *date;
+ tracker_guarantee_date_from_filename_mtime (metadata,
+ "nie:contentCreated",
+ md.date,
+ uri);
- date = tracker_guarantee_date_from_filename_mtime (uri);
- tracker_sparql_builder_predicate (metadata, "nie:contentCreated");
- tracker_sparql_builder_object_unvalidated (metadata, date);
- g_free (date);
- }
-#endif
if (md.description) {
tracker_sparql_builder_predicate (metadata, "nie:description");
tracker_sparql_builder_object_unvalidated (metadata, md.description);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]