[grilo-plugins] tracker: Export gibest hash if available



commit 50498d11b626c6f868eb8b0abee92ad20348a9e3
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Mar 18 17:35:16 2014 +0100

    tracker: Export gibest hash if available
    
    If the gibest hash, used by OpenSubtitles, is available, export
    it so that we can use it to look up subtitles.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=701651

 src/tracker/grl-tracker-utils.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/src/tracker/grl-tracker-utils.c b/src/tracker/grl-tracker-utils.c
index 7c36f23..0d69428 100644
--- a/src/tracker/grl-tracker-utils.c
+++ b/src/tracker/grl-tracker-utils.c
@@ -36,6 +36,7 @@ static GHashTable *grl_to_sparql_mapping = NULL;
 static GHashTable *sparql_to_grl_mapping = NULL;
 
 GrlKeyID grl_metadata_key_tracker_urn;
+GrlKeyID grl_metadata_key_gibest_hash;
 
 
 /**/
@@ -189,6 +190,22 @@ grl_tracker_setup_key_mappings (void)
                                           NULL);
   }
 
+  /* Check if "gibest-hash" is registered; if not, then register it */
+  grl_metadata_key_gibest_hash =
+    grl_registry_lookup_metadata_key (registry, "gibest-hash");
+
+  if (grl_metadata_key_gibest_hash == GRL_METADATA_KEY_INVALID) {
+    grl_metadata_key_gibest_hash =
+      grl_registry_register_metadata_key (grl_registry_get_default (),
+                                          g_param_spec_string ("gibest-hash",
+                                                               "Gibest hash",
+                                                               "Gibest hash of the video file",
+                                                               NULL,
+                                                               G_PARAM_STATIC_STRINGS |
+                                                               G_PARAM_READWRITE),
+                                          NULL);
+  }
+
   grl_to_sparql_mapping = g_hash_table_new (g_direct_hash, g_direct_equal);
   sparql_to_grl_mapping = g_hash_table_new (g_str_hash, g_str_equal);
 
@@ -227,6 +244,11 @@ grl_tracker_setup_key_mappings (void)
                       "nfo:fileSize(?urn)",
                       "file");
 
+  insert_key_mapping (grl_metadata_key_gibest_hash,
+                      NULL,
+                      "(select nfo:hashValue(?h) { ?urn nfo:hasHash ?h . ?h nfo:hashAlgorithm \"gibest\" })",
+                      "video");
+
   insert_key_mapping_with_setter (GRL_METADATA_KEY_MODIFICATION_DATE,
                                   "nfo:fileLastModified",
                                   "nfo:fileLastModified(?urn)",


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