summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhorchi <vdr@jwendel.de>2018-03-11 14:00:31 +0100
committerhorchi <vdr@jwendel.de>2018-03-11 14:00:31 +0100
commit92e05e8cbf57fa45a87027484929c033c4002d14 (patch)
treeb5fa3a9ce5d20a23733461a147da3fbc1a279be4
parenta29fa81a3dbf641a40b93f69b90151f70dc0290c (diff)
downloadvdr-plugin-epg2vdr-92e05e8cbf57fa45a87027484929c033c4002d14.tar.gz
vdr-plugin-epg2vdr-92e05e8cbf57fa45a87027484929c033c4002d14.tar.bz2
2018-03-11 version 1.1.94 (horchi)\n - change: Porting to dbapi 7 changes of epgd\n\n1.1.94
-rw-r--r--HISTORY.h9
-rw-r--r--configs/epg.dat2
-rw-r--r--lib/common.c18
-rw-r--r--lib/common.h5
-rw-r--r--lib/demo.c5
-rw-r--r--update.c54
6 files changed, 68 insertions, 25 deletions
diff --git a/HISTORY.h b/HISTORY.h
index b2c5708..9930007 100644
--- a/HISTORY.h
+++ b/HISTORY.h
@@ -5,10 +5,10 @@
*
*/
-#define _VERSION "1.1.93"
-#define VERSION_DATE "09.03.2018"
+#define _VERSION "1.1.94"
+#define VERSION_DATE "11.03.2018"
-#define DB_API 6
+#define DB_API 7
#ifdef GIT_REV
# define VERSION _VERSION "-GIT" GIT_REV
@@ -19,6 +19,9 @@
/*
* ------------------------------------
+2018-03-11 version 1.1.94 (horchi)
+ - change: Porting to dbapi 7 changes of epgd
+
2018-03-09 version 1.1.93 (horchi)
- added: Menu for matching 'jobs' (timersdone) of search timer results, with delete option
- added: some german translations
diff --git a/configs/epg.dat b/configs/epg.dat
index d98f882..e0d5de5 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/lib/common.c b/lib/common.c
index cf68ffa..a452b23 100644
--- a/lib/common.c
+++ b/lib/common.c
@@ -261,6 +261,20 @@ 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();
@@ -1920,6 +1934,8 @@ int urlUnescape(char* dst, const char* src, int normalize)
return (dst - org_dst) - 1;
}
+#ifdef VDR_PLUGIN
+
//***************************************************************************
//***************************************************************************
// Timer Thread
@@ -1967,3 +1983,5 @@ void cTimerThread::Action()
// if (selfdetroy)
// delete this; // :o :o ;)
}
+
+#endif // VDR_PLUGIN
diff --git a/lib/common.h b/lib/common.h
index c7faf81..c8361ec 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);
@@ -414,6 +415,8 @@ class LogDuration
int logLevel;
};
+#ifdef VDR_PLUGIN
+
//***************************************************************************
// Timer Thread
//***************************************************************************
@@ -442,6 +445,8 @@ class cTimerThread : public cThread
sendEventFct sendEvent;
};
+#endif // VDR_PLUGIN
+
//***************************************************************************
// Semaphore
//***************************************************************************
diff --git a/lib/demo.c b/lib/demo.c
index 347cabf..9d44526 100644
--- a/lib/demo.c
+++ b/lib/demo.c
@@ -470,6 +470,11 @@ int main(int argc, char** argv)
cEpgConfig::logstdout = yes;
cEpgConfig::loglevel = 2;
+ char* str = strdup("https://cellular.images.dvbdata.com:1234/4998510/4998510/320x240.jpg");
+ replaceChars(str, "<>:\"/\\:|?*", '_');
+ tell(0, "%s", str);
+ free(str);
+
const char* path = "/etc/epgd/epg.dat";
if (argc > 1)
diff --git a/update.c b/update.c
index ae51fe8..874b295 100644
--- a/update.c
+++ b/update.c
@@ -386,9 +386,10 @@ int cUpdate::initDb()
selectAllImages->setBindPrefix("e.");
selectAllImages->bind(&masterId, cDBS::bndOut);
selectAllImages->setBindPrefix("r.");
- selectAllImages->bind("ImgName", cDBS::bndOut, ", ");
- selectAllImages->bind("EventId", cDBS::bndOut, ", ");
- selectAllImages->bind("Lfn", cDBS::bndOut, ", ");
+ selectAllImages->bind("IMGNAME", cDBS::bndOut, ", ");
+ selectAllImages->bind("IMGNAMEFS", cDBS::bndOut, ", ");
+ selectAllImages->bind("EVENTID", cDBS::bndOut, ", ");
+ selectAllImages->bind("LFN", cDBS::bndOut, ", ");
selectAllImages->setBindPrefix("i.");
selectAllImages->build(", length(");
selectAllImages->bind(&imageSize, cDBS::bndOut);
@@ -397,13 +398,13 @@ int cUpdate::initDb()
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 (",
- eventsDb->getField("EventId")->getDbName(),
- imageRefDb->getField("EventId")->getDbName(),
- imageDb->getField("ImgName")->getDbName(),
- imageRefDb->getField("ImgName")->getDbName());
+ eventsDb->getField("EVENTID")->getDbName(),
+ imageRefDb->getField("EVENTID")->getDbName(),
+ imageDb->getField("IMGNAME")->getDbName(),
+ imageRefDb->getField("IMGNAME")->getDbName());
selectAllImages->bindCmp("i", &imageUpdSp, ">");
selectAllImages->build(" or ");
- selectAllImages->bindCmp("r", "UpdSp", 0, ">");
+ selectAllImages->bindCmp("r", "UPDSP", 0, ">");
selectAllImages->build(")");
status += selectAllImages->prepare();
@@ -1876,6 +1877,7 @@ cEvent* cUpdate::createEventFromRow(const cDbRow* row)
int cUpdate::storePicturesToFs()
{
int count = 0;
+ int cntLinks = 0;
int updated = 0;
char* path = 0;
time_t start = time(0);
@@ -1893,21 +1895,21 @@ int cUpdate::storePicturesToFs()
tell(0, "Load images from database");
imageRefDb->clear();
- imageRefDb->setValue("UpdSp", lastUpdateAt);
+ imageRefDb->setValue("UPDSP", lastUpdateAt);
imageUpdSp.setValue(lastUpdateAt);
for (int res = selectAllImages->find(); res; res = selectAllImages->fetch())
{
int eventid = masterId.getIntValue();
- const char* imageName = imageRefDb->getStrValue("ImgName");
- int lfn = imageRefDb->getIntValue("Lfn");
+ const char* imageNameFs = imageRefDb->getStrValue("IMGNAMEFS");
+ int lfn = imageRefDb->getIntValue("LFN");
char* newpath;
char* linkdest = 0;
char* destfile = 0;
int forceLink = no;
int size = imageSize.getIntValue();
- asprintf(&destfile, "%s/images/%s", epgimagedir, imageName);
+ asprintf(&destfile, "%s/images/%s", epgimagedir, imageNameFs);
// check target ... image changed?
@@ -1916,9 +1918,9 @@ int cUpdate::storePicturesToFs()
// get image
imageDb->clear();
- imageDb->setValue("ImgName", imageName);
+ imageDb->setValue("IMGNAME", imageRefDb->getStrValue("IMGNAME"));
- if (imageDb->find() && !imageDb->getRow()->getValue("Image")->isNull())
+ if (imageDb->find() && !imageDb->getRow()->getValue("IMAGE")->isNull())
{
count++;
@@ -1935,7 +1937,7 @@ int cUpdate::storePicturesToFs()
if (FILE* fh1 = fopen(destfile, "w"))
{
- fwrite(imageDb->getStrValue("Image"), 1, size, fh1);
+ fwrite(imageDb->getStrValue("IMAGE"), 1, size, fh1);
fclose(fh1);
}
else
@@ -1951,7 +1953,7 @@ int cUpdate::storePicturesToFs()
// create links ...
- asprintf(&linkdest, "./images/%s", imageName);
+ asprintf(&linkdest, "./images/%s", imageNameFs);
#ifdef _IMG_LINK
if (!lfn)
@@ -1967,6 +1969,10 @@ int cUpdate::storePicturesToFs()
// create link with index
asprintf(&newpath, "%s/%d_%d.%s", epgimagedir, eventid, lfn, imageExtension);
+
+ if (!fileExists(newpath))
+ cntLinks++;
+
createLink(newpath, linkdest, forceLink);
free(newpath);
@@ -1980,8 +1986,8 @@ int cUpdate::storePicturesToFs()
selectAllImages->freeResult();
- tell(0, "Got %d images from database in %ld seconds (%d updates, %d new)",
- count, time(0) - start, updated, count-updated);
+ tell(0, "Got %d images from database in %ld seconds (%d updates, %d new) and created %d links",
+ count, time(0) - start, updated, count-updated, cntLinks);
return dbConnected(yes) ? success : fail;
}
@@ -2018,9 +2024,9 @@ int cUpdate::cleanupPictures()
cDbStatement* stmt = new cDbStatement(imageRefDb);
stmt->build("select ");
- stmt->bind("FileRef", cDBS::bndOut);
+ stmt->bind("FILEREF", cDBS::bndOut);
stmt->build(" from %s where ", imageRefDb->TableName());
- stmt->bind("ImgName", cDBS::bndIn | cDBS::bndSet);
+ stmt->bind("IMGNAMEFS", cDBS::bndIn | cDBS::bndSet);
if (stmt->prepare() != success)
{
@@ -2037,7 +2043,6 @@ int cUpdate::cleanupPictures()
if (!(dir = opendir(pdir)))
{
tell(1, "Can't open directory '%s', '%s'", pdir, strerror(errno));
-
free(pdir);
return done;
@@ -2045,6 +2050,8 @@ int cUpdate::cleanupPictures()
free(pdir);
+ int cnt = 0;
+
while (dbConnected() && (dirent = readdir(dir)))
{
// check extension
@@ -2053,18 +2060,21 @@ int cUpdate::cleanupPictures()
continue;
imageRefDb->clear();
- imageRefDb->setValue("ImgName", dirent->d_name);
+ imageRefDb->setValue("IMGNAMEFS", dirent->d_name);
if (!stmt->find())
{
asprintf(&pdir, "%s/images/%s", epgimagedir, dirent->d_name);
+ tell(2, "Remove image '%s'", pdir);
+
if (!removeFile(pdir))
iCount++;
free(pdir);
}
+ cnt++;
stmt->freeResult();
}