[rygel] core: Use date from DIDL in CreateObject
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core: Use date from DIDL in CreateObject
- Date: Tue, 21 Feb 2012 13:50:13 +0000 (UTC)
commit c39162c62cd28d75cf07f88e6e7314383cc62730
Author: Jens Georg <mail jensge org>
Date: Tue Feb 21 11:36:38 2012 +0200
core: Use date from DIDL in CreateObject
src/rygel/rygel-item-creator.vala | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/src/rygel/rygel-item-creator.vala b/src/rygel/rygel-item-creator.vala
index facd73a..4caec90 100644
--- a/src/rygel/rygel-item-creator.vala
+++ b/src/rygel/rygel-item-creator.vala
@@ -391,6 +391,43 @@ internal class Rygel.ItemCreator: GLib.Object, Rygel.StateMachine {
}
this.item.id = this.item.uris[0];
+
+ this.parse_and_verify_didl_date ();
+ }
+
+ private void parse_and_verify_didl_date () throws Error {
+ if (this.didl_item.date == null) {
+ return;
+ }
+
+ var parsed_date = new Soup.Date.from_string (this.didl_item.date);
+ if (parsed_date != null) {
+ this.item.date = parsed_date.to_string (Soup.DateFormat.ISO8601);
+
+ return;
+ }
+
+ int year = 0, month = 0, day = 0;
+
+ if (this.didl_item.date.scanf ("%4d-%02d-%02d",
+ out year,
+ out month,
+ out day) != 3) {
+ throw new ContentDirectoryError.BAD_METADATA
+ ("Invalid date format: %s",
+ this.didl_item.date);
+ }
+
+ var date = GLib.Date ();
+ date.set_dmy ((DateDay) day, (DateMonth) month, (DateYear) year);
+
+ if (!date.valid ()) {
+ throw new ContentDirectoryError.BAD_METADATA
+ ("Invalid date: %s",
+ this.didl_item.date);
+ }
+
+ this.item.date = this.didl_item.date + "T00:00:00";
}
private MediaItem create_item (string id,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]