[PATCH 03/11] upnp: updated to new date format



---
 src/media/upnp/grl-upnp.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/media/upnp/grl-upnp.c b/src/media/upnp/grl-upnp.c
index 88048aa..6090766 100644
--- a/src/media/upnp/grl-upnp.c
+++ b/src/media/upnp/grl-upnp.c
@@ -549,10 +549,10 @@ setup_key_mappings (void)
   g_hash_table_insert (key_mapping, GRLKEYID_TO_POINTER (GRL_METADATA_KEY_ALBUM), "album");
   g_hash_table_insert (key_mapping, GRLKEYID_TO_POINTER (GRL_METADATA_KEY_GENRE), "genre");
   g_hash_table_insert (key_mapping, GRLKEYID_TO_POINTER (GRL_METADATA_KEY_URL), "res");
-  g_hash_table_insert (key_mapping, GRLKEYID_TO_POINTER (GRL_METADATA_KEY_DATE), "modified");
+  g_hash_table_insert (key_mapping, GRLKEYID_TO_POINTER (GRL_METADATA_KEY_MODIFICATION_DATE), "modified");
   g_hash_table_insert (filter_key_mapping, GRLKEYID_TO_POINTER (GRL_METADATA_KEY_TITLE), "title");
   g_hash_table_insert (filter_key_mapping, GRLKEYID_TO_POINTER (GRL_METADATA_KEY_URL), "res");
-  g_hash_table_insert (filter_key_mapping, GRLKEYID_TO_POINTER (GRL_METADATA_KEY_DATE), "dc:date");
+  g_hash_table_insert (filter_key_mapping, GRLKEYID_TO_POINTER (GRL_METADATA_KEY_CREATION_DATE), "dc:date");
   g_hash_table_insert (filter_key_mapping, GRLKEYID_TO_POINTER (GRL_METADATA_KEY_ARTIST), "upnp:artist");
   g_hash_table_insert (filter_key_mapping, GRLKEYID_TO_POINTER (GRL_METADATA_KEY_ALBUM), "upnp:album");
   g_hash_table_insert (filter_key_mapping, GRLKEYID_TO_POINTER (GRL_METADATA_KEY_GENRE), "upnp:genre");
@@ -795,7 +795,7 @@ get_value_for_key (GrlKeyID key_id,
                                 (const xmlChar *) "duration");
   } else if (key_id == GRL_METADATA_KEY_URL && props) {
     val = (gchar *) xmlNodeGetContent ((xmlNode *) props->data);
-  } else if (key_id == GRL_METADATA_KEY_DATE && props) {
+  } else if (key_id == GRL_METADATA_KEY_MODIFICATION_DATE && props) {
     val = g_strdup (gupnp_didl_lite_object_get_date (didl));
   } else if (key_id == GRL_METADATA_KEY_THUMBNAIL && props) {
     val = g_strdup (gupnp_didl_lite_object_get_album_art (didl));
@@ -816,10 +816,11 @@ get_value_for_key (GrlKeyID key_id,
 }
 
 static void
-set_metadata_value (GrlData *data,
+set_metadata_value (GrlMedia *media,
                     GrlKeyID key_id,
                     const gchar *value)
 {
+  GrlData *data = GRL_DATA (media);
   if (key_id == GRL_METADATA_KEY_DURATION) {
     gint duration = didl_h_mm_ss_to_int (value);
     if (duration >= 0) {
@@ -827,6 +828,10 @@ set_metadata_value (GrlData *data,
     }
   } else if (key_id == GRL_METADATA_KEY_CHILDCOUNT && value) {
     grl_data_set_int (data, GRL_METADATA_KEY_CHILDCOUNT, atoi (value));
+  } else if (key_id == GRL_METADATA_KEY_MODIFICATION_DATE) {
+    grl_media_set_modification_date_from_iso8601 (media, value);
+  } else if (key_id == GRL_METADATA_KEY_CREATION_DATE) {
+    grl_media_set_creation_date_from_iso8601 (media, value);
   } else {
     grl_data_set_string (data, key_id, value);
   }
@@ -887,7 +892,7 @@ build_media_from_didl (GrlMedia *content,
     GrlKeyID key = GRLPOINTER_TO_KEYID (iter->data);
     gchar *value = get_value_for_key (key, didl_node, didl_props);
     if (value) {
-      set_metadata_value (GRL_DATA (media), key, value);
+      set_metadata_value (media, key, value);
     }
     iter = g_list_next (iter);
   }
@@ -1065,7 +1070,8 @@ grl_upnp_source_supported_keys (GrlMetadataSource *source)
                                       GRL_METADATA_KEY_TITLE,
                                       GRL_METADATA_KEY_URL,
                                       GRL_METADATA_KEY_MIME,
-                                      GRL_METADATA_KEY_DATE,
+                                      GRL_METADATA_KEY_MODIFICATION_DATE,
+                                      GRL_METADATA_KEY_CREATION_DATE,
                                       GRL_METADATA_KEY_DURATION,
                                       GRL_METADATA_KEY_ARTIST,
                                       GRL_METADATA_KEY_ALBUM,
-- 
1.7.4.1



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