summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Dolze <vdr@dolze.de>2012-06-18 16:50:31 +0200
committerJochen Dolze <vdr@dolze.de>2012-06-18 16:50:31 +0200
commit3b4ec4e7f4b33eb5738481c6b8f577179d4275e3 (patch)
tree3c7cdfc7e14ab67daac06133910c2ffc718123ed
parente1fdf3f35890b74cd09987e54cdb691874bfec8a (diff)
downloadvdr-plugin-xmltv2vdr-3b4ec4e7f4b33eb5738481c6b8f577179d4275e3.tar.gz
vdr-plugin-xmltv2vdr-3b4ec4e7f4b33eb5738481c6b8f577179d4275e3.tar.bz2
Prevent update of wrong database events if eiteventids rotate daily
-rw-r--r--import.cpp21
-rw-r--r--parse.cpp9
2 files changed, 16 insertions, 14 deletions
diff --git a/import.cpp b/import.cpp
index 60d3f3f..cc49fce 100644
--- a/import.cpp
+++ b/import.cpp
@@ -729,6 +729,7 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule,
{
if (prev->EndTime()==next->StartTime())
{
+ // ok - no gap
localtime_r(&start,&tm);
strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm);
localtime_r(&end,&tm);
@@ -756,7 +757,7 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule,
if (end>next->StartTime())
{
int diff=(int) difftime(prev->EndTime(),start);
- if (diff>300)
+ if (diff>420)
{
localtime_r(&start,&tm);
@@ -1307,10 +1308,17 @@ cXMLTVEvent *cImport::SearchXMLTVEvent(sqlite3 **Db,const char *ChannelID, const
cXMLTVEvent *xevent=NULL;
char *sql=NULL;
+ int eventTimeDiff=0;
+ if (Event->Duration()) eventTimeDiff=Event->Duration()/4;
+ if (eventTimeDiff<100) eventTimeDiff=100;
+ if (eventTimeDiff>780) eventTimeDiff=780;
+
if (asprintf(&sql,"select channelid,eventid,starttime,duration,title,origtitle,shorttext,description," \
- "country,year,credits,category,review,rating,starrating,video,audio,season,episode,episodeoverall," \
- "pics,src,eiteventid,eitdescription from epg where eiteventid=%li and channelid='%s' " \
- "order by srcidx asc limit 1;",(long int) Event->EventID(),ChannelID)==-1)
+ "country,year,credits,category,review,rating,starrating,video,audio,season,episode," \
+ "episodeoverall,pics,src,eiteventid,eitdescription,abs(starttime-%li) as diff from epg where " \
+ " (starttime>=%li and starttime<=%li) and eiteventid=%u and channelid='%s' " \
+ " order by diff,srcidx asc limit 1;",Event->StartTime(),Event->StartTime()-eventTimeDiff,
+ Event->StartTime()+eventTimeDiff,Event->EventID(),ChannelID)==-1)
{
esyslog("out of memory");
return NULL;
@@ -1319,11 +1327,6 @@ cXMLTVEvent *cImport::SearchXMLTVEvent(sqlite3 **Db,const char *ChannelID, const
xevent=PrepareAndReturn(*Db,sql);
if (xevent) return xevent;
- int eventTimeDiff=0;
- if (Event->Duration()) eventTimeDiff=Event->Duration()/4;
- if (eventTimeDiff<100) eventTimeDiff=100;
- if (eventTimeDiff>780) eventTimeDiff=780;
-
char *sqltitle=strdup(Event->Title());
if (!sqltitle)
{
diff --git a/parse.cpp b/parse.cpp
index 251af86..d4f965c 100644
--- a/parse.cpp
+++ b/parse.cpp
@@ -697,12 +697,11 @@ int cParse::Process(cEPGExecutor &myExecutor,char *buffer, int bufsize)
"credits text, category text, review text, rating text, " \
"starrating text, video text, audio text, season int, episode int, " \
"episodeoverall int, pics text, srcidx int," \
- "PRIMARY KEY(src, channelid, eventid)" \
+ "PRIMARY KEY(eventid, src, channelid)" \
");" \
- "CREATE INDEX IF NOT EXISTS idx1 on epg (eventid, channelid); " \
- "CREATE INDEX IF NOT EXISTS idx2 on epg (eventid, src); " \
- "CREATE INDEX IF NOT EXISTS idx3 on epg (starttime, title, channelid); " \
- "CREATE INDEX IF NOT EXISTS idx4 on epg (starttime, src); " \
+ "CREATE INDEX IF NOT EXISTS idx1 on epg (starttime, eiteventid, channelid); " \
+ "CREATE INDEX IF NOT EXISTS idx2 on epg (starttime, title, channelid); " \
+ "CREATE INDEX IF NOT EXISTS idx3 on epg (starttime, duration, src); " \
"BEGIN";
char *errmsg;