[grilo-plugins] vimeo: Handle wrong dates



commit 1006db54b1519ca7f5bb9d0f1e89506a228bfcd8
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Thu May 12 13:18:15 2011 +0200

    vimeo: Handle wrong dates
    
    When converting Vimeo's date to ISO8601 check that date is in good
    format.
    
    Signed-off-by: Juan A. Suarez Romero <jasuarez igalia com>

 src/media/vimeo/grl-vimeo.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/src/media/vimeo/grl-vimeo.c b/src/media/vimeo/grl-vimeo.c
index b4901b2..cd2b0f4 100644
--- a/src/media/vimeo/grl-vimeo.c
+++ b/src/media/vimeo/grl-vimeo.c
@@ -200,7 +200,15 @@ str_to_iso8601 (gchar *str)
   gchar *iso8601_date;
 
   date = g_strsplit (str, " ", -1);
-  iso8601_date = g_strdup_printf ("%sT%sZ", date[0], date[1]);
+  if (date[0]) {
+    if (date[1]) {
+      iso8601_date = g_strdup_printf ("%sT%sZ", date[0], date[1]);
+    } else {
+      iso8601_date = g_strdup_printf ("%sT", date[0]);
+    }
+  } else {
+    iso8601_date = NULL;
+  }
   g_strfreev (date);
 
   return iso8601_date;
@@ -246,8 +254,10 @@ update_media (GrlMedia *media, GHashTable *video)
   if (str)
   {
     gchar *date = str_to_iso8601(str);
-    grl_media_set_date (media, date);
-    g_free (date);
+    if (date) {
+      grl_media_set_date (media, date);
+      g_free (date);
+    }
   }
 
   str = g_hash_table_lookup (video, VIMEO_VIDEO_THUMBNAIL);



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