[PATCH 10/11] vimeo: updated to new date format
- From: Guillaume Emont <guijemont igalia com>
- To: grilo-list gnome org
- Cc: Guillaume Emont <guijemont igalia com>
- Subject: [PATCH 10/11] vimeo: updated to new date format
- Date: Wed, 22 Jun 2011 19:13:55 +0200
---
src/media/vimeo/grl-vimeo.c | 37 +++++++++++++++----------------------
1 files changed, 15 insertions(+), 22 deletions(-)
diff --git a/src/media/vimeo/grl-vimeo.c b/src/media/vimeo/grl-vimeo.c
index 42edc8b..4e1ecf6 100644
--- a/src/media/vimeo/grl-vimeo.c
+++ b/src/media/vimeo/grl-vimeo.c
@@ -30,6 +30,7 @@
#include <grilo.h>
#include <string.h>
#include <stdlib.h>
+#include <stdio.h>
#include <errno.h>
#include "grl-vimeo.h"
@@ -194,27 +195,19 @@ str_to_gint (gchar *str)
return 0;
}
-static gchar *
-str_to_iso8601 (gchar *str)
+static GDateTime *
+parse_date (const gchar *date)
{
- gchar **date;
- gchar *iso8601_date;
-
- date = g_strsplit (str, " ", -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);
+ /* code duplicated from the flickr plugin until we find a better place for
+ * it.*/
+ guint year, month, day, hours, minutes;
+ gdouble seconds;
- return iso8601_date;
-}
+ sscanf (date, "%u-%u-%u %u:%u:%lf",
+ &year, &month, &day, &hours, &minutes, &seconds);
+ return g_date_time_new_utc (year, month, day, hours, minutes, seconds);
+}
static void
update_media (GrlMedia *media, GHashTable *video)
@@ -254,10 +247,10 @@ update_media (GrlMedia *media, GHashTable *video)
str = g_hash_table_lookup (video, VIMEO_VIDEO_UPLOAD_DATE);
if (str)
{
- gchar *date = str_to_iso8601(str);
+ GDateTime *date = parse_date (str);
if (date) {
- grl_media_set_date (media, date);
- g_free (date);
+ grl_media_set_publication_date (media, date);
+ g_date_time_unref (date);
}
}
@@ -367,7 +360,7 @@ grl_vimeo_source_supported_keys (GrlMetadataSource *source)
GRL_METADATA_KEY_DESCRIPTION,
GRL_METADATA_KEY_URL,
GRL_METADATA_KEY_AUTHOR,
- GRL_METADATA_KEY_DATE,
+ GRL_METADATA_KEY_PUBLICATION_DATE,
GRL_METADATA_KEY_THUMBNAIL,
GRL_METADATA_KEY_DURATION,
GRL_METADATA_KEY_WIDTH,
--
1.7.4.1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]