]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
accept "%c" placeholder for channel icons to use unmangled channel
authorSam Stenvall <neggelandia@gmail.com>
Thu, 8 Jan 2015 08:36:46 +0000 (10:36 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 9 Jan 2015 12:34:03 +0000 (13:34 +0100)
name

docs/html/config_misc.html
src/channels.c
src/webui/static/app/config.js

index 71b2c3b53b6758d6ec7da3654b26d959f9859403..566e2b91715c10f88236921ed044d63cfd77742b 100644 (file)
     <dd>If both a picon and a channel-specific (e.g. channelname.jpg) icon are defined, use the picon.</dd>
  
     <dt>Channel icon path</dt>
-    <dd>Path to an icon for this channel. This can be named however you wish, as a local (file://) or remote (http://) image.<br>
-       Example: file:///tmp/icons/%C.png (where %C is the channel nameon local storage where
-       is TVHeadend) or http://example.com/example.png to set icon from web page.</dd>
+    <dd>Path to an icon for this channel. This can be named however you wish, as a local (file://) or remote (http://) image. 
+        The following placeholders are available:<br>
+       <ul>
+               <li>%C - the transliterated channel name in ASCII (safe characters, no spaces etc.)</li>
+               <li>%c - the channel name (URL encoded ASCII)</li>
+       </ul>
+       Example: file:///tmp/icons/%C.png or http://example.com/%c.png</dd>
   
     <dt>Picon path</dt>
     <dd>Path to a directory (folder) containing your picon collection. This can be named however 
index 5497d6f47f319f843a596cd6703bfeff93d3edec..5e79511a082d63a7d61fe7340cc6ede6e9790158 100644 (file)
@@ -645,17 +645,14 @@ channel_get_icon ( channel_t *ch )
         (chname = channel_get_name(ch)) != NULL && chname[0]) {
       const char *chi, *send, *sname, *s;
       chi = strdup(chicon);
-      send = strstr(chi, "%C");
-      if (send == NULL) {
-        buf[0] = '\0';
-        sname = "";
-      } else {
-        *(char *)send = '\0';
-        send += 2;
+
+      /* Check for and replace placeholders */
+      if ((send = strstr(chi, "%C"))) {
         sname = intlconv_utf8safestr(intlconv_charset_id("ASCII", 1, 1),
                                      chname, strlen(chname) * 2);
         if (sname == NULL)
           sname = strdup(chname);
+
         /* Remove problematic characters */
         s = sname;
         while (s && *s) {
@@ -665,6 +662,26 @@ channel_get_icon ( channel_t *ch )
           s++;
         }
       }
+      else if((send = strstr(chi, "%c"))) {
+        char *aname = intlconv_utf8safestr(intlconv_charset_id("ASCII", 1, 1),
+                                     chname, strlen(chname) * 2);
+
+        if (aname == NULL)
+          aname = strdup(chname);
+
+        sname = url_encode(aname);
+        free((char *)aname);
+      }
+      else {
+        buf[0] = '\0';
+        sname = "";
+      }
+
+      if (send) {
+        *(char *)send = '\0';
+        send += 2;
+      }
+
       snprintf(buf, sizeof(buf), "%s%s%s", chi, sname ?: "", send ?: "");
       if (send)
         free((char *)sname);
index 4469a0ce8f3247be19eaa9df7b1fa54341bd62a7..ab6b44ef14f1e3841e83c0adc78ed5bceec708f3 100644 (file)
@@ -140,13 +140,13 @@ tvheadend.miscconf = function(panel, index) {
 
     var chiconPath = new Ext.form.TextField({
         name: 'chiconpath',
-        fieldLabel: 'Channel icon path<br/>(e.g. file:///tmp/icons/%C.png or http://...)',
+        fieldLabel: 'Channel icon path (see Help)',
         width: 400
     });
 
     var piconPath = new Ext.form.TextField({
         name: 'piconpath',
-        fieldLabel: 'Picon path<br/>(e.g. file:///tmp/picons or http://...)',
+        fieldLabel: 'Picon path (see Help)',
         width: 400
     });