From cbc06b5a5c68eeb976f01d4a7021c9ec22b95919 Mon Sep 17 00:00:00 2001 From: pablozg Date: Fri, 8 Jun 2018 11:30:09 +0200 Subject: [PATCH] webui: Added support for Kodi label formatting in dvr/epg as optional --- src/config.c | 9 +++++++++ src/config.h | 1 + src/webui/comet.c | 1 + src/webui/static/app/dvr.js | 18 +++++++++++++++++- src/webui/static/app/epg.js | 2 +- src/webui/static/app/tvheadend.js | 2 ++ 6 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/config.c b/src/config.c index a6c024249..984d20c3d 100644 --- a/src/config.c +++ b/src/config.c @@ -1705,6 +1705,7 @@ config_boot config.chname_num = 1; config.iptv_tpool_count = 2; config.date_mask = strdup(""); + config.label_formatting = 0; idclass_register(&config_class); @@ -2237,6 +2238,14 @@ const idclass_t config_class = { .off = offsetof(config_t, date_mask), .group = 2, }, + { + .type = PT_BOOL, + .id = "label_formatting", + .name = N_("Kodi label formatting support"), + .desc = N_("Enable parser for kodi label formatting"), + .off = offsetof(config_t, label_formatting), + .group = 2 + }, { .type = PT_STR, .islist = 1, diff --git a/src/config.h b/src/config.h index 91c167b8b..87891a337 100644 --- a/src/config.h +++ b/src/config.h @@ -68,6 +68,7 @@ typedef struct config { uint32_t epg_update_window; int iptv_tpool_count; char *date_mask; + int label_formatting; } config_t; extern const idclass_t config_class; diff --git a/src/webui/comet.c b/src/webui/comet.c index ed917fc46..de762d829 100644 --- a/src/webui/comet.c +++ b/src/webui/comet.c @@ -192,6 +192,7 @@ comet_access_update(http_connection_t *hc, comet_mailbox_t *cmb) htsmsg_add_u32(m, "chname_num", config.chname_num); htsmsg_add_u32(m, "chname_src", config.chname_src); htsmsg_add_str(m, "date_mask", config.date_mask); + htsmsg_add_u32(m, "label_formatting", config.label_formatting); if (!access_noacl) htsmsg_add_str(m, "username", username); if (hc->hc_peer_ipstr) diff --git a/src/webui/static/app/dvr.js b/src/webui/static/app/dvr.js index b52804026..3ef310cb6 100644 --- a/src/webui/static/app/dvr.js +++ b/src/webui/static/app/dvr.js @@ -5,6 +5,22 @@ /** * */ + +tvheadend.labelFormattingParser = function(description) { + if (tvheadend.label_formatting){ + return description.replace(/\[COLOR\s(.*?)\]/g, '') + .replace(/\[\/COLOR\]/g, '<\/font>') + .replace(/\[B\]/g, '') + .replace(/\[\/B\]/g, '<\/b>') + .replace(/\[I\]/g, '') + .replace(/\[CR\]/g, '
') + .replace(/\[\/I\]/g, '<\/i>') + .replace(/\[UPPERCASE\](.*)\[\/UPPERCASE\]/g, function(match, group) {return group.toUpperCase();}) + .replace(/\[LOWERCASE\](.*)\[\/LOWERCASE\]/g, function(match, group) {return group.toLowerCase();}) + .replace(/\[CAPITALIZE\](.*)\[\/CAPITALIZE\]/g, function(match, group) {return group.split(/\s/).map(w => w[0].toUpperCase() w.slice(1)).join(' ');}); + }else return description; +}; + tvheadend.dvrDetails = function(uuid) { function showit(d) { @@ -79,7 +95,7 @@ tvheadend.dvrDetails = function(uuid) { if (summary && (!subtitle || subtitle != summary)) content += '
' + summary + '
'; if (desc) { - content += '
' + desc + '
'; + content += '
' + tvheadend.labelFormattingParser(desc) + '
'; content += '
'; } content += tvheadend.getDisplayCredits(credits); diff --git a/src/webui/static/app/epg.js b/src/webui/static/app/epg.js index 81b5e6f1d..8a2a12efa 100644 --- a/src/webui/static/app/epg.js +++ b/src/webui/static/app/epg.js @@ -152,7 +152,7 @@ tvheadend.epgDetails = function(event) { if (event.summary) content += '
' + event.summary + '
'; if (event.description) - content += '
' + event.description + '
'; + content += '
' + tvheadend.labelFormattingParser(event.description) + '
'; if (event.summary || event.description) content += '
'; content += tvheadend.getDisplayCredits(event.credits); diff --git a/src/webui/static/app/tvheadend.js b/src/webui/static/app/tvheadend.js index a0a36df01..4e2ff8dbb 100644 --- a/src/webui/static/app/tvheadend.js +++ b/src/webui/static/app/tvheadend.js @@ -13,6 +13,7 @@ tvheadend.docs_toc = null; tvheadend.doc_history = []; tvheadend.doc_win = null; tvheadend.date_mask = ''; +tvheadend.label_formatting = false; tvheadend.language = window.navigator.userLanguage || window.navigator.language; // Use en-US if browser language detection fails. @@ -1000,6 +1001,7 @@ function accessUpdate(o) { tvheadend.chname_num = o.chname_num ? 1 : 0; tvheadend.chname_src = o.chname_src ? 1 : 0; tvheadend.date_mask = o.date_mask; + tvheadend.label_formatting = o.label_formatting ? true : false; if (o.uilevel_nochange) tvheadend.uilevel_nochange = true; -- 2.47.2