[grilo] core: Add generic metadata keys from TMDB



commit ae6327ba4a73bf426b6ec230491e9e7f6bf63121
Author: Mathias Hasselmann <mathias openismus com>
Date:   Tue Oct 23 22:44:10 2012 +0200

    core: Add generic metadata keys from TMDB
    
    The TMDB plugin defines a few new metadata keys of generic
    interest. They should be moved to Grilo's core to make such
    data easier to use once other sources should provide
    similiar information.
    
    This introduces following new keys together with generated
    GrlMedia accessors:
    
      * GRL_METADATA_KEY_KEYWORD
      * GRL_METADATA_KEY_PERFORMER
      * GRL_METADATA_KEY_PRODUCER
      * GRL_METADATA_KEY_DIRECTOR
      * GRL_METADATA_KEY_ORIGINAL_TITLE
    
    All keys are defined as strings and there are no relations
    between them. Except for "original-title" all of those keys
    are multi-valued. All keys but "keyword" are video specific
    keys.
    
    This fixes https://bugzilla.gnome.org/show_bug.cgi?id=686206
    
    Signed-off-by: Juan A. Suarez Romero <jasuarez igalia com>

 bindings/vala/grilo-0.2-custom.vala |   10 ++
 doc/grilo/grilo-sections.txt        |   18 +++
 src/data/grl-media-video.c          |  264 +++++++++++++++++++++++++++++++++++
 src/data/grl-media-video.h          |   38 +++++
 src/data/grl-media.c                |   79 +++++++++++
 src/data/grl-media.h                |    8 +
 src/grl-metadata-key.c              |   47 ++++++-
 src/grl-metadata-key.h              |    5 +
 8 files changed, 468 insertions(+), 1 deletions(-)
---
diff --git a/bindings/vala/grilo-0.2-custom.vala b/bindings/vala/grilo-0.2-custom.vala
index 165eac6..67506a7 100644
--- a/bindings/vala/grilo-0.2-custom.vala
+++ b/bindings/vala/grilo-0.2-custom.vala
@@ -100,6 +100,16 @@ namespace Grl {
 		public static Grl.KeyID MODIFICATION_DATE;
 		[CCode (cname ="GRL_METADATA_KEY_START_TIME")]
 		public static Grl.KeyID START_TIME;
+		[CCode (cname ="GRL_METADATA_KEY_KEYWORD")]
+		public static Grl.KeyID KEYWORD;
+		[CCode (cname ="GRL_METADATA_KEY_PERFORMER")]
+		public static Grl.KeyID PERFORMER;
+		[CCode (cname ="GRL_METADATA_KEY_PRODUCER")]
+		public static Grl.KeyID PRODUCER;
+		[CCode (cname ="GRL_METADATA_KEY_DIRECTOR")]
+		public static Grl.KeyID DIRECTOR;
+		[CCode (cname ="GRL_METADATA_KEY_ORIGINAL_TITLE")]
+		public static Grl.KeyID ORIGINAL_TITLE;
 
 		public static unowned GLib.List list_new (Grl.KeyID p, ...);
 	}
diff --git a/doc/grilo/grilo-sections.txt b/doc/grilo/grilo-sections.txt
index 7a42604..d571287 100644
--- a/doc/grilo/grilo-sections.txt
+++ b/doc/grilo/grilo-sections.txt
@@ -329,6 +329,7 @@ grl_media_new
 grl_media_add_author
 grl_media_add_external_player
 grl_media_add_external_url
+grl_media_add_keyword
 grl_media_add_region_data
 grl_media_add_thumbnail
 grl_media_add_thumbnail_binary
@@ -342,6 +343,8 @@ grl_media_get_duration
 grl_media_get_external_url
 grl_media_get_external_url_nth
 grl_media_get_id
+grl_media_get_keyword
+grl_media_get_keyword_nth
 grl_media_get_last_played
 grl_media_get_last_position
 grl_media_get_license
@@ -377,6 +380,7 @@ grl_media_set_duration
 grl_media_set_external_player
 grl_media_set_external_url
 grl_media_set_id
+grl_media_set_keyword
 grl_media_set_last_played
 grl_media_set_last_position
 grl_media_set_license
@@ -476,18 +480,32 @@ grl_media_box_get_type
 GrlMediaVideo
 GrlMediaVideoClass
 grl_media_video_new
+grl_media_video_add_director
+grl_media_video_add_performer
+grl_media_video_add_producer
 grl_media_video_add_url_data
+grl_media_video_get_director
+grl_media_video_get_director_nth
 grl_media_video_get_episode
 grl_media_video_get_framerate
 grl_media_video_get_height
+grl_media_video_get_original_title
+grl_media_video_get_performer
+grl_media_video_get_performer_nth
+grl_media_video_get_producer
+grl_media_video_get_producer_nth
 grl_media_video_get_season
 grl_media_video_get_show
 grl_media_video_get_url_data
 grl_media_video_get_url_data_nth
 grl_media_video_get_width
+grl_media_video_set_director
 grl_media_video_set_episode
 grl_media_video_set_framerate
 grl_media_video_set_height
+grl_media_video_set_original_title
+grl_media_video_set_performer
+grl_media_video_set_producer
 grl_media_video_set_season
 grl_media_video_set_show
 grl_media_video_set_size
diff --git a/src/data/grl-media-video.c b/src/data/grl-media-video.c
index 77c7929..7d2815c 100644
--- a/src/data/grl-media-video.c
+++ b/src/data/grl-media-video.c
@@ -430,3 +430,267 @@ grl_media_video_get_url_data_nth (GrlMediaVideo *video,
 
   return grl_related_keys_get_string (relkeys, GRL_METADATA_KEY_URL);
 }
+
+/**
+ * grl_media_video_set_performer:
+ * @video: a #GrlMediaVideo
+ * @performer: an actor performing in the movie
+ *
+ * Sets the actor performing in the movie.
+ *
+ * Since: 0.2.3
+ */
+void
+grl_media_video_set_performer (GrlMediaVideo *video,
+                               const gchar *performer)
+{
+  grl_data_set_string (GRL_DATA (video),
+                       GRL_METADATA_KEY_PERFORMER,
+                       performer);
+}
+
+/**
+ * grl_media_video_add_performer:
+ * @video: a #GrlMediaVideo
+ * @performer: an actor performing in the movie
+ *
+ * Adds the actor performing in the movie.
+ *
+ * Since: 0.2.3
+ */
+void
+grl_media_video_add_performer (GrlMediaVideo *video,
+                               const gchar *performer)
+{
+  grl_data_add_string (GRL_DATA (video),
+                       GRL_METADATA_KEY_PERFORMER,
+                       performer);
+}
+
+/**
+ * grl_media_video_get_performer:
+ * @video: a #GrlMediaVideo
+ *
+ * Returns: (transfer none): the actor performing in the movie (owned by @video).
+ *
+ * Since: 0.2.3
+ */
+const gchar *
+grl_media_video_get_performer (GrlMediaVideo *video)
+{
+  return grl_data_get_string (GRL_DATA (video),
+                              GRL_METADATA_KEY_PERFORMER);
+}
+
+/**
+ * grl_media_video_get_performer_nth:
+ * @video: a #GrlMediaVideo
+ * @index: element to retrieve
+ *
+ * Returns: (transfer none): the actor performing in the movie (owned by @video).
+ *
+ * Since: 0.2.3
+ */
+const gchar *
+grl_media_video_get_performer_nth (GrlMediaVideo *video,
+                                   guint index)
+{
+  GrlRelatedKeys *const relkeys =
+    grl_data_get_related_keys (GRL_DATA (video),
+                               GRL_METADATA_KEY_PERFORMER,
+                               index);
+
+  if (!relkeys) {
+    return NULL;
+  }
+
+  return grl_related_keys_get_string (relkeys,
+                                      GRL_METADATA_KEY_PERFORMER);
+}
+
+/**
+ * grl_media_video_set_producer:
+ * @video: a #GrlMediaVideo
+ * @producer: producer of the movie
+ *
+ * Sets the producer of the movie.
+ *
+ * Since: 0.2.3
+ */
+void
+grl_media_video_set_producer (GrlMediaVideo *video,
+                              const gchar *producer)
+{
+  grl_data_set_string (GRL_DATA (video),
+                       GRL_METADATA_KEY_PRODUCER,
+                       producer);
+}
+
+/**
+ * grl_media_video_add_producer:
+ * @video: a #GrlMediaVideo
+ * @producer: producer of the movie
+ *
+ * Adds the producer of the movie.
+ *
+ * Since: 0.2.3
+ */
+void
+grl_media_video_add_producer (GrlMediaVideo *video,
+                              const gchar *producer)
+{
+  grl_data_add_string (GRL_DATA (video),
+                       GRL_METADATA_KEY_PRODUCER,
+                       producer);
+}
+
+/**
+ * grl_media_video_get_producer:
+ * @video: a #GrlMediaVideo
+ *
+ * Returns: (transfer none): the producer of the movie (owned by @video).
+ *
+ * Since: 0.2.3
+ */
+const gchar *
+grl_media_video_get_producer (GrlMediaVideo *video)
+{
+  return grl_data_get_string (GRL_DATA (video),
+                              GRL_METADATA_KEY_PRODUCER);
+}
+
+/**
+ * grl_media_video_get_producer_nth:
+ * @video: a #GrlMediaVideo
+ * @index: element to retrieve
+ *
+ * Returns: (transfer none): the producer of the movie (owned by @video).
+ *
+ * Since: 0.2.3
+ */
+const gchar *
+grl_media_video_get_producer_nth (GrlMediaVideo *video,
+                                  guint index)
+{
+  GrlRelatedKeys *const relkeys =
+    grl_data_get_related_keys (GRL_DATA (video),
+                               GRL_METADATA_KEY_PRODUCER,
+                               index);
+
+  if (!relkeys) {
+    return NULL;
+  }
+
+  return grl_related_keys_get_string (relkeys,
+                                      GRL_METADATA_KEY_PRODUCER);
+}
+
+/**
+ * grl_media_video_set_director:
+ * @video: a #GrlMediaVideo
+ * @director: director of the movie
+ *
+ * Sets the director of the movie.
+ *
+ * Since: 0.2.3
+ */
+void
+grl_media_video_set_director (GrlMediaVideo *video,
+                              const gchar *director)
+{
+  grl_data_set_string (GRL_DATA (video),
+                       GRL_METADATA_KEY_DIRECTOR,
+                       director);
+}
+
+/**
+ * grl_media_video_add_director:
+ * @video: a #GrlMediaVideo
+ * @director: director of the movie
+ *
+ * Adds the director of the movie.
+ *
+ * Since: 0.2.3
+ */
+void
+grl_media_video_add_director (GrlMediaVideo *video,
+                              const gchar *director)
+{
+  grl_data_add_string (GRL_DATA (video),
+                       GRL_METADATA_KEY_DIRECTOR,
+                       director);
+}
+
+/**
+ * grl_media_video_get_director:
+ * @video: a #GrlMediaVideo
+ *
+ * Returns: (transfer none): the director of the movie (owned by @video).
+ *
+ * Since: 0.2.3
+ */
+const gchar *
+grl_media_video_get_director (GrlMediaVideo *video)
+{
+  return grl_data_get_string (GRL_DATA (video),
+                              GRL_METADATA_KEY_DIRECTOR);
+}
+
+/**
+ * grl_media_video_get_director_nth:
+ * @video: a #GrlMediaVideo
+ * @index: element to retrieve
+ *
+ * Returns: (transfer none): the director of the movie (owned by @video).
+ *
+ * Since: 0.2.3
+ */
+const gchar *
+grl_media_video_get_director_nth (GrlMediaVideo *video,
+                                  guint index)
+{
+  GrlRelatedKeys *const relkeys =
+    grl_data_get_related_keys (GRL_DATA (video),
+                               GRL_METADATA_KEY_DIRECTOR,
+                               index);
+
+  if (!relkeys) {
+    return NULL;
+  }
+
+  return grl_related_keys_get_string (relkeys,
+                                      GRL_METADATA_KEY_DIRECTOR);
+}
+
+/**
+ * grl_media_video_set_original_title:
+ * @video: a #GrlMediaVideo
+ * @original_title: original, untranslated title of the movie
+ *
+ * Sets the original, untranslated title of the movie.
+ *
+ * Since: 0.2.3
+ */
+void
+grl_media_video_set_original_title (GrlMediaVideo *video,
+                                    const gchar *original_title)
+{
+  grl_data_set_string (GRL_DATA (video),
+                       GRL_METADATA_KEY_ORIGINAL_TITLE,
+                       original_title);
+}
+
+/**
+ * grl_media_video_get_original_title:
+ * @video: a #GrlMediaVideo
+ *
+ * Returns: (transfer none): the original, untranslated title of the movie (owned by @video).
+ *
+ * Since: 0.2.3
+ */
+const gchar *
+grl_media_video_get_original_title (GrlMediaVideo *video)
+{
+  return grl_data_get_string (GRL_DATA (video),
+                              GRL_METADATA_KEY_ORIGINAL_TITLE);
+}
diff --git a/src/data/grl-media-video.h b/src/data/grl-media-video.h
index 4013b7a..c218ea2 100644
--- a/src/data/grl-media-video.h
+++ b/src/data/grl-media-video.h
@@ -144,6 +144,44 @@ const gchar *grl_media_video_get_url_data_nth (GrlMediaVideo *video,
                                                gint *width,
                                                gint *height);
 
+void grl_media_video_set_performer (GrlMediaVideo *video,
+                                    const gchar *performer);
+
+void grl_media_video_add_performer (GrlMediaVideo *video,
+                                    const gchar *performer);
+
+const gchar * grl_media_video_get_performer (GrlMediaVideo *video);
+
+const gchar * grl_media_video_get_performer_nth (GrlMediaVideo *video,
+                                                 guint index);
+
+void grl_media_video_set_producer (GrlMediaVideo *video,
+                                   const gchar *producer);
+
+void grl_media_video_add_producer (GrlMediaVideo *video,
+                                   const gchar *producer);
+
+const gchar * grl_media_video_get_producer (GrlMediaVideo *video);
+
+const gchar * grl_media_video_get_producer_nth (GrlMediaVideo *video,
+                                                guint index);
+
+void grl_media_video_set_director (GrlMediaVideo *video,
+                                   const gchar *director);
+
+void grl_media_video_add_director (GrlMediaVideo *video,
+                                   const gchar *director);
+
+const gchar * grl_media_video_get_director (GrlMediaVideo *video);
+
+const gchar * grl_media_video_get_director_nth (GrlMediaVideo *video,
+                                                guint index);
+
+void grl_media_video_set_original_title (GrlMediaVideo *video,
+                                         const gchar *original_title);
+
+const gchar * grl_media_video_get_original_title (GrlMediaVideo *video);
+
 G_END_DECLS
 
 #endif /* _GRL_MEDIA_VIDEO_H_ */
diff --git a/src/data/grl-media.c b/src/data/grl-media.c
index b88a70e..07a8d1d 100644
--- a/src/data/grl-media.c
+++ b/src/data/grl-media.c
@@ -237,6 +237,24 @@ grl_media_add_external_url (GrlMedia *media, const gchar *url)
 }
 
 /**
+ * grl_media_add_keyword:
+ * @media: a #GrlMedia
+ * @keyword: a keyword describing the media
+ *
+ * Adds the keyword describing the @media.
+ *
+ * Since: 0.2.3
+ */
+void
+grl_media_add_keyword (GrlMedia *media,
+                       const gchar *keyword)
+{
+  grl_data_add_string (GRL_DATA (media),
+                       GRL_METADATA_KEY_KEYWORD,
+                       keyword);
+}
+
+/**
  * grl_media_serialize:
  * @media: a #GrlMedia
  *
@@ -963,6 +981,7 @@ grl_media_set_license (GrlMedia *media, const gchar *license)
  *
  * Set if the media is favourite or not
  *
+ * Since: 0.2.3
  */
 void
 grl_media_set_favourite (GrlMedia *media, gboolean favourite)
@@ -973,6 +992,24 @@ grl_media_set_favourite (GrlMedia *media, gboolean favourite)
 }
 
 /**
+ * grl_media_set_keyword:
+ * @media: a #GrlMedia
+ * @keyword: a keyword describing the media
+ *
+ * Sets the keyword describing the @media.
+ *
+ * Since: 0.2.3
+ */
+void
+grl_media_set_keyword (GrlMedia *media,
+                       const gchar *keyword)
+{
+  grl_data_set_string (GRL_DATA (media),
+                       GRL_METADATA_KEY_KEYWORD,
+                       keyword);
+}
+
+/**
  * grl_media_get_id:
  * @media: the media object
  *
@@ -1566,9 +1603,51 @@ grl_media_get_start_time (GrlMedia *media)
  *
  * Returns: whether the media is favourite or not
  *
+ * Since: 0.2.3
  */
 gboolean
 grl_media_get_favourite (GrlMedia *media)
 {
   return grl_data_get_boolean (GRL_DATA (media), GRL_METADATA_KEY_FAVOURITE);
 }
+
+/**
+ * grl_media_get_keyword:
+ * @media: a #GrlMedia
+ *
+ * Returns: (transfer none): the keyword describing the @media (owned by @media).
+ *
+ * Since: 0.2.3
+ */
+const gchar *
+grl_media_get_keyword (GrlMedia *media)
+{
+  return grl_data_get_string (GRL_DATA (media),
+                              GRL_METADATA_KEY_KEYWORD);
+}
+
+/**
+ * grl_media_get_keyword_nth:
+ * @media: a #GrlMedia
+ * @index: element to retrieve
+ *
+ * Returns: (transfer none): the keyword describing the @media (owned by @media).
+ *
+ * Since: 0.2.3
+ */
+const gchar *
+grl_media_get_keyword_nth (GrlMedia *media,
+                           guint index)
+{
+  GrlRelatedKeys *const relkeys =
+    grl_data_get_related_keys (GRL_DATA (media),
+                               GRL_METADATA_KEY_KEYWORD,
+                               index);
+
+  if (!relkeys) {
+    return NULL;
+  }
+
+  return grl_related_keys_get_string (relkeys,
+                                      GRL_METADATA_KEY_KEYWORD);
+}
diff --git a/src/data/grl-media.h b/src/data/grl-media.h
index 10b049a..5191b19 100644
--- a/src/data/grl-media.h
+++ b/src/data/grl-media.h
@@ -164,6 +164,8 @@ void grl_media_set_url_data (GrlMedia *media, const gchar *url, const gchar *mim
 
 void grl_media_set_favourite (GrlMedia *media, gboolean favourite);
 
+void grl_media_set_keyword (GrlMedia *media, const gchar *keyword);
+
 void grl_media_add_url_data (GrlMedia *media, const gchar *url, const gchar *mime);
 
 void grl_media_add_author (GrlMedia *media, const gchar *author);
@@ -176,6 +178,8 @@ void grl_media_add_external_player (GrlMedia *media, const gchar *player);
 
 void grl_media_add_external_url (GrlMedia *media, const gchar *url);
 
+void grl_media_add_keyword (GrlMedia *media, const gchar *keyword);
+
 const gchar *grl_media_get_id (GrlMedia *media);
 
 const gchar *grl_media_get_url (GrlMedia *media);
@@ -251,6 +255,10 @@ gfloat grl_media_get_start_time (GrlMedia *media);
 
 gboolean grl_media_get_favourite (GrlMedia *media);
 
+const gchar *grl_media_get_keyword (GrlMedia *media);
+
+const gchar * grl_media_get_keyword_nth (GrlMedia *media, guint index);
+
 GType grl_media_get_type (void) G_GNUC_CONST;
 
 GrlMedia *grl_media_new (void);
diff --git a/src/grl-metadata-key.c b/src/grl-metadata-key.c
index 430e2d5..2af318b 100644
--- a/src/grl-metadata-key.c
+++ b/src/grl-metadata-key.c
@@ -422,7 +422,7 @@ grl_metadata_key_setup_system_keys (GrlRegistry *registry)
   grl_registry_register_metadata_key_full (registry,
                                            g_param_spec_int ("track-number",
                                                              "Track number",
-                                                             "Track number  inside the album",
+                                                             "Track number inside the album",
                                                              1, G_MAXINT,
                                                              1,
                                                              G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE),
@@ -466,6 +466,51 @@ grl_metadata_key_setup_system_keys (GrlRegistry *registry)
                                            GRL_METADATA_KEY_REGION,
                                            NULL);
 
+  grl_registry_register_metadata_key_full (registry,
+                                           g_param_spec_string ("keyword",
+                                                                "keyword",
+                                                                "A keyword describing the media",
+                                                                NULL,
+                                                                G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE),
+                                           GRL_METADATA_KEY_KEYWORD,
+                                           NULL);
+
+  grl_registry_register_metadata_key_full (registry,
+                                           g_param_spec_string ("performer",
+                                                                "performer",
+                                                                "An actor performing in the movie",
+                                                                NULL,
+                                                                G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE),
+                                           GRL_METADATA_KEY_PERFORMER,
+                                           NULL);
+
+  grl_registry_register_metadata_key_full (registry,
+                                           g_param_spec_string ("producer",
+                                                                "Producer",
+                                                                "Producer of the movie",
+                                                                NULL,
+                                                                G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE),
+                                           GRL_METADATA_KEY_PRODUCER,
+                                           NULL);
+
+  grl_registry_register_metadata_key_full (registry,
+                                           g_param_spec_string ("director",
+                                                                "Director",
+                                                                "Director of the movie",
+                                                                NULL,
+                                                                G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE),
+                                           GRL_METADATA_KEY_DIRECTOR,
+                                           NULL);
+
+  grl_registry_register_metadata_key_full (registry,
+                                           g_param_spec_string ("original-title",
+                                                                "Original Title",
+                                                                "Original, untranslated title of the movie",
+                                                                NULL,
+                                                                G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE),
+                                           GRL_METADATA_KEY_ORIGINAL_TITLE,
+                                           NULL);
+
   /* Create the relations */
   grl_registry_register_metadata_key_relation (registry,
                                                GRL_METADATA_KEY_URL,
diff --git a/src/grl-metadata-key.h b/src/grl-metadata-key.h
index 3009886..1880be1 100644
--- a/src/grl-metadata-key.h
+++ b/src/grl-metadata-key.h
@@ -91,6 +91,11 @@ typedef guint32 GrlKeyID;
 #define GRL_METADATA_KEY_START_TIME           42
 #define GRL_METADATA_KEY_FAVOURITE            43
 #define GRL_METADATA_KEY_REGION               44
+#define GRL_METADATA_KEY_KEYWORD              45
+#define GRL_METADATA_KEY_PERFORMER            46
+#define GRL_METADATA_KEY_PRODUCER             47
+#define GRL_METADATA_KEY_DIRECTOR             48
+#define GRL_METADATA_KEY_ORIGINAL_TITLE       49
 
 G_BEGIN_DECLS
 



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