[tracker/version-macros: 4/9] tracker-extract-gstramer, gupnp-dlna: Use GST_DATE_TIME if available
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/version-macros: 4/9] tracker-extract-gstramer, gupnp-dlna: Use GST_DATE_TIME if available
- Date: Thu, 31 Mar 2011 19:30:44 +0000 (UTC)
commit 1214b18de6711d1a37ad04f3206d4ac01d72407d
Author: Jürg Billeter <j bitron ch>
Date: Thu Mar 31 16:27:35 2011 +0200
tracker-extract-gstramer, gupnp-dlna: Use GST_DATE_TIME if available
GST_DATE tag does not provide time information.
Fixes NB#241833.
src/tracker-extract/tracker-extract-gstreamer.c | 34 +++++++++++++++-------
src/tracker-extract/tracker-extract-gupnp-dlna.c | 34 +++++++++++++++-------
2 files changed, 46 insertions(+), 22 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index 3b66086..44746e9 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -280,19 +280,34 @@ add_fraction_gst_tag (TrackerSparqlBuilder *metadata,
}
static void
-add_y_date_gst_tag (TrackerSparqlBuilder *metadata,
- const gchar *uri,
- const gchar *key,
- GstTagList *tag_list,
- const gchar *tag)
+add_date_time_gst_tag (TrackerSparqlBuilder *metadata,
+ const gchar *uri,
+ const gchar *key,
+ GstTagList *tag_list,
+ const gchar *tag_date_time,
+ const gchar *tag_date)
{
+ GstDateTime *date_time;
GDate *date;
gchar buf[25];
+ date_time = NULL;
date = NULL;
buf[0] = '\0';
- if (gst_tag_list_get_date (tag_list, tag, &date)) {
+ if (gst_tag_list_get_date_time (tag_list, tag_date_time, &date_time)) {
+ snprintf (buf, sizeof (buf), "%04d-%02d-%02dT%02d:%02d:%02d%s%02d00",
+ gst_date_time_get_year (date_time),
+ gst_date_time_get_month (date_time),
+ gst_date_time_get_day (date_time),
+ gst_date_time_get_hour (date_time),
+ gst_date_time_get_minute (date_time),
+ gst_date_time_get_second (date_time),
+ gst_date_time_get_time_zone_offset (date_time) >= 0 ? "+" : "",
+ (int) gst_date_time_get_time_zone_offset (date_time));
+
+ gst_date_time_unref (date_time);
+ } else if (gst_tag_list_get_date (tag_list, tag_date, &date)) {
gboolean ret;
if (date && g_date_valid (date)) {
@@ -305,10 +320,7 @@ add_y_date_gst_tag (TrackerSparqlBuilder *metadata,
}
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);
- }
+ g_date_strftime (buf, sizeof (buf), "%Y-%m-%dT%H:%M:%S%z", date);
}
}
@@ -788,7 +800,7 @@ extract_metadata (MetadataExtractor *extractor,
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);
- add_y_date_gst_tag (metadata, uri, "nie:contentCreated", extractor->tagcache, GST_TAG_DATE);
+ add_date_time_gst_tag (metadata, uri, "nie:contentCreated", extractor->tagcache, GST_TAG_DATE_TIME, GST_TAG_DATE);
add_string_gst_tag (metadata, uri, "nie:comment", extractor->tagcache, GST_TAG_COMMENT);
gst_tag_list_get_string (extractor->tagcache, GST_TAG_DEVICE_MODEL, &model);
diff --git a/src/tracker-extract/tracker-extract-gupnp-dlna.c b/src/tracker-extract/tracker-extract-gupnp-dlna.c
index aacd0da..6af134c 100644
--- a/src/tracker-extract/tracker-extract-gupnp-dlna.c
+++ b/src/tracker-extract/tracker-extract-gupnp-dlna.c
@@ -195,19 +195,34 @@ add_double_gst_tag (TrackerSparqlBuilder *metadata,
}
static void
-add_y_date_gst_tag (TrackerSparqlBuilder *metadata,
- const gchar *uri,
- const gchar *key,
- GstTagList *tag_list,
- const gchar *tag)
+add_date_time_gst_tag (TrackerSparqlBuilder *metadata,
+ const gchar *uri,
+ const gchar *key,
+ GstTagList *tag_list,
+ const gchar *tag_date_time,
+ const gchar *tag_date)
{
+ GstDateTime *date_time;
GDate *date;
gchar buf[25];
+ date_time = NULL;
date = NULL;
buf[0] = '\0';
- if (gst_tag_list_get_date (tag_list, tag, &date)) {
+ if (gst_tag_list_get_date_time (tag_list, tag_date_time, &date_time)) {
+ snprintf (buf, sizeof (buf), "%04d-%02d-%02dT%02d:%02d:%02d%s%02d00",
+ gst_date_time_get_year (date_time),
+ gst_date_time_get_month (date_time),
+ gst_date_time_get_day (date_time),
+ gst_date_time_get_hour (date_time),
+ gst_date_time_get_minute (date_time),
+ gst_date_time_get_second (date_time),
+ gst_date_time_get_time_zone_offset (date_time) >= 0 ? "+" : "",
+ (int) gst_date_time_get_time_zone_offset (date_time));
+
+ gst_date_time_unref (date_time);
+ } else if (gst_tag_list_get_date (tag_list, tag_date, &date)) {
gboolean ret;
if (date && g_date_valid (date)) {
@@ -220,10 +235,7 @@ add_y_date_gst_tag (TrackerSparqlBuilder *metadata,
}
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);
- }
+ g_date_strftime (buf, sizeof (buf), "%Y-%m-%dT%H:%M:%S%z", date);
}
}
@@ -534,7 +546,7 @@ extract_metadata (MetadataExtractor *extractor,
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);
add_string_gst_tag (metadata, uri, "dc:coverage", extractor->tags, GST_TAG_LOCATION);
- add_y_date_gst_tag (metadata, uri, "nie:contentCreated", extractor->tags, GST_TAG_DATE);
+ add_date_time_gst_tag (metadata, uri, "nie:contentCreated", extractor->tags, GST_TAG_DATE_TIME, GST_TAG_DATE);
add_string_gst_tag (metadata, uri, "nie:comment", extractor->tags, GST_TAG_COMMENT);
gst_tag_list_get_string (extractor->tags, GST_TAG_DEVICE_MODEL, &model);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]