diff options
author | horchi <vdr@jwendel.de> | 2018-03-11 14:00:09 +0100 |
---|---|---|
committer | horchi <vdr@jwendel.de> | 2018-03-11 14:00:09 +0100 |
commit | cc0ddd47a78d451b445cfa7667757400c619cd5b (patch) | |
tree | 2cfadc6b53b10ceba0606a59176035af9e7b13a4 /lib | |
parent | 69218e79181c863a92e51d0d0b8f8a31b31c66c2 (diff) | |
download | vdr-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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/common.c | 15 | ||||
-rw-r--r-- | lib/common.h | 1 | ||||
-rw-r--r-- | lib/demo.c | 93 |
3 files changed, 70 insertions, 39 deletions
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); @@ -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(); |