Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
accept "%c" placeholder for channel icons to use unmangled channel
name
  • Loading branch information
Jalle19 authored and perexg committed Jan 9, 2015
1 parent 3967007 commit f5c8e4c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
10 changes: 7 additions & 3 deletions docs/html/config_misc.html
Expand Up @@ -83,9 +83,13 @@
<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
Expand Down
31 changes: 24 additions & 7 deletions src/channels.c
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/webui/static/app/config.js
Expand Up @@ -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
});

Expand Down

0 comments on commit f5c8e4c

Please sign in to comment.