From f5c8e4ce86247c72cab3eb4df2fc578b244d7c4e Mon Sep 17 00:00:00 2001 From: Sam Stenvall Date: Thu, 8 Jan 2015 10:36:46 +0200 Subject: [PATCH] accept "%c" placeholder for channel icons to use unmangled channel name --- docs/html/config_misc.html | 10 +++++++--- src/channels.c | 31 ++++++++++++++++++++++++------- src/webui/static/app/config.js | 4 ++-- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/docs/html/config_misc.html b/docs/html/config_misc.html index 71b2c3b53..566e2b917 100644 --- a/docs/html/config_misc.html +++ b/docs/html/config_misc.html @@ -83,9 +83,13 @@
If both a picon and a channel-specific (e.g. channelname.jpg) icon are defined, use the picon.
Channel icon path
-
Path to an icon for this channel. This can be named however you wish, as a local (file://) or remote (http://) image.
- 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.
+
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:
+ + Example: file:///tmp/icons/%C.png or http://example.com/%c.png
Picon path
Path to a directory (folder) containing your picon collection. This can be named however diff --git a/src/channels.c b/src/channels.c index 5497d6f47..5e79511a0 100644 --- a/src/channels.c +++ b/src/channels.c @@ -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); diff --git a/src/webui/static/app/config.js b/src/webui/static/app/config.js index 4469a0ce8..ab6b44ef1 100644 --- a/src/webui/static/app/config.js +++ b/src/webui/static/app/config.js @@ -140,13 +140,13 @@ tvheadend.miscconf = function(panel, index) { var chiconPath = new Ext.form.TextField({ name: 'chiconpath', - fieldLabel: 'Channel icon path
(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
(e.g. file:///tmp/picons or http://...)', + fieldLabel: 'Picon path (see Help)', width: 400 }); -- 2.47.3