From 4e21dd5c4455b61a777435d7f0a57cf78b4d133b Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Tue, 18 Dec 2018 00:19:35 +0100 Subject: [PATCH] - introduce eventlogos (e.g. tagesschau.png for Tagesschau) Eventlogo name is created from lowercase event name. Sspaces are replaced by "-". So an event called "American Dad" needs a logo called "american-dad.png". Eventlogo must be located in a subdir called "/events" in the logo directories. The search is working backwards through the eventname like this: "/var/tuxbox/icons/logo/events/american-dad.jpg" "/var/tuxbox/icons/logo/events/american-da.jpg" "/var/tuxbox/icons/logo/events/american-d.jpg" "/var/tuxbox/icons/logo/events/american-.jpg" "/var/tuxbox/icons/logo/events/american.jpg" "/var/tuxbox/icons/logo/events/america.jpg" "/var/tuxbox/icons/logo/events/americ.jpg" "/var/tuxbox/icons/logo/events/ameri.jpg" "/var/tuxbox/icons/logo/events/amer.jpg" "/var/tuxbox/icons/logo/events/ame.jpg" "/var/tuxbox/icons/logo/events/am.jpg" "/var/tuxbox/icons/logo/events/a.jpg" First hit is used. If no eventlogo was found, the wellknown channellogos are used. Be carefull with the naming of the eventlogos. A logo named "a.png" will be used for all events starting with an A. Signed-off-by: Thilo Graf --- src/driver/pictureviewer/Makefile.am | 1 + src/driver/pictureviewer/pictureviewer.cpp | 57 +++++++++++++++++++++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/driver/pictureviewer/Makefile.am b/src/driver/pictureviewer/Makefile.am index 16bf123ca..acfa5096a 100644 --- a/src/driver/pictureviewer/Makefile.am +++ b/src/driver/pictureviewer/Makefile.am @@ -7,6 +7,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/zapit/include \ -I$(top_srcdir)/lib \ -I$(top_srcdir)/lib/libconfigfile \ + -I$(top_srcdir)/lib/libeventserver \ @SIGC_CFLAGS@ \ @FREETYPE_CFLAGS@ \ @LUA_CFLAGS@ \ diff --git a/src/driver/pictureviewer/pictureviewer.cpp b/src/driver/pictureviewer/pictureviewer.cpp index 21e880082..248cff128 100644 --- a/src/driver/pictureviewer/pictureviewer.cpp +++ b/src/driver/pictureviewer/pictureviewer.cpp @@ -2,6 +2,8 @@ #include #include #include "pictureviewer.h" +#include +#include #include "pv_config.h" #include #include @@ -530,6 +532,59 @@ void CPictureViewer::getSize(const char* name, int* width, int *height) bool CPictureViewer::GetLogoName(const uint64_t &ChannelID, const std::string &ChannelName, std::string &name, int *width, int *height) { std::string fileType[] = { ".png", ".jpg", ".gif" }; + std::vector v_path; + + // create eventname for eventlogos; Note: We don't process channellogos if any eventlogo was found. + std::string EventName = ""; + int mode = CNeutrinoApp::getInstance()->getMode(); + if (ChannelID || mode == NeutrinoModes::mode_ts) + { + // TODO: fix eventlogo in moviebrowser + + if (mode == NeutrinoModes::mode_ts) + { + if (CMoviePlayerGui::getInstance().p_movie_info && !CMoviePlayerGui::getInstance().p_movie_info->epgTitle.empty()) + EventName = CMoviePlayerGui::getInstance().p_movie_info->epgTitle; + } + else + { + CSectionsdClient::CurrentNextInfo CurrentNext; + CEitManager::getInstance()->getCurrentNextServiceKey(ChannelID, CurrentNext); + + if (CSectionsdClient::epgflags::has_current && !CurrentNext.current_name.empty()) + EventName = CurrentNext.current_name; + } + + std::transform(EventName.begin(), EventName.end(), EventName.begin(), ::tolower); + EventName = str_replace(" ", "-", EventName); + //printf("GetLogoName(): EventName \"%s\"\n", EventName.c_str()); + + v_path.clear(); + v_path.push_back(g_settings.logo_hdd_dir); + if (g_settings.logo_hdd_dir != LOGODIR_VAR) + v_path.push_back(LOGODIR_VAR); + if (g_settings.logo_hdd_dir != LOGODIR) + v_path.push_back(LOGODIR); + + for (size_t i = 0; i < (sizeof(fileType) / sizeof(fileType[0])); i++) + { + for (size_t j = 0; j < v_path.size(); j++) + { + for (size_t k = EventName.length(); k > 0; k--) + { + std::string EventLogo = v_path[j] + "/events/" + EventName.substr(0, k) + fileType[i]; + //printf("GetLogoName(): EventLogo \"%s\"\n", EventLogo.c_str()); + if (access(EventLogo.c_str(), R_OK) == 0) + { + if (width && height) + getSize(EventLogo.c_str(), width, height); + name = EventLogo; + return true; + } + } + } + } + } //get channel id as string char strChnId[16]; @@ -577,7 +632,7 @@ bool CPictureViewer::GetLogoName(const uint64_t &ChannelID, const std::string &C for (size_t i = 0; i < (sizeof(fileType) / sizeof(fileType[0])); i++) { - std::vector v_path; + v_path.clear(); std::string id_tmp_path; //create filename with channel name (logo_hdd_dir)