mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 07:51:11 +02:00
introduce mdb-tools (taken from mdb-imdb)
Origin commit data
------------------
Branch: ni/coolstream
Commit: ab3f0e198c
Author: vanhofen <vanhofen@gmx.de>
Date: 2021-05-03 (Mon, 03 May 2021)
Origin message was:
------------------
- introduce mdb-tools (taken from mdb-imdb)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
#include "timerlist.h"
|
||||
#include <zapit/zapit.h>
|
||||
#include <system/helpers.h>
|
||||
#include <system/mdb-tools.h>
|
||||
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
@@ -1220,7 +1221,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start
|
||||
picname = movie_filename.substr(0, _pos) + ".jpg";
|
||||
}
|
||||
else
|
||||
picname = imdb->getFilename(channel, epgData.eventID);
|
||||
picname = CMDBTools::getInstance()->getFilename(channel, epgData.eventID);
|
||||
|
||||
CFileHelpers fh;
|
||||
if (!fh.copyFile(imdb->posterfile.c_str(), picname.c_str(), 0644))
|
||||
|
@@ -475,79 +475,6 @@ int CIMDB::getStars()
|
||||
return (int)(atof(imdbRating.c_str()) * 10);
|
||||
}
|
||||
|
||||
std::string CIMDB::getFilename(CZapitChannel *channel, uint64_t id)
|
||||
{
|
||||
char fname[512]; // UTF-8
|
||||
char buf[256];
|
||||
unsigned int pos = 0;
|
||||
|
||||
if (check_dir(g_settings.network_nfs_recordingdir.c_str()))
|
||||
return ("");
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/", g_settings.network_nfs_recordingdir.c_str());
|
||||
pos = strlen(fname);
|
||||
|
||||
// %C == channel, %T == title, %I == info1, %d == date, %t == time_t
|
||||
std::string FilenameTemplate = g_settings.recording_filename_template;
|
||||
if (FilenameTemplate.empty())
|
||||
FilenameTemplate = "%C_%T_%d_%t";
|
||||
|
||||
StringReplace(FilenameTemplate, "%d", "");
|
||||
StringReplace(FilenameTemplate, "%t", "");
|
||||
StringReplace(FilenameTemplate, "__", "_");
|
||||
|
||||
std::string channel_name = channel->getName();
|
||||
if (!(channel_name.empty()))
|
||||
{
|
||||
strcpy(buf, UTF8_TO_FILESYSTEM_ENCODING(channel_name.c_str()));
|
||||
ZapitTools::replace_char(buf);
|
||||
StringReplace(FilenameTemplate, "%C", buf);
|
||||
}
|
||||
else
|
||||
StringReplace(FilenameTemplate, "%C", "no_channel");
|
||||
|
||||
CShortEPGData epgdata;
|
||||
if (CEitManager::getInstance()->getEPGidShort(id, &epgdata))
|
||||
{
|
||||
if (!(epgdata.title.empty()))
|
||||
{
|
||||
strcpy(buf, epgdata.title.c_str());
|
||||
ZapitTools::replace_char(buf);
|
||||
StringReplace(FilenameTemplate, "%T", buf);
|
||||
}
|
||||
else
|
||||
StringReplace(FilenameTemplate, "%T", "no_title");
|
||||
|
||||
if (!(epgdata.info1.empty()))
|
||||
{
|
||||
strcpy(buf, epgdata.info1.c_str());
|
||||
ZapitTools::replace_char(buf);
|
||||
StringReplace(FilenameTemplate, "%I", buf);
|
||||
}
|
||||
else
|
||||
StringReplace(FilenameTemplate, "%I", "no_info");
|
||||
}
|
||||
|
||||
strcpy(&(fname[pos]), UTF8_TO_FILESYSTEM_ENCODING(FilenameTemplate.c_str()));
|
||||
|
||||
pos = strlen(fname);
|
||||
|
||||
strcpy(&(fname[pos]), ".jpg");
|
||||
|
||||
return (fname);
|
||||
}
|
||||
|
||||
void CIMDB::StringReplace(std::string &str, const std::string search, const std::string rstr)
|
||||
{
|
||||
std::string::size_type ptr = 0;
|
||||
std::string::size_type pos = 0;
|
||||
while ((ptr = str.find(search, pos)) != std::string::npos)
|
||||
{
|
||||
str.replace(ptr, search.length(), rstr);
|
||||
pos = ptr + rstr.length();
|
||||
}
|
||||
}
|
||||
|
||||
void CIMDB::cleanup()
|
||||
{
|
||||
if (access(search_outfile.c_str(), F_OK) == 0)
|
||||
|
@@ -59,8 +59,6 @@ class CIMDB
|
||||
std::string posterfile;
|
||||
|
||||
int getMovieDetails(const std::string &epgTitle);
|
||||
std::string getFilename(CZapitChannel *channel, uint64_t id);
|
||||
void StringReplace(std::string &str, const std::string search, const std::string rstr);
|
||||
void cleanup();
|
||||
|
||||
std::string getPoster() { return posterfile; }
|
||||
|
@@ -36,6 +36,7 @@ libneutrino_system_a_SOURCES = \
|
||||
luaserver.cpp \
|
||||
localize.cpp \
|
||||
helpers.cpp \
|
||||
mdb-tools.cpp \
|
||||
ping.cpp \
|
||||
proc_tools.cpp \
|
||||
settings.cpp \
|
||||
|
115
src/system/mdb-tools.cpp
Normal file
115
src/system/mdb-tools.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
Movie Database - Tools
|
||||
|
||||
(C) 2009-2016 NG-Team
|
||||
(C) 2016 NI-Team
|
||||
|
||||
License: GPL
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <global.h>
|
||||
#include <system/helpers.h>
|
||||
#include <eitd/sectionsd.h>
|
||||
|
||||
#include "mdb-tools.h"
|
||||
|
||||
CMDBTools *CMDBTools::getInstance()
|
||||
{
|
||||
static CMDBTools *mdbtools = NULL;
|
||||
if (!mdbtools)
|
||||
mdbtools = new CMDBTools();
|
||||
return mdbtools;
|
||||
}
|
||||
|
||||
CMDBTools::CMDBTools()
|
||||
{
|
||||
}
|
||||
|
||||
CMDBTools::~CMDBTools()
|
||||
{
|
||||
}
|
||||
|
||||
std::string CMDBTools::getFilename(CZapitChannel *channel, uint64_t id)
|
||||
{
|
||||
char fname[512];
|
||||
char buf[256];
|
||||
unsigned int pos = 0;
|
||||
|
||||
if (check_dir(g_settings.network_nfs_recordingdir.c_str()))
|
||||
return ("");
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/", g_settings.network_nfs_recordingdir.c_str());
|
||||
pos = strlen(fname);
|
||||
|
||||
// %C == channel, %T == title, %I == info1, %d == date, %t == time_t
|
||||
std::string FilenameTemplate = g_settings.recording_filename_template;
|
||||
if (FilenameTemplate.empty())
|
||||
FilenameTemplate = "%C_%T_%d_%t";
|
||||
|
||||
FilenameTemplate = str_replace("%d", "", FilenameTemplate);
|
||||
FilenameTemplate = str_replace("%t", "", FilenameTemplate);
|
||||
FilenameTemplate = str_replace("__", "_", FilenameTemplate);
|
||||
|
||||
std::string channel_name = channel->getName();
|
||||
if (!(channel_name.empty()))
|
||||
{
|
||||
strcpy(buf, UTF8_TO_FILESYSTEM_ENCODING(channel_name.c_str()));
|
||||
ZapitTools::replace_char(buf);
|
||||
FilenameTemplate = str_replace("%C", buf, FilenameTemplate);
|
||||
}
|
||||
else
|
||||
FilenameTemplate = str_replace("%C", "no_channel", FilenameTemplate);
|
||||
|
||||
CShortEPGData epgdata;
|
||||
if (CEitManager::getInstance()->getEPGidShort(id, &epgdata))
|
||||
{
|
||||
if (!(epgdata.title.empty()))
|
||||
{
|
||||
strcpy(buf, epgdata.title.c_str());
|
||||
ZapitTools::replace_char(buf);
|
||||
FilenameTemplate = str_replace("%T", buf, FilenameTemplate);
|
||||
}
|
||||
else
|
||||
FilenameTemplate = str_replace("%T", "no_title", FilenameTemplate);
|
||||
|
||||
if (!(epgdata.info1.empty()))
|
||||
{
|
||||
strcpy(buf, epgdata.info1.c_str());
|
||||
ZapitTools::replace_char(buf);
|
||||
FilenameTemplate = str_replace("%I", buf, FilenameTemplate);
|
||||
}
|
||||
else
|
||||
FilenameTemplate = str_replace("%I", "no_info", FilenameTemplate);
|
||||
}
|
||||
|
||||
strcpy(&(fname[pos]), UTF8_TO_FILESYSTEM_ENCODING(FilenameTemplate.c_str()));
|
||||
|
||||
pos = strlen(fname);
|
||||
|
||||
strcpy(&(fname[pos]), ".jpg");
|
||||
|
||||
return (fname);
|
||||
}
|
39
src/system/mdb-tools.h
Normal file
39
src/system/mdb-tools.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Movie Database - Tools
|
||||
|
||||
(C) 2009-2016 NG-Team
|
||||
(C) 2016 NI-Team
|
||||
|
||||
License: GPL
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __mdb_tools__
|
||||
#define __mdb_tools__
|
||||
|
||||
class CMDBTools
|
||||
{
|
||||
private:
|
||||
|
||||
public:
|
||||
CMDBTools();
|
||||
~CMDBTools();
|
||||
static CMDBTools *getInstance();
|
||||
|
||||
std::string getFilename(CZapitChannel *channel, uint64_t id);
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user