From: E.Smith <31170571+azlm8t@users.noreply.github.com>
Date: Wed, 20 Sep 2017 01:22:52 +0000 (+0100)
Subject: api epg: Send credit (cast), category, and keyword information to the GUI and display...
X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=643d1b0949ccb409e4f770e3c0a5bfe07946934f;p=thirdparty%2Ftvheadend.git
api epg: Send credit (cast), category, and keyword information to the GUI and display it. (#4441)
---
diff --git a/src/api/api_epg.c b/src/api/api_epg.c
index cd85c6b22..c9c5e17ff 100644
--- a/src/api/api_epg.c
+++ b/src/api/api_epg.c
@@ -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);
diff --git a/src/webui/static/app/epg.js b/src/webui/static/app/epg.js
index af3bb2293..09180afc2 100644
--- a/src/webui/static/app/epg.js
+++ b/src/webui/static/app/epg.js
@@ -129,6 +129,54 @@ tvheadend.epgDetails = function(event) {
content += '
' + event.description + '
';
if (event.summary || event.description)
content += '
';
+
+ // 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 '' + title + ':' + csv + '
';
+ 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 += '' + _('Star Rating') + ':' + event.starRating + '
';
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' },