From dab5ddc6d04a3f26ca3552aebb051f4d437a7434 Mon Sep 17 00:00:00 2001 From: Jochen Dolze Date: Thu, 9 Aug 2012 22:47:54 +0200 Subject: Added check for soundex function --- import.cpp | 38 ++++++++++++++++++++------------------ xmltv2vdr.cpp | 2 ++ xmltv2vdr.h | 9 +++++++++ 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/import.cpp b/import.cpp index de5d2a7..672e924 100644 --- a/import.cpp +++ b/import.cpp @@ -1411,27 +1411,29 @@ cXMLTVEvent *cImport::SearchXMLTVEvent(sqlite3 **Db,const char *ChannelID, const xevent=PrepareAndReturn(Db,sql); if (xevent) return xevent; - char wstr[128]; - if (SoundEx((char *) &wstr,(char *) Event->Title(),0,1)==0) + if (g->SoundEx()) { - esyslog("soundex of '%s' failed",Event->Title()); - return NULL; - } - - 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,alttitle,abs(starttime-%li) as diff from epg where " \ - " (starttime>=%li and starttime<=%li) and soundex(title)='%s' and channelid='%s' " \ - " order by diff,srcidx asc limit 1;",Event->StartTime(),Event->StartTime()-eventTimeDiff, - Event->StartTime()+eventTimeDiff,wstr,ChannelID)==-1) - { - esyslog("out of memory"); - return NULL; - } + char wstr[128]; + if (SoundEx((char *) &wstr,(char *) Event->Title(),0,1)==0) + { + esyslog("soundex of '%s' failed",Event->Title()); + return NULL; + } - xevent=PrepareAndReturn(Db,sql); - if (xevent) return xevent; + 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,alttitle,abs(starttime-%li) as diff from epg where " \ + " (starttime>=%li and starttime<=%li) and soundex(title)='%s' and channelid='%s' " \ + " order by diff,srcidx asc limit 1;",Event->StartTime(),Event->StartTime()-eventTimeDiff, + Event->StartTime()+eventTimeDiff,wstr,ChannelID)==-1) + { + esyslog("out of memory"); + return NULL; + } + xevent=PrepareAndReturn(Db,sql); + if (xevent) return xevent; + } return NULL; } diff --git a/xmltv2vdr.cpp b/xmltv2vdr.cpp index b0e3b7e..69ace7e 100644 --- a/xmltv2vdr.cpp +++ b/xmltv2vdr.cpp @@ -268,6 +268,7 @@ cGlobals::cGlobals() epall=0; order=strdup(GetDefaultOrder()); imgdelafter=30; + soundex=false; if (asprintf(&epgfile,"%s/epg.db",VideoDirectory)==-1) {}; if (asprintf(&imgdir,"%s","/var/cache/vdr/epgimages")==-1) {}; @@ -826,6 +827,7 @@ void cPluginXmltv2vdr::GetSqliteCompileOptions() { const char *option=(const char *) sqlite3_column_text(stmt,0); tsyslog("option %s",option); + if (!strncasecmp(option,"SOUNDEX",7)) g.SetSoundEx(); } else { diff --git a/xmltv2vdr.h b/xmltv2vdr.h index 72702d9..1570d0c 100644 --- a/xmltv2vdr.h +++ b/xmltv2vdr.h @@ -176,6 +176,7 @@ private: int epall; int imgdelafter; bool wakeup; + bool soundex; cEPGMappings epgmappings; cTEXTMappings textmappings; cEPGSources epgsources; @@ -302,6 +303,14 @@ public: { return wakeup; } + void SetSoundEx() + { + soundex=true; + } + bool SoundEx() + { + return soundex; + } }; class cPluginXmltv2vdr : public cPlugin -- cgit v1.2.3