diff options
author | Jochen Dolze <vdr@dolze.de> | 2012-05-19 17:57:50 +0200 |
---|---|---|
committer | Jochen Dolze <vdr@dolze.de> | 2012-05-19 17:57:50 +0200 |
commit | fba8c36e477d8b149b9ea78221f8397d04f849e5 (patch) | |
tree | be77731c7d239af4e0b094e2578a8df8a9e57142 | |
parent | b05fade925bd301abd7310d55daf33cfe7078714 (diff) | |
download | vdr-plugin-xmltv2vdr-fba8c36e477d8b149b9ea78221f8397d04f849e5.tar.gz vdr-plugin-xmltv2vdr-fba8c36e477d8b149b9ea78221f8397d04f849e5.tar.bz2 |
Changed search algo for existing events (max. difftime 780s)
Improved log output
-rw-r--r-- | event.cpp | 4 | ||||
-rw-r--r-- | import.cpp | 23 | ||||
-rw-r--r-- | parse.cpp | 43 | ||||
-rw-r--r-- | setup.cpp | 14 | ||||
-rw-r--r-- | xmltv2vdr.cpp | 1 |
5 files changed, 64 insertions, 21 deletions
@@ -300,7 +300,7 @@ const char *cXMLTVEvent::GetSQL(const char *Source, int SrcIdx, const char *Chan if (asprintf(&sql,"INSERT OR IGNORE INTO epg (src,channelid,eventid,starttime,duration,"\ "title,origtitle,shorttext,description,country,year,credits,category,"\ "review,rating,starrating,video,audio,season,episode,episodeoverall,pics,srcidx) "\ - "VALUES (^%s^,^%s^,%i,%li,%i,"\ + "VALUES (^%s^,^%s^,%u,%li,%i,"\ "^%s^,^%s^,^%s^,^%s^,^%s^,%i,^%s^,^%s^,"\ "^%s^,^%s^,^%s^,^%s^,^%s^,%i,%i,%i,^%s^,%i);"\ @@ -308,7 +308,7 @@ const char *cXMLTVEvent::GetSQL(const char *Source, int SrcIdx, const char *Chan "shorttext=^%s^,description=^%s^,country=^%s^,year=%i,credits=^%s^,category=^%s^,"\ "review=^%s^,rating=^%s^,starrating=^%s^,video=^%s^,audio=^%s^,season=%i,episode=%i, "\ "episodeoverall=%i,pics=^%s^,srcidx=%i " \ - " where changes()=0 and src=^%s^ and channelid=^%s^ and eventid=%i" + " where changes()=0 and src=^%s^ and channelid=^%s^ and eventid=%u" , Source,ChannelID,eventid,starttime,duration,title, origtitle ? origtitle : "NULL", @@ -90,16 +90,24 @@ cEvent *cImport::SearchVDREvent(cEPGSource *source, cSchedule* schedule, cXMLTVE // try to find an event, // 1st with our own EventID if (xevent->EITEventID()) f=(cEvent *) schedule->GetEvent(xevent->EITEventID()); - if (f) return f; + if (f) + { + return f; + } if (xevent->EventID() && append) f=(cEvent *) schedule->GetEvent(xevent->EventID()); - if (f) return f; + if (f) + { + return f; + } + + const char *cxTitle=conv->Convert(xevent->Title()); // 2nd with StartTime f=(cEvent *) schedule->GetEvent((tEventID) 0,xevent->StartTime()); if (f) { - if (!strcmp(f->Title(),conv->Convert(xevent->Title()))) + if (!strcmp(f->Title(),cxTitle)) { return f; } @@ -108,7 +116,8 @@ cEvent *cImport::SearchVDREvent(cEPGSource *source, cSchedule* schedule, cXMLTVE int maxdiff=INT_MAX; int eventTimeDiff=0; if (xevent->Duration()) eventTimeDiff=xevent->Duration()/4; - if (eventTimeDiff<780) eventTimeDiff=780; + if (eventTimeDiff<100) eventTimeDiff=100; + if (eventTimeDiff>780) eventTimeDiff=780; for (cEvent *p = schedule->Events()->First(); p; p = schedule->Events()->Next(p)) { @@ -116,7 +125,7 @@ cEvent *cImport::SearchVDREvent(cEPGSource *source, cSchedule* schedule, cXMLTVE if (diff<=eventTimeDiff) { // found event with exact the same title - if (!strcmp(p->Title(),conv->Convert(xevent->Title()))) + if (!strcmp(p->Title(),cxTitle)) { if (diff<=maxdiff) { @@ -136,7 +145,7 @@ cEvent *cImport::SearchVDREvent(cEPGSource *source, cSchedule* schedule, cXMLTVE // 0x20,0x30-0x39,0x41-0x5A,0x61-0x7A int wfound=0; char *s1=RemoveNonASCII(p->Title()); - char *s2=RemoveNonASCII(conv->Convert(xevent->Title())); + char *s2=RemoveNonASCII(cxTitle); if (s1 && s2) { if (!strcmp(s1,s2)) @@ -170,7 +179,7 @@ cEvent *cImport::SearchVDREvent(cEPGSource *source, cSchedule* schedule, cXMLTVE if (diff<=maxdiff) { if (!WasChanged(p)) - tsyslogs(source,"found '%s' for '%s'",p->Title(),conv->Convert(xevent->Title())); + tsyslogs(source,"found '%s' for '%s'",p->Title(),cxTitle); f=p; maxdiff=diff; } @@ -706,8 +706,9 @@ int cParse::Process(cEPGExecutor &myExecutor,char *buffer, int bufsize) time_t begin=time(NULL)-7200; xmlNodePtr node=rootnode->xmlChildrenNode; - int lerr=0; - int cnt=0; + int lerr=0,lweak=0; + xmlChar *lastchannelid=NULL; + int skipped=0; while (node) { if (node->type!=XML_ELEMENT_NODE) @@ -727,18 +728,24 @@ int cParse::Process(cEPGExecutor &myExecutor,char *buffer, int bufsize) esyslogs(source,"missing channelid in xmltv file"); lerr=PARSE_NOCHANNELID; node=node->next; + skipped++; continue; } cEPGMapping *map=maps->GetMap((const char *) channelid); if (!map) { - if (lerr!=PARSE_NOMAPPING) + if ((lerr!=PARSE_NOMAPPING) || (lastchannelid && xmlStrcmp(channelid,lastchannelid))) esyslogs(source,"no mapping for channelid %s",channelid); lerr=PARSE_NOMAPPING; + if (lastchannelid) xmlFree(lastchannelid); + lastchannelid=xmlStrdup(channelid); xmlFree(channelid); node=node->next; + skipped++; continue; } + if (lastchannelid) xmlFree(lastchannelid); + lastchannelid=xmlStrdup(channelid); xmlFree(channelid); xmlChar *start,*stop; @@ -766,12 +773,14 @@ int cParse::Process(cEPGExecutor &myExecutor,char *buffer, int bufsize) esyslogs(source,"no starttime, check xmltv file"); lerr=PARSE_XMLTVERR; node=node->next; + skipped++; continue; } if (starttime<begin) { node=node->next; + skipped++; continue; } xevent.Clear(); @@ -784,14 +793,20 @@ int cParse::Process(cEPGExecutor &myExecutor,char *buffer, int bufsize) esyslogs(source,"failed to fetch event"); lerr=PARSE_FETCHERR; node=node->next; + skipped++; continue; } + xmlErrorPtr xmlerr=xmlGetLastError(); + if (xmlerr && xmlerr->code) + { + esyslogs(source,"%s",xmlerr->message); + } if (!xevent.EventID()) { - if (lerr!=PARSE_NOEVENTID) - isyslogs(source,"event without id, using weak id!"); - lerr=PARSE_NOEVENTID; + if (lweak!=PARSE_NOEVENTID) + isyslogs(source,"event without id, using starttime as id (weak)!"); + lweak=PARSE_NOEVENTID; } for (int i=0; i<map->NumChannelIDs(); i++) @@ -806,8 +821,6 @@ int cParse::Process(cEPGExecutor &myExecutor,char *buffer, int bufsize) break; } } - cnt++; - node=node->next; if (!myExecutor.StillRunning()) { @@ -816,6 +829,17 @@ int cParse::Process(cEPGExecutor &myExecutor,char *buffer, int bufsize) } } + if (sqlite3_exec(db,"COMMIT",NULL,NULL,&errmsg)!=SQLITE_OK) + { + esyslogs(source,"sqlite3: %s",errmsg); + sqlite3_free(errmsg); + } + + int cnt=sqlite3_total_changes(db); + + if (skipped) + isyslogs(source,"skipped %i xmltv events",skipped); + if (!lerr) { isyslogs(source,"processed %i xmltv events",cnt); @@ -823,10 +847,9 @@ int cParse::Process(cEPGExecutor &myExecutor,char *buffer, int bufsize) else { isyslogs(source,"processed %i xmltv events - see ERRORs above!",cnt); - } - if (sqlite3_exec(db,"COMMIT; ANALYZE epg;",NULL,NULL,&errmsg)!=SQLITE_OK) + if (sqlite3_exec(db,"ANALYZE epg;",NULL,NULL,&errmsg)!=SQLITE_OK) { esyslogs(source,"sqlite3: %s",errmsg); sqlite3_free(errmsg); @@ -147,7 +147,19 @@ void cMenuSetupXmltv2vdr::Output(void) cEPGMapping *map=baseplugin->EPGMapping(channels[i]); if (map) { - if (map->NumChannelIDs()) mapped=true; + for (int x=0; x<map->NumChannelIDs(); x++) + { + cChannel *chan=Channels.GetByChannelID(map->ChannelIDs()[x]); + if (chan) + { + mapped=true; + } + else + { + // invalid channelid? remove from list + map->RemoveChannel(map->ChannelIDs()[x],true); + } + } } cString buffer = cString::sprintf("%s:\t%s",channels[i],mapped ? tr("mapped") : ""); Add(new cOsdItem(buffer),true); diff --git a/xmltv2vdr.cpp b/xmltv2vdr.cpp index 420ad7b..4ba7d6f 100644 --- a/xmltv2vdr.cpp +++ b/xmltv2vdr.cpp @@ -804,7 +804,6 @@ bool cPluginXmltv2vdr::Start(void) void cPluginXmltv2vdr::Stop(void) { // Stop any background activities the plugin is performing. - cSchedules::Cleanup(true); if (epgtimer) { epgtimer->Stop(); |