From 27da45f59e61f19caf23e5dd68a15f108cf2d417 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Fri, 26 Aug 2016 15:00:14 +0200 Subject: [PATCH] neutrinoyparser: move search for channellogos to neutrinoyparser This is to respecting user's setting to use other channellogos for WebIf. Now WebIf tries Tuxbox.LogosURL from nhttpd.conf first. Controlapi ignores these setting and providing the default system channelogos using NeutrinoAPI->getLogoFile(). Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/7ac0ed9093028276834dbfe6fbcd217318497676 Author: vanhofen Date: 2016-08-26 (Fri, 26 Aug 2016) Origin message was: ------------------ - neutrinoyparser: move search for channellogos to neutrinoyparser This is to respecting user's setting to use other channellogos for WebIf. Now WebIf tries Tuxbox.LogosURL from nhttpd.conf first. Controlapi ignores these setting and providing the default system channelogos using NeutrinoAPI->getLogoFile(). ------------------ This commit was generated by Migit --- src/nhttpd/tuxboxapi/neutrinoyparser.cpp | 31 +++++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/nhttpd/tuxboxapi/neutrinoyparser.cpp b/src/nhttpd/tuxboxapi/neutrinoyparser.cpp index 0b713d901..f2a1fb2ad 100644 --- a/src/nhttpd/tuxboxapi/neutrinoyparser.cpp +++ b/src/nhttpd/tuxboxapi/neutrinoyparser.cpp @@ -368,7 +368,7 @@ std::string CNeutrinoYParser::func_get_bouquets_with_epg(CyhookHandler *hh, std: yresult += ""; if (have_logos) { - std::string channel_logo = NeutrinoAPI->getLogoFile(hh->WebserverConfigList["Tuxbox.LogosURL"], channel->getChannelID()); + std::string channel_logo = func_get_logo_name(hh, string_printf(PRINTF_CHANNEL_ID_TYPE, channel->getChannelID())); std::string zaplink; if (channel_logo.empty()) zaplink = channel->getName().c_str(); @@ -575,14 +575,33 @@ std::string CNeutrinoYParser::func_get_actual_channel_id(CyhookHandler *, std:: } //------------------------------------------------------------------------- -// func: Get Logo Name +// func: Get logo name for Webif //------------------------------------------------------------------------- std::string CNeutrinoYParser::func_get_logo_name(CyhookHandler *hh, std::string channelId) { - if (hh->WebserverConfigList["Tuxbox.DisplayLogos"] == "true") { - t_channel_id cid; - if (1 == sscanf(channelId.c_str(), "%" PRIx64, &cid)) - return NeutrinoAPI->getLogoFile(hh->WebserverConfigList["Tuxbox.LogosURL"], cid); + std::string LogosURL = hh->WebserverConfigList["Tuxbox.LogosURL"]; + if (hh->WebserverConfigList["Tuxbox.DisplayLogos"] == "true" && !LogosURL.empty()) + { + std::string fileType[] = { ".png", ".jpg" , ".gif" }; + + std::string channelIdShort = channelId.substr(channelId.length() - 12); + channelIdShort = channelIdShort.erase(0, min(channelIdShort.find_first_not_of('0'), channelIdShort.size()-1)); + + std::string channelName = ""; + t_channel_id chId = 0; + if (sscanf(channelId.c_str(), "%" PRIx64, &chId) == 1) + channelName = NeutrinoAPI->GetServiceName(chId); + + for (size_t i = 0; i < (sizeof(fileType) / sizeof(fileType[0])); i++) + { + // first check Tuxbox.LogosURL from nhttpd.conf + if (access((LogosURL + "/" + channelName + fileType[i]).c_str(), R_OK) == 0) + return LogosURL + "/" + channelName + fileType[i]; + else if (access((LogosURL + "/" + channelIdShort + fileType[i]).c_str(), R_OK) == 0) + return LogosURL + "/" + channelIdShort + fileType[i]; + else // fallback to default logos + return NeutrinoAPI->getLogoFile("", chId); + } } return ""; }