summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY.h7
-rw-r--r--configs/mergeepg.sql2
-rw-r--r--epgd.h2
-rw-r--r--main.c1
-rw-r--r--update.c118
5 files changed, 127 insertions, 3 deletions
diff --git a/HISTORY.h b/HISTORY.h
index b47b128..5e889cc 100644
--- a/HISTORY.h
+++ b/HISTORY.h
@@ -4,8 +4,8 @@
* -----------------------------------
*/
-#define _VERSION "1.1.125"
-#define VERSION_DATE "21.12.2017"
+#define _VERSION "1.1.126"
+#define VERSION_DATE "02.01.2017"
#define DB_API 5
#ifdef GIT_REV
@@ -18,6 +18,9 @@
* ------------------------------------
*
+2017-01-02: version 1.1.126 (ckone)
+ - change: improved handling of reinstated events in merge procedure
+
2017-12-22: version 1.1.125 (horchi)
- change: new field in 'recordinglist' to store the original description
diff --git a/configs/mergeepg.sql b/configs/mergeepg.sql
index bde021a..62c2144 100644
--- a/configs/mergeepg.sql
+++ b/configs/mergeepg.sql
@@ -45,7 +45,7 @@ update
events v
left join
events e
- on e.masterid = v.useid and v.masterid != e.masterid and e.updflg in ('T','C') and e.delflg is Null
+ on e.masterid = v.useid and v.masterid != e.masterid and e.updflg in ('T','C') and ifnull(e.delflg,'N') = 'N'
where
v.updflg in('L') and
v.starttime + v.duration >= unix_timestamp()
diff --git a/epgd.h b/epgd.h
index ad1d0b6..3a7b74b 100644
--- a/epgd.h
+++ b/epgd.h
@@ -202,6 +202,7 @@ class cEpgd : public cFrame, public cSystemNotification
int initDb();
int exitDb();
int migrateFromDbApi4();
+ int tryFillEmptyRecTableFields();
int checkProcedure(const char* name, cDBS::ProcType type, cDbProcedure* fp = 0);
int checkView(const char* name, const char* file);
int registerMe();
@@ -266,6 +267,7 @@ class cEpgd : public cFrame, public cSystemNotification
static int shutdown;
static int epgTrigger;
static int searchTimerTrigger;
+ static int recTableFixTrigger;
std::vector<PluginLoader*> plugins;
diff --git a/main.c b/main.c
index cd38ece..9fc03d1 100644
--- a/main.c
+++ b/main.c
@@ -205,6 +205,7 @@ int main(int argc, char** argv)
::signal(SIGTERM, cEpgd::downF);
::signal(SIGHUP, cEpgd::triggerF);
::signal(SIGUSR1, cEpgd::triggerF);
+ ::signal(SIGUSR2, cEpgd::triggerF);
// do work ...
diff --git a/update.c b/update.c
index 861d77b..9eab690 100644
--- a/update.c
+++ b/update.c
@@ -25,6 +25,7 @@
int cEpgd::shutdown = no;
int cEpgd::epgTrigger = no;
int cEpgd::searchTimerTrigger = no;
+int cEpgd::recTableFixTrigger = no;
//***************************************************************************
// Signal Handler
@@ -37,6 +38,9 @@ void cEpgd::triggerF(int aSignal)
else if (aSignal == SIGUSR1)
searchTimerTrigger = yes;
+
+ else if (aSignal == SIGUSR2)
+ recTableFixTrigger = yes;
}
//***************************************************************************
@@ -1079,6 +1083,13 @@ int startWith(const char* buf, const char* token)
return strncmp(buf, token, strlen(token)) == 0;
}
+const char* endOf(const char* buf, const char* token)
+{
+ if (strncmp(buf, token, strlen(token)) == 0)
+ return buf + strlen(token);
+ return 0;
+}
+
int cEpgd::migrateFromDbApi4()
{
int status = success;
@@ -1151,6 +1162,110 @@ int cEpgd::migrateFromDbApi4()
return status;
}
+const char* getLine(const char* buf, const char* startChar = 0, const char* endChar = 0)
+{
+ static char line[100+TB];
+
+ const char* p;
+ int len = strlen(buf);
+
+ if (startChar && strchr(buf, *startChar))
+ {
+ buf = strchr(buf, *startChar);
+ len = strlen(buf);
+ }
+
+ if ((p = strchr(buf, '\n')))
+ len = p - buf;
+
+ if (endChar && (p = strchr(buf, *endChar)))
+ len = p - buf;
+
+ if (len > 100)
+ len = 100;
+
+ sprintf(line, "%.*s", len, buf);
+
+ return line;
+}
+
+int cEpgd::tryFillEmptyRecTableFields()
+{
+ int status = success;
+
+ recTableFixTrigger = no;
+
+ tell(0, "tryFillEmptyRecTableFields ...");
+
+ cDbStatement* select = new cDbStatement(recordingListDb);
+ select->build("select ");
+ select->bindAllOut();
+ select->build(" from %s", recordingListDb->TableName());
+ status += select->prepare();
+
+ if (status == success)
+ {
+ for (int f = select->find(); f; f = select->fetch())
+ {
+ const char* description = recordingListDb->getStrValue("DESCRIPTION");
+ const char* p = description;
+ const char* s = 0;
+
+ while (true)
+ {
+ if ((s = endOf(p, "Actor: ")) && recordingListDb->getValue("ACTOR")->isEmpty())
+ recordingListDb->setValue("ACTOR", getLine(s));
+ else if ((s = endOf(p, "Audio: ")) && recordingListDb->getValue("AUDIO")->isEmpty())
+ recordingListDb->setValue("AUDIO", getLine(s));
+ else if ((s = endOf(p, "Kategorie: ")) && recordingListDb->getValue("CATEGORY")->isEmpty())
+ recordingListDb->setValue("CATEGORY", getLine(s));
+ else if ((s = endOf(p, "Genre: ")) && recordingListDb->getValue("GENRE")->isEmpty())
+ recordingListDb->setValue("GENRE", getLine(s));
+ else if ((s = endOf(p, "Land: ")) && recordingListDb->getValue("COUNTRY")->isEmpty())
+ recordingListDb->setValue("COUNTRY", getLine(s));
+ else if ((s = endOf(p, "Jahr: ")) && recordingListDb->getValue("YEAR")->isEmpty())
+ {
+ recordingListDb->setValue("YEAR", getLine(s, 0, "["));
+
+ // #TODO don't work
+ // Examples: select flags, year, title, genre, category, description from recordinglist where description like '%Jahr: 2014[%';
+ if ((strchr(getLine(s, 0, "["), '[')) && recordingListDb->getValue("FLAGS")->isEmpty())
+ recordingListDb->setValue("FLAGS", getLine(s, "["));
+ }
+ else if ((s = endOf(p, "Flags: ")) && recordingListDb->getValue("FLAGS")->isEmpty())
+ recordingListDb->setValue("FLAGS", getLine(s));
+ else if ((s = endOf(p, "Kamera: ")) && recordingListDb->getValue("CAMERA")->isEmpty())
+ recordingListDb->setValue("CAMERA", getLine(s));
+ else if ((s = endOf(p, "Musik: ")) && recordingListDb->getValue("MUSIC")->isEmpty())
+ recordingListDb->setValue("MUSIC", getLine(s));
+ else if ((s = endOf(p, "TagesTipp")) && recordingListDb->getValue("TIPP")->isEmpty())
+ recordingListDb->setValue("TIPP", "TagesTipp");
+ else if ((s = endOf(p, "Tagestipp")) && recordingListDb->getValue("TIPP")->isEmpty())
+ recordingListDb->setValue("TIPP", "TagesTipp");
+ else if ((s = endOf(p, "TopTipp")) && recordingListDb->getValue("TIPP")->isEmpty())
+ recordingListDb->setValue("TIPP", "TopTipp");
+ else if ((s = endOf(p, "Toptipp")) && recordingListDb->getValue("TIPP")->isEmpty())
+ recordingListDb->setValue("TIPP", "TopTipp");
+ else if ((s = endOf(p, "Tipp")) && recordingListDb->getValue("TIPP")->isEmpty())
+ recordingListDb->setValue("TIPP", "Tipp");
+ else if ((s = endOf(p, "Bewertung: ")) && recordingListDb->getValue("RATING")->isEmpty())
+ recordingListDb->setValue("RATING", getLine(s));
+
+ if (!(p = strchr(p, '\n')) || !*(p++))
+ break;
+ }
+
+ recordingListDb->update();
+ }
+ }
+
+ tell(0, "... done");
+
+ delete select;
+
+ return status;
+}
+
//***************************************************************************
// Check Function
//***************************************************************************
@@ -1559,6 +1674,9 @@ void cEpgd::loop()
if (search->modified() || searchTimerTrigger)
updateSearchTimers(searchTimerTrigger, searchTimerTrigger ? "triggered by user" : "search timer changed");
+ if (recTableFixTrigger)
+ tryFillEmptyRecTableFields();
+
// print sql statistic for statement debugging
if (EpgdConfig.loglevel > 2)