summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhorchi <vdr@jwendel.de>2018-10-02 19:21:14 +0200
committerhorchi <vdr@jwendel.de>2018-10-02 19:21:14 +0200
commitbd6ac8b88a6e128ad8778aad89f5d8c3f31148de (patch)
treec5e044200fc3101d6d14452aadc04b524883281b
parent1cbab41a38411ded875924d8b3cdaba68bafd574 (diff)
downloadvdr-epg-daemon-bd6ac8b88a6e128ad8778aad89f5d8c3f31148de.tar.gz
vdr-epg-daemon-bd6ac8b88a6e128ad8778aad89f5d8c3f31148de.tar.bz2
2018-10-02: version 1.1.143 (horchi)\n change: Fixed compile problem of epglv \n \n1.1.143
-rw-r--r--HISTORY.h11
-rw-r--r--Make.config2
-rw-r--r--Makefile4
-rw-r--r--README2
-rw-r--r--channelmap.c65
-rw-r--r--epgd.h2
-rw-r--r--epglv/src/epglv.h5
-rw-r--r--lib/curl.c4
-rw-r--r--lib/dbdict.h2
-rw-r--r--update.c36
10 files changed, 116 insertions, 17 deletions
diff --git a/HISTORY.h b/HISTORY.h
index 71644a9..a03b2bb 100644
--- a/HISTORY.h
+++ b/HISTORY.h
@@ -4,8 +4,8 @@
* -----------------------------------
*/
-#define _VERSION "1.1.141"
-#define VERSION_DATE "14.05.2018"
+#define _VERSION "1.1.143"
+#define VERSION_DATE "02.10.2018"
#define DB_API 7
#ifdef GIT_REV
@@ -17,6 +17,13 @@
/*
* ------------------------------------
*
+
+2018-10-02: version 1.1.143 (horchi)
+ change: Fixed compile problem of epglv
+
+2018-09-02: version 1.1.142 (horchi)
+ added: Auto update of modified channelids
+ change: systemd now default in Make.config
2018-05-14: version 1.1.141 (horchi)
added: Compatibility for newer MariaBD librarys (patch by provided by marco)
diff --git a/Make.config b/Make.config
index cc6942f..4e06fc7 100644
--- a/Make.config
+++ b/Make.config
@@ -21,7 +21,7 @@ UPSTARTDEST = $(DESTDIR)/etc/init
# select your init system { none, upstart, systemd }
-INIT_SYSTEM = none
+INIT_SYSTEM = systemd
INIT_AFTER = mysql.service
# ------------------
diff --git a/Makefile b/Makefile
index 1faf36e..0cdb20c 100644
--- a/Makefile
+++ b/Makefile
@@ -114,9 +114,9 @@ install-upstart:
chmod a+r $(UPSTARTDEST)/epghttpd.conf
install-systemd:
- cat contrib/epgd.service | sed s:"<BINDEST>":"$(BINDEST)":g | sed s:"<AFTER>":"$(INIT_AFTER)":g | sed s:"<PLGDEST>":"$(PLGDEST)":g | install -C -D /dev/stdin $(SYSTEMDDEST)/epgd.service
+ cat contrib/epgd.service | sed s:"<BINDEST>":"$(BINDEST)":g | sed s:"<AFTER>":"$(INIT_AFTER)":g | sed s:"<PLGDEST>":"$(PLGDEST)":g | install --mode=644 -C -D /dev/stdin $(SYSTEMDDEST)/epgd.service
chmod a+r $(SYSTEMDDEST)/epgd.service
- cat contrib/epghttpd.service | sed s:"<BINDEST>":"$(BINDEST)":g | install -C -D /dev/stdin $(SYSTEMDDEST)/epghttpd.service
+ cat contrib/epghttpd.service | sed s:"<BINDEST>":"$(BINDEST)":g | install --mode=644 -C -D /dev/stdin $(SYSTEMDDEST)/epghttpd.service
chmod a+r $(SYSTEMDDEST)/epghttpd.service
ifeq ($(DESTDIR),)
systemctl daemon-reload
diff --git a/README b/README
index fd0ef7a..c7ebcb1 100644
--- a/README
+++ b/README
@@ -77,7 +77,7 @@ git pull
Requirements:
-------------
- - libarchive
+ - libarchive-dev
- libcurl 7.10+
- libxslt 1.1.24+
- libxml2
diff --git a/channelmap.c b/channelmap.c
index 9629227..c8a52d6 100644
--- a/channelmap.c
+++ b/channelmap.c
@@ -223,10 +223,7 @@ int cEpgd::updateMapRow(char* extid, const char* source, const char* chan,
if (changed || insert)
{
tell(1, "Channel '%s' %s, source '%s', extid %s, merge %d",
- chan, insert ? "inserted" : "updated",
- source,
- extid,
- merge);
+ chan, insert ? "inserted" : "updated", source, extid, merge);
mapDb->setValue("MERGESP", 0L); // reset mergesp!
mapDb->setValue("UPDFLG", insert ? "I" : "U");
@@ -241,7 +238,7 @@ int cEpgd::updateMapRow(char* extid, const char* source, const char* chan,
}
else
{
- mapDb->setValue("UPDFLG", "S");
+ mapDb->setValue("UPDFLG", "S"); // 'S'tay - no change
}
mapDb->store();
@@ -259,6 +256,64 @@ int cEpgd::applyChannelmapChanges()
connection->startTransaction();
mapDb->clear();
+ mapDb->setValue("UPDFLG", "D");
+
+ // search matching 'I'nserted rows for all 'D'eleted rows to check if only the channelid has changed
+
+ for (int f = selectMapByUpdFlg->find(); f; f = selectMapByUpdFlg->fetch())
+ {
+ std::string oldChannelId = mapDb->getStrValue("CHANNELID");
+
+ mapDb->setValue("UPDFLG", "I");
+
+ if (selectMapByExt->find())
+ {
+ std::string newChannelId = mapDb->getStrValue("CHANNELID");
+
+ tell(0, "channelid '%s' was changed to '%s'", oldChannelId.c_str(), newChannelId.c_str());
+
+ // change the 'I'nserted row and remove the 'D'eleted row -> no further action is necessary later on
+
+ mapDb->find();
+ mapDb->setValue("UPDFLG", "S");
+ mapDb->update();
+ mapDb->deleteWhere("channelid = '%s' and extid = '%s' and source = '%s'",
+ oldChannelId.c_str(), mapDb->getStrValue("EXTERNALID"), mapDb->getStrValue("SOURCE"));
+
+ // now patch tables with channelid field
+
+ std::map<std::string, cDbTableDef*>::iterator t;
+
+ for (t = dbDict.getFirstTableIterator(); t != dbDict.getTableEndIterator(); t++)
+ {
+ cDbTableDef* td = t->second;
+
+ if (td->hasName("CHANNELMAP"))
+ continue;
+
+ if (td->getField("CHANNELID", yes))
+ {
+ tell(3, "Table '%s' has a channelid field", td->getName());
+
+ cDbTable* table = new cDbTable(connection, t->first.c_str());
+ char* stmt;
+
+ asprintf(&stmt, "update %s set %s = '%s' where %s = '%s'",
+ td->getName(),
+ table->getField("CHANNELID")->getDbName(), newChannelId.c_str(),
+ table->getField("CHANNELID")->getDbName(), oldChannelId.c_str());
+
+ tell(0, "Executing '%s'", stmt);
+ connection->query("%s", stmt);
+
+ free(stmt);
+ delete table;
+ }
+ }
+ }
+ }
+
+ mapDb->clear();
for (int f = selectAllMap->find(); f; f = selectAllMap->fetch())
{
diff --git a/epgd.h b/epgd.h
index 0651f92..3efca10 100644
--- a/epgd.h
+++ b/epgd.h
@@ -178,6 +178,8 @@ class cEpgd : public cFrame, public cSystemNotification
cDbTable* messageDb;
cDbStatement* selectAllMap;
+ cDbStatement* selectMapByUpdFlg;
+ cDbStatement* selectMapByExt;
cDbStatement* selectByCompTitle;
cDbStatement* selectMaxUpdSp;
cDbStatement* selectDistCompname;
diff --git a/epglv/src/epglv.h b/epglv/src/epglv.h
index 39554b8..66dd4cf 100644
--- a/epglv/src/epglv.h
+++ b/epglv/src/epglv.h
@@ -12,14 +12,9 @@ Copyright (C) 2013 Jörg Wendel
#ifdef STANDARD
# include <string.h>
-#else
-# include <my_global.h>
-# include <my_sys.h>
#endif
#include <mysql.h>
-#include <m_ctype.h>
-#include <m_string.h>
#include <locale.h>
#include <stdio.h>
diff --git a/lib/curl.c b/lib/curl.c
index d87ceba..93cb4a3 100644
--- a/lib/curl.c
+++ b/lib/curl.c
@@ -120,6 +120,7 @@ int cCurl::init(const char* httpproxy)
curl_easy_setopt(handle, CURLOPT_TIMEOUT, 30); // Set timeout
curl_easy_setopt(handle, CURLOPT_NOBODY, 0); //
curl_easy_setopt(handle, CURLOPT_USERAGENT, CURL_USERAGENT); // Some servers don't like requests
+ curl_easy_setopt(handle, CURLOPT_ACCEPT_ENCODING, "");
return success;
}
@@ -437,7 +438,8 @@ int cCurl::downloadFile(const char* url, int& size, MemoryStruct* data, int time
curl_easy_setopt(handle, CURLOPT_TIMEOUT, timeout); // Set timeout
curl_easy_setopt(handle, CURLOPT_NOBODY, data->headerOnly ? 1 : 0); //
curl_easy_setopt(handle, CURLOPT_USERAGENT, userAgent); // Some servers don't like requests without a user-agent field
- curl_easy_setopt(handle, CURLOPT_ACCEPT_ENCODING, "gzip"); //
+// curl_easy_setopt(handle, CURLOPT_ACCEPT_ENCODING, "gzip"); //
+ curl_easy_setopt(handle, CURLOPT_ACCEPT_ENCODING, "");
if (headerlist)
curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headerlist);
diff --git a/lib/dbdict.h b/lib/dbdict.h
index 94aab67..3b0398a 100644
--- a/lib/dbdict.h
+++ b/lib/dbdict.h
@@ -308,6 +308,8 @@ class cDbTableDef : public cDbService
}
const char* getName() { return name; }
+
+ int hasName(const char* n) { return strcasecmp(name, n) == 0; }
int fieldCount() { return dfields.size(); }
cDbFieldDef* getField(int id) { return _dfields[id]; }
diff --git a/update.c b/update.c
index d307f8b..a5384d6 100644
--- a/update.c
+++ b/update.c
@@ -52,6 +52,8 @@ cEpgd::cEpgd()
const char* lang;
selectAllMap = 0;
+ selectMapByUpdFlg = 0;
+ selectMapByExt = 0;
selectByCompTitle = 0;
selectMaxUpdSp = 0;
selectDistCompname = 0;
@@ -594,6 +596,38 @@ int cEpgd::initDb()
status += selectAllMap->prepare();
// ----------
+ // select extid, source
+ // from channelmap where
+ // updflg = ?
+
+ selectMapByUpdFlg = new cDbStatement(mapDb);
+
+ selectMapByUpdFlg->build("select ");
+ selectMapByUpdFlg->bind("EXTERNALID", cDBS::bndOut);
+ selectMapByUpdFlg->bind("CHANNELID", cDBS::bndOut, ", ");
+ selectMapByUpdFlg->bind("SOURCE", cDBS::bndOut, ", ");
+ selectMapByUpdFlg->build(" from %s where ", mapDb->TableName());
+ selectMapByUpdFlg->bind("UPDFLG", cDBS::bndIn | cDBS::bndSet);
+
+ status += selectMapByUpdFlg->prepare();
+
+ // ----------
+ // select channelid
+ // from channelmap where
+ // updflg = ? and externalid = ? and source = ?
+
+ selectMapByExt = new cDbStatement(mapDb);
+
+ selectMapByExt->build("select ");
+ selectMapByExt->bind("CHANNELID", cDBS::bndOut);
+ selectMapByExt->build(" from %s where ", mapDb->TableName());
+ selectMapByExt->bind("UPDFLG", cDBS::bndIn | cDBS::bndSet);
+ selectMapByExt->bind("EXTERNALID", cDBS::bndIn | cDBS::bndSet, " and ");
+ selectMapByExt->bind("SOURCE", cDBS::bndIn | cDBS::bndSet, " and ");
+
+ status += selectMapByExt->prepare();
+
+ // ----------
// update useevents u, events e
// set
// u.sub_scrseriesid = e.scrseriesid,
@@ -1045,6 +1079,8 @@ int cEpgd::exitDb()
delete selectMaxMapOrd; selectMaxMapOrd = 0;
delete selectMapOrdOf; selectMapOrdOf = 0;
delete selectAllMap; selectAllMap = 0;
+ delete selectMapByUpdFlg; selectMapByUpdFlg = 0;
+ delete selectMapByExt; selectMapByExt = 0;
delete selectByCompTitle; selectByCompTitle = 0;
delete selectMaxUpdSp; selectMaxUpdSp = 0;
delete selectDistCompname; selectDistCompname = 0;