From: Jaroslav Kysela Date: Tue, 1 Jan 2019 17:34:53 +0000 (+0100) Subject: xmltv: add support for the lcn tag, fixes #5471 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7da43a563fe75368769fde33064d17810d9f2909;p=thirdparty%2Ftvheadend.git xmltv: add support for the lcn tag, fixes #5471 --- diff --git a/docs/markdown/url.md b/docs/markdown/url.md index 1906c70c0..269b45b5c 100644 --- a/docs/markdown/url.md +++ b/docs/markdown/url.md @@ -98,6 +98,9 @@ tag | Tagged channels specified by UUID or tag name tagname | Tagged channels specified by tag name tagid | Tagged channels specified by short tag ID +Option | Explanation +-----------|------------------------------------------------------------------------------ +lcn | Use _lcn_ tag instead _display-name_ (standard) for the channel number ### /special/srvid2 diff --git a/src/webui/xmltv.c b/src/webui/xmltv.c index 6dec81d5c..149d582e7 100644 --- a/src/webui/xmltv.c +++ b/src/webui/xmltv.c @@ -24,6 +24,8 @@ #include "string_list.h" #include "imagecache.h" +#define XMLTV_FLAG_LCN (1<<0) + /* * */ @@ -64,10 +66,11 @@ http_xmltv_end(htsbuf_queue_t *hq) * */ static void -http_xmltv_channel_add(htsbuf_queue_t *hq, const char *hostpath, channel_t *ch) +http_xmltv_channel_add(htsbuf_queue_t *hq, int flags, const char *hostpath, channel_t *ch) { const char *icon = channel_get_icon(ch); char ubuf[UUID_HEX_SIZE]; + const char *tag; int64_t lcn; htsbuf_qprintf(hq, "\n ", idnode_uuid_as_str(&ch->ch_id, ubuf)); @@ -75,13 +78,14 @@ http_xmltv_channel_add(htsbuf_queue_t *hq, const char *hostpath, channel_t *ch) htsbuf_append_str(hq, "\n"); lcn = channel_get_number(ch); if (lcn > 0) { + tag = (flags & XMLTV_FLAG_LCN) ? "lcn" : "display-name"; if (channel_get_minor(lcn)) { - htsbuf_qprintf(hq, " %u.%u\n", - channel_get_major(lcn), - channel_get_minor(lcn)); + htsbuf_qprintf(hq, " <%s>%u.%u\n", + tag, channel_get_major(lcn), + channel_get_minor(lcn), tag); } else { - htsbuf_qprintf(hq, " %u\n", - channel_get_major(lcn)); + htsbuf_qprintf(hq, " <%s>%u\n", + tag, channel_get_major(lcn), tag); } } if (icon) { @@ -224,7 +228,7 @@ http_xmltv_programme_add(htsbuf_queue_t *hq, const char *hostpath, channel_t *ch * Output a XMLTV containing a single channel */ static int -http_xmltv_channel(http_connection_t *hc, channel_t *channel) +http_xmltv_channel(http_connection_t *hc, int flags, channel_t *channel) { char hostpath[512]; @@ -233,7 +237,7 @@ http_xmltv_channel(http_connection_t *hc, channel_t *channel) http_get_hostpath(hc, hostpath, sizeof(hostpath)); http_xmltv_begin(&hc->hc_reply); - http_xmltv_channel_add(&hc->hc_reply, hostpath, channel); + http_xmltv_channel_add(&hc->hc_reply, flags, hostpath, channel); http_xmltv_programme_add(&hc->hc_reply, hostpath, channel); http_xmltv_end(&hc->hc_reply); return 0; @@ -244,7 +248,7 @@ http_xmltv_channel(http_connection_t *hc, channel_t *channel) * Output a playlist containing all channels with a specific tag */ static int -http_xmltv_tag(http_connection_t *hc, channel_tag_t *tag) +http_xmltv_tag(http_connection_t *hc, int flags, channel_tag_t *tag) { idnode_list_mapping_t *ilm; char hostpath[512]; @@ -260,7 +264,7 @@ http_xmltv_tag(http_connection_t *hc, channel_tag_t *tag) ch = (channel_t *)ilm->ilm_in2; if (http_access_verify_channel(hc, ACCESS_STREAMING, ch)) continue; - http_xmltv_channel_add(&hc->hc_reply, hostpath, ch); + http_xmltv_channel_add(&hc->hc_reply, flags, hostpath, ch); } LIST_FOREACH(ilm, &tag->ct_ctms, ilm_in1_link) { ch = (channel_t *)ilm->ilm_in2; @@ -277,7 +281,7 @@ http_xmltv_tag(http_connection_t *hc, channel_tag_t *tag) * Output a flat playlist with all channels */ static int -http_xmltv_channel_list(http_connection_t *hc) +http_xmltv_channel_list(http_connection_t *hc, int flags) { channel_t *ch; char hostpath[512]; @@ -291,7 +295,7 @@ http_xmltv_channel_list(http_connection_t *hc) CHANNEL_FOREACH(ch) { if (http_access_verify_channel(hc, ACCESS_STREAMING, ch)) continue; - http_xmltv_channel_add(&hc->hc_reply, hostpath, ch); + http_xmltv_channel_add(&hc->hc_reply, flags, hostpath, ch); } CHANNEL_FOREACH(ch) { if (http_access_verify_channel(hc, ACCESS_STREAMING, ch)) @@ -309,8 +313,8 @@ http_xmltv_channel_list(http_connection_t *hc) int page_xmltv(http_connection_t *hc, const char *remain, void *opaque) { - char *components[2], *cmd; - int nc, r; + char *components[2], *cmd, *str; + int nc, r, flags = 0; channel_t *ch = NULL; channel_tag_t *tag = NULL; @@ -328,6 +332,9 @@ page_xmltv(http_connection_t *hc, const char *remain, void *opaque) if (nc == 2) http_deescape(components[1]); + if ((str = http_arg_get(&hc->hc_req_args, "lcn"))) + if (atoll(str) > 0) flags |= XMLTV_FLAG_LCN; + tvh_mutex_lock(&global_lock); if (nc == 2 && !strcmp(components[0], "channelid")) @@ -346,12 +353,12 @@ page_xmltv(http_connection_t *hc, const char *remain, void *opaque) tag = channel_tag_find_by_uuid(components[1]); if (ch) { - r = http_xmltv_channel(hc, ch); + r = http_xmltv_channel(hc, flags, ch); } else if (tag) { - r = http_xmltv_tag(hc, tag); + r = http_xmltv_tag(hc, flags, tag); } else { if (!strcmp(cmd, "channels")) { - r = http_xmltv_channel_list(hc); + r = http_xmltv_channel_list(hc, flags); } else { r = HTTP_STATUS_BAD_REQUEST; }