summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhorchi <vdr@jwendel.de>2018-03-11 14:00:09 +0100
committerhorchi <vdr@jwendel.de>2018-03-11 14:00:09 +0100
commitcc0ddd47a78d451b445cfa7667757400c619cd5b (patch)
tree2cfadc6b53b10ceba0606a59176035af9e7b13a4
parent69218e79181c863a92e51d0d0b8f8a31b31c66c2 (diff)
downloadvdr-epg-daemon-cc0ddd47a78d451b445cfa7667757400c619cd5b.tar.gz
vdr-epg-daemon-cc0ddd47a78d451b445cfa7667757400c619cd5b.tar.bz2
2018-03-11: version 1.1.138 (horchi)\n change: Fixed image problem with epgdata\n due to interface change by epgdata (patch by seahawk1986)\n\n1.1.138
-rw-r--r--HISTORY.h11
-rw-r--r--PLUGINS/epgdata/epgdata.c49
-rw-r--r--PLUGINS/epgdata/epgdata.h1
-rw-r--r--configs/epg.dat2
-rw-r--r--epgd.h9
-rw-r--r--lib/common.c15
-rw-r--r--lib/common.h1
-rw-r--r--lib/demo.c93
-rw-r--r--svdrpclient.c2
-rw-r--r--update.c90
10 files changed, 193 insertions, 80 deletions
diff --git a/HISTORY.h b/HISTORY.h
index 64cf337..b53146a 100644
--- a/HISTORY.h
+++ b/HISTORY.h
@@ -4,9 +4,9 @@
* -----------------------------------
*/
-#define _VERSION "1.1.137"
-#define VERSION_DATE "09.03.2018"
-#define DB_API 6
+#define _VERSION "1.1.138"
+#define VERSION_DATE "11.03.2018"
+#define DB_API 7
#ifdef GIT_REV
# define VERSION _VERSION "-GIT" GIT_REV
@@ -17,6 +17,11 @@
/*
* ------------------------------------
*
+
+2018-03-11: version 1.1.138 (horchi)
+ change: Fixed image problem with epgdata
+ due to interface change by epgdata (patch by seahawk1986)
+
2018-03-09: version 1.1.137 (horchi)
bugfix: Try to fixed potential problem at timer modification
diff --git a/PLUGINS/epgdata/epgdata.c b/PLUGINS/epgdata/epgdata.c
index aca4fcb..d368d30 100644
--- a/PLUGINS/epgdata/epgdata.c
+++ b/PLUGINS/epgdata/epgdata.c
@@ -625,44 +625,49 @@ int Epgdata::processFile(const char* data, int size, const char* fileRef)
}
//***************************************************************************
-// Get Picture
+// Create FS Name Of Picture
+// - caller has to free the result!
//***************************************************************************
-int Epgdata::getPicture(const char* imagename, const char* fileRef, MemoryStruct* data)
+char* Epgdata::fsNameOfPicture(const char* imagename)
{
- int fileSize = 0;
- char* path = 0;
- char entryName[200+TB];
+ char* buffer = 0;
- data->clear();
+ if (const char* p = strstr(imagename, "://"))
+ buffer = strdup(p+strlen("://"));
+ else
+ buffer = strdup(imagename);
- // lookup file information
+ replaceChars(buffer, "<>:\"/\\:|?*", '_');
+ return buffer;
+}
- obj->fileDb->clear();
- obj->fileDb->setValue("FILEREF", fileRef);
- obj->fileDb->setValue("SOURCE", getSource());
+//***************************************************************************
+// Get Picture
+//***************************************************************************
- if (stmtByFileRef->find())
- asprintf(&path, "%s/epgdata/%s", EpgdConfig.cachePath,
- obj->fileDb->getStrValue("Name"));
+int Epgdata::getPicture(const char* imagename, const char* fileRef, MemoryStruct* data)
+{
+ int fileSize = 0;
+ int status;
- stmtByFileRef->freeResult();
+ data->clear();
- if (!path)
+ if (!imagename)
{
- tell(0, "Error: No entry with fileref '%s' to lookup image '%s' found",
- fileRef, imagename);
+ tell(0, "Error: No image url given, skipping image");
return 0;
}
- if (unzip(path, imagename, data->memory, fileSize, entryName) == success)
+ tell(0, "Downloading image '%s'", imagename);
+ status = obj->downloadFile(imagename, fileSize, data);
+
+ if (status != success)
{
- data->size = fileSize;
- tell(2, "Unzip of image '%s' succeeded", imagename);
+ tell(0, "Error: downloading image from url '%s' failed", imagename);
+ return 0;
}
- free(path);
-
return fileSize;
}
diff --git a/PLUGINS/epgdata/epgdata.h b/PLUGINS/epgdata/epgdata.h
index 0bb0d88..c4097a8 100644
--- a/PLUGINS/epgdata/epgdata.h
+++ b/PLUGINS/epgdata/epgdata.h
@@ -25,6 +25,7 @@ class Epgdata : public Plugin
const char* getSource() { return "epgdata"; }
+ char* fsNameOfPicture(const char* imagename); // caller has to free the result!
int getPicture(const char* imagename, const char* fileRef, MemoryStruct* data);
int processDay(int day, int fullupdate, Statistic* statistic);
int cleanupAfter();
diff --git a/configs/epg.dat b/configs/epg.dat
index 8d3ce74..fd29f54 100644
--- a/configs/epg.dat
+++ b/configs/epg.dat
@@ -150,6 +150,7 @@ Table imagerefs
SOURCE "" source Ascii 10 Meta,
FILEREF "" fileref Ascii 100 Data,
IMGNAME "" imagename Ascii 100 Data,
+ IMGNAMEFS "" imagenamefs Ascii 100 Data,
}
// ----------------------------------------------------------------
@@ -160,6 +161,7 @@ Index imagerefs
{
lfn "" LFN,
name "" IMGNAME,
+ namefs "" IMGNAMEFS,
}
// ----------------------------------------------------------------
diff --git a/epgd.h b/epgd.h
index 1358b7a..0651f92 100644
--- a/epgd.h
+++ b/epgd.h
@@ -77,6 +77,14 @@ class Plugin
virtual int hasSource(const char* source) { return strcmp(getSource(), source) == 0; }
virtual int getPicture(const char* imagename, const char* fileRef, MemoryStruct* data) = 0;
+
+ virtual char* fsNameOfPicture(const char* imagename) // caller has to free the result!
+ {
+ char* buffer = strdup(imagename);
+ replaceChars(buffer, "<>:\"/\\:|?*", '_');
+ return buffer;
+ }
+
virtual int processDay(int day, int fullupdate, Statistic* stat) = 0;
virtual int cleanupBefore() { return done; }
@@ -203,6 +211,7 @@ class cEpgd : public cFrame, public cSystemNotification
int exitDb();
int migrateFromDbApi4();
int migrateFromDbApi5();
+ int migrateFromDbApi6();
int tryFillEmptyRecTableFields();
int checkProcedure(const char* name, cDBS::ProcType type, cDbProcedure* fp = 0);
int checkView(const char* name, const char* file);
diff --git a/lib/common.c b/lib/common.c
index 69cc618..597f0d5 100644
--- a/lib/common.c
+++ b/lib/common.c
@@ -261,6 +261,21 @@ const char* toCase(Case cs, char* str)
return str;
}
+
+char* replaceChars(char* string, const char* chars, const char to)
+{
+ char* p = string;
+
+ while (*p)
+ {
+ if (strchr(chars, *p))
+ *p = to;
+ p++;
+ }
+
+ return string;
+}
+
void removeChars(std::string& str, const char* ignore)
{
const char* s = str.c_str();
diff --git a/lib/common.h b/lib/common.h
index 0b9c284..578ab7c 100644
--- a/lib/common.h
+++ b/lib/common.h
@@ -265,6 +265,7 @@ const char* bcastAddressOf(const char* ipStr, const char* maskStr = 0);
const char* getUniqueId();
#endif
+char* replaceChars(char* string, const char* chars, const char to);
void removeChars(std::string& str, const char* ignore);
void removeCharsExcept(std::string& str, const char* except);
void removeWord(std::string& pattern, std::string word);
diff --git a/lib/demo.c b/lib/demo.c
index 0c4c234..ca29da6 100644
--- a/lib/demo.c
+++ b/lib/demo.c
@@ -38,13 +38,13 @@ void initConnection()
void exitConnection()
{
cDbConnection::exit();
-
+
if (connection)
delete connection;
}
//***************************************************************************
-//
+//
//***************************************************************************
int demoStatement()
@@ -57,15 +57,15 @@ int demoStatement()
// open table (attach)
- if (eventsDb->open() != success)
+ if (eventsDb->open() != success)
return fail;
-
+
tell(0, "---------------- prepare select statement -------------");
// vorbereiten (prepare) eines statement, am besten einmal bei programmstart!
// ----------
- // select eventid, compshorttext, episodepart, episodelang
- // from events
+ // select eventid, compshorttext, episodepart, episodelang
+ // from events
// where eventid > ?
cDbStatement* selectByCompTitle = new cDbStatement(eventsDb);
@@ -77,14 +77,14 @@ int demoStatement()
status += selectByCompTitle->build(" from %s where ", eventsDb->TableName());
status += selectByCompTitle->bindCmp(0, eventsDb->getField("EventId"), 0, ">");
- status += selectByCompTitle->prepare(); // prepare statement
+ status += selectByCompTitle->prepare(); // prepare statement
if (status != success)
{
// prepare sollte MySQL fehler ausgegeben haben!
delete eventsDb;
- delete selectByCompTitle;
+ delete selectByCompTitle;
return fail;
}
@@ -93,7 +93,7 @@ int demoStatement()
tell(0, "------------------ create some rows ----------------------");
- eventsDb->clear(); // alle values löschen
+ eventsDb->clear(); // alle values löschen
for (int i = 0; i < 10; i++)
{
@@ -103,7 +103,7 @@ int demoStatement()
eventsDb->setValue(eventsDb->getField("EventId"), 800 + i * 100);
eventsDb->setValue(eventsDb->getField("ChannelId"), "xxx-yyyy-zzz");
eventsDb->setValue(eventsDb->getField("Title"), title);
-
+
eventsDb->store(); // store -> select mit anschl. update oder insert je nachdem ob dier PKey bereits vorhanden ist
// eventsDb->insert(); // sofern man schon weiß das es ein insert ist
// eventsDb->update(); // sofern man schon weiß das der Datensatz vorhanden ist
@@ -114,7 +114,7 @@ int demoStatement()
tell(0, "------------------ done ----------------------");
tell(0, "-------- select all where eventid > 1000 -------------");
-
+
eventsDb->clear(); // alle values löschen
eventsDb->setValue(eventsDb->getField("EventId"), 1000);
@@ -148,7 +148,7 @@ int joinDemo()
int status = success;
// grundsätzlich genügt hier auch eine Tabelle, für die anderen sind cDbValue Instanzen außreichend
- // so ist es etwas einfacher die cDbValues zu initialisieren.
+ // so ist es etwas einfacher die cDbValues zu initialisieren.
// Ich habe statische "virtual FieldDef* getFieldDef(int f)" Methode in der Tabellenklassen geplant
// um ohne Instanz der cTable ein Feld einfach initialisieren zu können
@@ -161,7 +161,7 @@ int joinDemo()
delete timerDb;
// init dict fields as needed (normaly done once at programm start)
- // init and using the pointer improve the speed since the lookup via
+ // init and using the pointer improve the speed since the lookup via
// the name is dine only once
// F_INIT(events, EventId); // ergibt: cDbFieldDef* eventsEventId; dbDict.init(eventsEventId, "events", "EventId");
@@ -170,15 +170,15 @@ int joinDemo()
// open tables (attach)
- if (eventsDb->open() != success)
+ if (eventsDb->open() != success)
return fail;
- if (imageDb->open() != success)
+ if (imageDb->open() != success)
return fail;
- if (imageRefDb->open() != success)
+ if (imageRefDb->open() != success)
return fail;
-
+
tell(0, "---------------- prepare select statement -------------");
// all images
@@ -192,13 +192,13 @@ int joinDemo()
cDbValue masterId;
cDbFieldDef imageSizeDef("image", "image", cDBS::ffUInt, 999, cDBS::ftData, 0); // eine Art ein Feld zu erzeugen
- imageSize.setField(&imageSizeDef);
+ imageSize.setField(&imageSizeDef);
imageUpdSp.setField(imageDb->getField("UpdSp"));
masterId.setField(eventsDb->getField("MasterId"));
// select e.masterid, r.imagename, r.eventid, r.lfn, length(i.image)
- // from imagerefs r, images i, events e
- // where i.imagename = r.imagename
+ // from imagerefs r, images i, events e
+ // where i.imagename = r.imagename
// and e.eventid = r.eventid
// and (i.updsp > ? or r.updsp > ?)
@@ -214,10 +214,10 @@ int joinDemo()
selectAllImages->bind(&imageSize, cDBS::bndOut);
selectAllImages->build(")");
selectAllImages->clrBindPrefix();
- selectAllImages->build(" from %s r, %s i, %s e where ",
+ selectAllImages->build(" from %s r, %s i, %s e where ",
imageRefDb->TableName(), imageDb->TableName(), eventsDb->TableName());
selectAllImages->build("e.%s = r.%s and i.%s = r.%s and (",
- "EventId", // eventsEventId->getDbName(),
+ "EventId", // eventsEventId->getDbName(),
imageRefDb->getField("EventId")->getDbName(),
"imagename", // direkt den DB Feldnamen verwenden -> nicht so schön da nicht dynamisch
imageRefDb->getField("ImgName")->getDbName()); // ordentlich via dictionary übersetzt -> schön ;)
@@ -235,7 +235,7 @@ int joinDemo()
delete eventsDb;
delete imageDb;
delete imageRefDb;
- delete selectAllImages;
+ delete selectAllImages;
return fail;
}
@@ -280,7 +280,7 @@ int joinDemo()
}
//***************************************************************************
-//
+//
//***************************************************************************
int insertDemo()
@@ -302,7 +302,7 @@ int insertDemo()
}
//***************************************************************************
-//
+//
//***************************************************************************
int findUseEvent()
@@ -324,7 +324,7 @@ int findUseEvent()
selectEventById->bindAllOut();
selectEventById->build(" from %s where ", useeventsDb->TableName());
selectEventById->bind("USEID", cDBS::bndIn | cDBS::bndSet);
- selectEventById->build(" and %s in (%s)",
+ selectEventById->build(" and %s in (%s)",
useeventsDb->getField("UPDFLG")->getDbName(),
Us::getNeeded());
@@ -390,8 +390,8 @@ int findUseEvent()
continue;
}
- if (field->getFormat() == cDbService::ffAscii ||
- field->getFormat() == cDbService::ffText ||
+ if (field->getFormat() == cDbService::ffAscii ||
+ field->getFormat() == cDbService::ffText ||
field->getFormat() == cDbService::ffMText)
{
fprintf(f, "%s: %s\n", flds[i], useeventsDb->getStrValue(flds[i]));
@@ -411,11 +411,11 @@ int findUseEvent()
selectEventById->freeResult();
- return done;
+ return done;
}
//***************************************************************************
-//
+//
//***************************************************************************
int updateRecordingDirectory()
@@ -428,31 +428,31 @@ int updateRecordingDirectory()
// char* dir = strdup("more~Marvel's Agents of S.H.I.E.L.D.~xxx.ts");
char* dir = strdup("aaaaa~bbbbbb~ccccc.ts");
char* pos = strrchr(dir, '~');
-
+
if (pos)
{
*pos = 0;
-
+
for (int level = 0; level < 3; level++)
{
recordingDirDb->clear();
recordingDirDb->setValue("VDRUUID", "foobar");
recordingDirDb->setValue("DIRECTORY", dir);
-
+
if (!recordingDirDb->find())
{
ins++;
recordingDirDb->store();
}
-
+
recordingDirDb->reset();
-
+
char* pos = strrchr(dir, '~');
if (pos) *pos=0;
}
}
-
+
tell(0, "inserted %d directories", ins);
delete recordingDirDb;
@@ -470,15 +470,30 @@ int main(int argc, char** argv)
cEpgConfig::logstdout = yes;
cEpgConfig::loglevel = 2;
+ const char* imagename = "https://cellular.images.dvbdata.com:1234/4998510/4998510/320x240.jpg";
+ char* buffer = 0;
+
+ if (const char* p = strstr(imagename, "://"))
+ buffer = strdup(p+strlen("://"));
+ else
+ buffer = strdup(imagename);
+
+ tell(0, "%s", buffer);
+
+ replaceChars(buffer, "<>:\"/\\:|?*", '_');
+
+ tell(0, "%s", buffer);
+ free(buffer);
+
const char* path = "/etc/epgd/epg.dat";
if (argc > 1)
path = argv[1];
// read deictionary
-
+
dbDict.setFilterFromNameFct(toFieldFilter);
-
+
if (dbDict.in(path, ffEpgd) != success)
{
tell(0, "Invalid dictionary configuration, aborting!");
@@ -519,7 +534,7 @@ int main(int argc, char** argv)
tell(0, "uuid: '%s'", getUniqueId());
tell(0, "- - - - - - - - - - - - - - - - - ");
-
+
//updateRecordingDirectory();
findUseEvent();
diff --git a/svdrpclient.c b/svdrpclient.c
index 86a078c..6c5a0bf 100644
--- a/svdrpclient.c
+++ b/svdrpclient.c
@@ -490,7 +490,7 @@ int cSvdrpClient::connect()
if (result != 0)
{
- tell(0, "Error: SVDRPCL: Cconnecting to '%s:%d' %s failed", ip, port, strerror(errno));
+ tell(0, "Error: SVDRPCL: Connecting to '%s:%d' %s failed", ip, port, strerror(errno));
::close(sock);
return fail;
diff --git a/update.c b/update.c
index eb774da..5fa7b58 100644
--- a/update.c
+++ b/update.c
@@ -159,9 +159,7 @@ cEpgd::~cEpgd()
cDbConnection::exit();
- vector<PluginLoader*>::iterator it;
-
- for (it = plugins.begin(); it < plugins.end(); it++)
+ for (auto it = plugins.begin(); it < plugins.end(); it++)
delete *it;
plugins.clear();
@@ -488,6 +486,12 @@ int cEpgd::initDb()
return fail;
}
+ if (lastApi <= 6)
+ {
+ if (migrateFromDbApi6() != success)
+ return fail;
+ }
+
registerMe(); // and update DB_API info at vdrs table
initial = no;
}
@@ -1213,6 +1217,52 @@ int cEpgd::migrateFromDbApi5()
}
//***************************************************************************
+// Migrate From DB API 6
+//***************************************************************************
+
+int cEpgd::migrateFromDbApi6()
+{
+ int status = success;
+
+ imageRefDb = new cDbTable(connection, "imagerefs");
+ if ((status = imageRefDb->open()) != success) return status;
+
+ tell(0, "Migration of table '%s' from version <= 6 ...", imageRefDb->TableName());
+
+ cDbStatement* select = new cDbStatement(imageRefDb);
+
+ select->build("update %s set imagenamefs = imagename where imagenamefs is null",
+ imageRefDb->TableName());
+
+ status += select->prepare();
+
+ if (status == success)
+ select->execute();
+
+ // select->bindAllOut();
+ // select->build(" from %s where %s is null", imageRefDb->TableName(),
+ // imageRefDb->getField("IMGNAMEFS")->getDbName());
+
+ // status += select->prepare();
+
+ // if (status == success)
+ // {
+ // for (int f = select->find(); f; f = select->fetch())
+ // {
+ // imageRefDb->setValue("IMGNAMEFS", imageRefDb->getStrValue("IMGNAME"));
+ // imageRefDb->update();
+ // }
+ // }
+
+ tell(0, "... done");
+
+ delete select;
+ delete imageRefDb; imageRefDb = 0;
+
+ return status;
+}
+
+//***************************************************************************
// Try Fill Empty Rec Table Fields
//***************************************************************************
@@ -2111,6 +2161,24 @@ int cEpgd::storeImageRefs(tEventId evtId, const char* source, const char* images
imageRefDb->setValue("SOURCE", source);
imageRefDb->setValue("FILEREF", fileRef);
+ for (auto it = plugins.begin(); it < plugins.end(); it++)
+ {
+ Plugin* p = (*it)->getPlugin();
+
+ cSystemNotification::check();
+
+ if (p->ready() && p->hasSource(source))
+ {
+ char* fsName = p->fsNameOfPicture(image);
+ imageRefDb->setValue("IMGNAMEFS", fsName);
+ free(fsName);
+ break;
+ }
+ }
+
+ // strReplace(image, '/', '_');
+ // imageRefDb->setValue("IMGNAMEFS", image);
+
imageRefDb->store();
count++;
@@ -2392,9 +2460,7 @@ int cEpgd::loadFromFs(MemoryStruct* data, const char* filename, const char* subP
int cEpgd::cleanupBefore()
{
- vector<PluginLoader*>::iterator it;
-
- for (it = plugins.begin(); it < plugins.end(); it++)
+ for (auto it = plugins.begin(); it < plugins.end(); it++)
{
Plugin* p = (*it)->getPlugin();
@@ -2413,9 +2479,7 @@ int cEpgd::cleanupBefore()
int cEpgd::cleanupAfter()
{
- vector<PluginLoader*>::iterator it;
-
- for (it = plugins.begin(); it < plugins.end(); it++)
+ for (auto it = plugins.begin(); it < plugins.end(); it++)
{
Plugin* p = (*it)->getPlugin();
@@ -2435,9 +2499,7 @@ int cEpgd::cleanupAfter()
int cEpgd::getPicture(const char* source, const char* imagename,
const char* fileRef, MemoryStruct* data)
{
- vector<PluginLoader*>::iterator it;
-
- for (it = plugins.begin(); it < plugins.end(); it++)
+ for (auto it = plugins.begin(); it < plugins.end(); it++)
{
Plugin* p = (*it)->getPlugin();
@@ -2456,9 +2518,7 @@ int cEpgd::getPicture(const char* source, const char* imagename,
int cEpgd::processDay(int day, int fullupdate, Statistic* stat)
{
- vector<PluginLoader*>::iterator it;
-
- for (it = plugins.begin(); it < plugins.end(); it++)
+ for (auto it = plugins.begin(); it < plugins.end(); it++)
{
Plugin* p = (*it)->getPlugin();