mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-27 15:32:52 +02:00
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:
@@ -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;
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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 {
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user