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.


Origin commit data
------------------
Commit: 4275fabed6
Author: vanhofen <vanhofen@gmx.de>
Date: 2018-12-18 (Tue, 18 Dec 2018)

Origin message was:
------------------
- 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.
This commit is contained in:
vanhofen
2018-12-18 00:19:35 +01:00
parent b4d591ff3a
commit e1877ac7c0
2 changed files with 57 additions and 1 deletions

View File

@@ -2,6 +2,8 @@
#include <global.h>
#include <neutrino.h>
#include "pictureviewer.h"
#include <gui/movieplayer.h>
#include <eitd/sectionsd.h>
#include "pv_config.h"
#include <system/debug.h>
#include <system/helpers.h>
@@ -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<std::string> 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<std::string> v_path;
v_path.clear();
std::string id_tmp_path;
//create filename with channel name (logo_hdd_dir)