adding caching xmltv logos

Origin commit data
------------------
Branch: ni/coolstream
Commit: 3955d83961
Author: TangoCash <eric@loxat.de>
Date: 2018-09-20 (Thu, 20 Sep 2018)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
TangoCash
2018-09-20 15:11:05 +02:00
committed by vanhofen
parent 2d3a6a9f1d
commit 729dd20a12
4 changed files with 27 additions and 2 deletions

View File

@@ -664,7 +664,7 @@ bool CPictureViewer::GetLogoName(const uint64_t& channel_id, const std::string&
{
if (!cc->getAlternateLogo().empty())
{
std::string lname = downloadUrlToRandomFile(cc->getAlternateLogo(), LOGODIR_TMP);
std::string lname = downloadUrlToLogo(cc->getAlternateLogo(), LOGODIR_TMP, cc->getChannelID());
if (width && height)
getSize(lname.c_str(), width, height);
name = lname;

View File

@@ -1744,6 +1744,28 @@ std::string downloadUrlToRandomFile(std::string url, std::string directory, unsi
return url;
}
std::string downloadUrlToLogo(std::string url, std::string directory, t_channel_id channel_id)
{
if (channel_id == 0)
return downloadUrlToRandomFile(url,directory);
if (strstr(url.c_str(), "://"))
{
//get channel id as string
char strChnId[16];
snprintf(strChnId, 16, "%llx", channel_id & 0xFFFFFFFFFFFFULL);
strChnId[15] = '\0';
std::string file = directory + "/" + strChnId + url.substr(url.find_last_of("."));
if (file_exists(file))
return file;
if (downloadUrl(url, file))
return file;
}
return url;
}
// curl
static void *myrealloc(void *ptr, size_t size)
{

View File

@@ -36,6 +36,8 @@
#include <curl/curl.h>
#include <curl/easy.h>
typedef uint64_t t_channel_id;
int my_system(const char * cmd);
int my_system(int argc, const char *arg, ...); /* argc is number of arguments including command */
@@ -166,6 +168,7 @@ bool utf8_check_is_valid(const std::string &str);
std::string randomString(unsigned int length = 10);
std::string randomFile(std::string suffix = "tmp", std::string directory = "/tmp", unsigned int length = 10);
std::string downloadUrlToRandomFile(std::string url, std::string directory = "/tmp", unsigned int length = 10);
std::string downloadUrlToLogo(std::string url, std::string directory = "/tmp", t_channel_id channel_id = 0);
// curl
struct MemoryStruct {

View File

@@ -1153,7 +1153,7 @@ void* CBouquetManager::LogoThread(void* _logolist)
{
CZapitChannel *cc = (*it);
if (cc)
cc->setAlternateLogo(downloadUrlToRandomFile(cc->getAlternateLogo(), LOGODIR_TMP));
cc->setAlternateLogo(downloadUrlToLogo(cc->getAlternateLogo(), LOGODIR_TMP, cc->getChannelID()));
}
LogoList->clear();
pthread_mutex_unlock(&mutex);