]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
webui: Added support for Kodi label formatting in dvr/epg as optional
authorpablozg <pablozg@gmail.com>
Fri, 8 Jun 2018 09:30:09 +0000 (11:30 +0200)
committerperexg <perex@perex.cz>
Fri, 8 Jun 2018 09:48:37 +0000 (11:48 +0200)
src/config.c
src/config.h
src/webui/comet.c
src/webui/static/app/dvr.js
src/webui/static/app/epg.js
src/webui/static/app/tvheadend.js

index a6c02424954f8bd10275fcd233e609782e15b82a..984d20c3d74bc4e0ef7f9d2702a113241d0eaf1f 100644 (file)
@@ -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,
index 91c167b8b8cbd1c8d5400508d4215cc07973b855..87891a3374bffd93db2e02a6c13ac383a51fef27 100644 (file)
@@ -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;
index ed917fc46cfece8fda39af10d95892f63cabb2e7..de762d82940c5a9cbd5da07fc988b016454696d7 100644 (file)
@@ -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)
index b52804026216715fbb210c40e21fce6ac33d1a16..3ef310cb64e1f752a16f1ce0defdc60f59872bee 100644 (file)
@@ -5,6 +5,22 @@
 /**
  *
  */
+
+tvheadend.labelFormattingParser = function(description) {
+    if (tvheadend.label_formatting){
+        return description.replace(/\[COLOR\s(.*?)\]/g, '<font style="color:$1">')
+                          .replace(/\[\/COLOR\]/g, '<\/font>')
+                          .replace(/\[B\]/g, '<b>')
+                          .replace(/\[\/B\]/g, '<\/b>')
+                          .replace(/\[I\]/g, '<i>')
+                          .replace(/\[CR\]/g, '<br>')
+                          .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 += '<div class="x-epg-summary">' + summary + '</div>';
         if (desc) {
-            content += '<div class="x-epg-desc">' + desc + '</div>';
+            content += '<div class="x-epg-desc">' + tvheadend.labelFormattingParser(desc) + '</div>';
             content += '<hr class="x-epg-hr"/>';
         }
         content += tvheadend.getDisplayCredits(credits);
index 81b5e6f1dc75286408ace852e2fd9731f64d34b7..8a2a12efafe922f82831860a11538c6e0a84746f 100644 (file)
@@ -152,7 +152,7 @@ tvheadend.epgDetails = function(event) {
     if (event.summary)
       content += '<div class="x-epg-summary">' + event.summary + '</div>';
     if (event.description)
-      content += '<div class="x-epg-desc">' + event.description + '</div>';
+      content += '<div class="x-epg-desc">' + tvheadend.labelFormattingParser(event.description) + '</div>';
     if (event.summary || event.description)
       content += '<hr class="x-epg-hr"/>';
     content += tvheadend.getDisplayCredits(event.credits);
index a0a36df01aeeac9734236b5882d533b774f77533..4e2ff8dbb8ac7ffa13b405add9fe0b294949f94c 100644 (file)
@@ -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;