[PATCH 09/11] tracker: updated to new date format



---
 src/media/tracker/grl-tracker-utils.c |   31 +++++++++++++++++++++++--------
 1 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/src/media/tracker/grl-tracker-utils.c b/src/media/tracker/grl-tracker-utils.c
index 3588708..02d7c88 100644
--- a/src/media/tracker/grl-tracker-utils.c
+++ b/src/media/tracker/grl-tracker-utils.c
@@ -71,6 +71,19 @@ set_orientation (TrackerSparqlCursor *cursor,
     grl_data_set_int (GRL_DATA (media), key, 270);
 }
 
+static void
+set_date (TrackerSparqlCursor *cursor,
+          gint                 column,
+          GrlMedia            *media,
+          GrlKeyID             key)
+{
+  const gchar *str = tracker_sparql_cursor_get_string (cursor, column, NULL);
+  if (key == GRL_METADATA_KEY_CREATION_DATE)
+    grl_media_set_creation_date_from_iso8601 (media, str);
+  else if (key == GRL_METADATA_KEY_MODIFICATION_DATE)
+    grl_media_set_modification_date_from_iso8601 (media, str);
+}
+
 static tracker_grl_sparql_t *
 insert_key_mapping (GrlKeyID     grl_key,
                     const gchar *sparql_key_attr,
@@ -179,10 +192,11 @@ grl_tracker_setup_key_mappings (void)
                       "nfo:entryCounter(?urn)",
                       "directory");
 
-  insert_key_mapping (GRL_METADATA_KEY_DATE,
-                      "nfo:fileLastModified",
-                      "nfo:fileLastModified(?urn)",
-                      "file");
+  insert_key_mapping_with_setter (GRL_METADATA_KEY_MODIFICATION_DATE,
+                                  "nfo:fileLastModified",
+                                  "nfo:fileLastModified(?urn)",
+                                  "file",
+                                  set_date);
 
   insert_key_mapping (GRL_METADATA_KEY_DURATION,
                       "nfo:duration",
@@ -248,10 +262,11 @@ grl_tracker_setup_key_mappings (void)
                       "nmm:episodeNumber(?urn)",
                       "video");
 
-  insert_key_mapping (GRL_METADATA_KEY_CREATION_DATE,
-                      "nie:contentCreated",
-                      "nie:contentCreated(?urn)",
-                      "image");
+  insert_key_mapping_with_setter (GRL_METADATA_KEY_CREATION_DATE,
+                                  "nie:contentCreated",
+                                  "nie:contentCreated(?urn)",
+                                  "image",
+                                  set_date);
 
   insert_key_mapping (GRL_METADATA_KEY_CAMERA_MODEL,
                       NULL,
-- 
1.7.4.1



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