From: E.Smith <31170571+azlm8t@users.noreply.github.com> Date: Wed, 1 May 2019 17:52:10 +0000 (+0100) Subject: xmltv: Avoid outputting lang tags in xmltv for only one language, fixes #5630 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f249f6ac9c42b6b37c84edaaab24476ade90522a;p=thirdparty%2Ftvheadend.git xmltv: Avoid outputting lang tags in xmltv for only one language, fixes #5630 For most sources of guide information, we only have one language. If we output xmltv with language tags just makes the xmltv output larger with no benefit. --- diff --git a/src/webui/xmltv.c b/src/webui/xmltv.c index ebb050202..3ce7d8759 100644 --- a/src/webui/xmltv.c +++ b/src/webui/xmltv.c @@ -161,6 +161,18 @@ _http_xmltv_add_episode_num(htsbuf_queue_t *hq, uint16_t num, uint16_t cnt) } } +/// Output a start tag for the tag and include a lang="xx" _only_ if we +/// have more than one language. This avoids outputting lots of tags for +/// the common case of only having one language, so is useful for very low +/// memory devices. +#define HTTP_XMLTV_OUTPUT_START_TAG_WITH_LANG(hq,rb_tree,lang_str,tag) \ + do { \ + htsbuf_qprintf(hq, " <%s", tag); \ + if (rb_tree->entries != 1) \ + htsbuf_qprintf(hq, " lang=\"%s\"", lang_str->lang); \ + htsbuf_append_str(hq,">"); \ + } while(0) + /** Output long description fields of the programme which are * not output for basic/limited devices. */ @@ -177,7 +189,7 @@ http_xmltv_programme_one_long(const http_connection_t *hc, RB_FOREACH(lse, ebc->subtitle, link) { /* Ignore empty sub-titles */ if (!strempty(lse->str)) { - htsbuf_qprintf(hq, " ", lse->lang); + HTTP_XMLTV_OUTPUT_START_TAG_WITH_LANG(hq, ebc->subtitle, lse, "sub-title"); htsbuf_append_and_escape_xml(hq, lse->str); htsbuf_append_str(hq, "\n"); } @@ -185,13 +197,13 @@ http_xmltv_programme_one_long(const http_connection_t *hc, if (ebc->description) RB_FOREACH(lse, ebc->description, link) { - htsbuf_qprintf(hq, " ", lse->lang); + HTTP_XMLTV_OUTPUT_START_TAG_WITH_LANG(hq, ebc->description, lse, "desc"); htsbuf_append_and_escape_xml(hq, lse->str); htsbuf_append_str(hq, "\n"); } else if (ebc->summary) RB_FOREACH(lse, ebc->summary, link) { - htsbuf_qprintf(hq, " ", lse->lang); + HTTP_XMLTV_OUTPUT_START_TAG_WITH_LANG(hq, ebc->summary, lse, "desc"); htsbuf_append_and_escape_xml(hq, lse->str); htsbuf_append_str(hq, "\n"); } @@ -239,7 +251,7 @@ http_xmltv_programme_one(const http_connection_t *hc, htsbuf_append_and_escape_xml(hq, http_xmltv_channel_get_name(hc, ch, ubuf, sizeof ubuf)); htsbuf_qprintf(hq, "\">\n"); RB_FOREACH(lse, ebc->title, link) { - htsbuf_qprintf(hq, " ", lse->lang); + HTTP_XMLTV_OUTPUT_START_TAG_WITH_LANG(hq, ebc->title, lse, "title"); htsbuf_append_and_escape_xml(hq, lse->str); htsbuf_append_str(hq, "\n"); }