]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
api epg: Send credit (cast), category, and keyword information to the GUI and display...
authorE.Smith <31170571+azlm8t@users.noreply.github.com>
Wed, 20 Sep 2017 01:22:52 +0000 (02:22 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 9 Oct 2017 14:15:05 +0000 (16:15 +0200)
src/api/api_epg.c
src/webui/static/app/epg.js

index cd85c6b226f8526722723c5abf4b74e1f1a36e44..c9c5e17ff23b32a1643e170392fc7c2e7a88e612 100644 (file)
@@ -25,6 +25,7 @@
 #include "imagecache.h"
 #include "dvr/dvr.h"
 #include "lang_codes.h"
+#include "string_list.h"
 
 static htsmsg_t *
 api_epg_get_list ( const char *s )
@@ -119,6 +120,15 @@ api_epg_entry ( epg_broadcast_t *eb, const char *lang, access_t *perm, const cha
     htsmsg_add_str(m, "summary", s);
   if ((s = epg_broadcast_get_description(eb, lang)))
     htsmsg_add_str(m, "description", s);
+  if (eb->credits) {
+    htsmsg_add_msg(m, "credits", htsmsg_copy(eb->credits));
+  }
+  if (eb->category) {
+    htsmsg_add_msg(m, "category", string_list_to_htsmsg(eb->category));
+  }
+  if (eb->keyword) {
+    htsmsg_add_msg(m, "keyword", string_list_to_htsmsg(eb->keyword));
+  }
 
   if (eb->is_new)
     htsmsg_add_u32(m, "new", eb->is_new);
index af3bb2293129f053741e87da1a27a51ce5e6dd92..09180afc2c56b5923433b8d5532fccda3f82c467 100644 (file)
@@ -129,6 +129,54 @@ tvheadend.epgDetails = function(event) {
       content += '<div class="x-epg-desc">' + event.description + '</div>';
     if (event.summary || event.description)
       content += '<hr class="x-epg-hr"/>';
+
+    // Helper function for common code to sort an array, convert to CSV and
+    // return the string to add to the content.
+    function sortAndAddArray(arr, title) {
+      arr.sort();
+      var csv = arr.join(", ");
+      if (csv)
+        return '<div class="x-epg-meta"><span class="x-epg-prefix">' + title + ':</span><span class="x-epg-body">' + csv + '</span></div>';
+      else
+        return '';
+    }
+
+    if (event.credits) {
+      // Our cast (credits) map contains details of actors, writers,
+      // etc. so split in to separate categories for displaying.
+      var castArr = [];
+      var crewArr = [];
+      var directorArr = [];
+      var writerArr = [];
+      var cast = ["actor", "guest", "presenter"];
+      // We use arrays here in case more tags in the future map on to
+      // director/writer, e.g., SchedulesDirect breaks it down in to
+      // writer, writer (adaptation) writer (screenplay), etc. but
+      // currently we just have them all as writer.
+      var director = ["director"];
+      var writer = ["writer"];
+
+      for (key in event.credits) {
+        var type = event.credits[key];
+        if (cast.indexOf(type) != -1)
+          castArr.push(key);
+        else if (director.indexOf(type) != -1)
+          directorArr.push(key);
+        else if (writer.indexOf(type) != -1)
+          writerArr.push(key);
+        else
+          crewArr.push(key);
+      };
+
+      content += sortAndAddArray(castArr, _('Starring'));
+      content += sortAndAddArray(directorArr, _('Director'));
+      content += sortAndAddArray(writerArr, _('Writer'));
+      content += sortAndAddArray(crewArr, _('Crew'));
+    }
+    if (event.keyword)
+      content += sortAndAddArray(event.keyword, _('Keywords'));
+    if (event.category)
+      content += sortAndAddArray(event.category, _('Categories'));
     if (event.starRating)
       content += '<div class="x-epg-meta"><span class="x-epg-prefix">' + _('Star Rating') + ':</span><span class="x-epg-body">' + event.starRating + '</span></div>';
     if (event.ageRating)
@@ -430,6 +478,9 @@ tvheadend.epg = function() {
                 dateFormat: 'U' /* unix time */
             },
             { name: 'starRating' },
+            { name: 'credits' },
+            { name: 'category' },
+            { name: 'keyword' },
             { name: 'ageRating' },
             { name: 'genre' },
             { name: 'dvrUuid' },