summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--import.cpp74
-rw-r--r--import.h5
-rw-r--r--maps.h1
-rw-r--r--parse.cpp51
-rw-r--r--parse.h12
-rw-r--r--setup.cpp35
-rw-r--r--setup.h2
-rw-r--r--source.cpp15
-rw-r--r--source.h7
-rw-r--r--xmltv2vdr.cpp144
-rw-r--r--xmltv2vdr.h14
11 files changed, 188 insertions, 172 deletions
diff --git a/import.cpp b/import.cpp
index b802c81..e547910 100644
--- a/import.cpp
+++ b/import.cpp
@@ -12,7 +12,6 @@
#include <langinfo.h>
#include <pcrecpp.h>
#include <unistd.h>
-#include <pwd.h>
#include <sys/types.h>
#include <vdr/channels.h>
@@ -747,7 +746,7 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule,
description=RemoveLastCharFromDescription(description);
description=AddEOT2Description(description);
const char *dp=conv->Convert(description);
- if (!Event->Description() || strcmp(Event->Description(),dp))
+ if (!Event->Description() || strcasecmp(Event->Description(),dp))
{
Event->SetDescription(dp);
changed|=CHANGED_DESCRIPTION;
@@ -930,44 +929,15 @@ cXMLTVEvent *cImport::AddXMLTVEvent(cEPGSource *Source,sqlite3 *Db, const char *
if (!ChannelID) return NULL;
if (!Event) return NULL;
if (!EITDescription) return NULL;
-
- struct passwd pwd,*pwdbuf;
- char buf[1024],*epdir=NULL;
- iconv_t conv=(iconv_t) -1;
- getpwuid_r(getuid(),&pwd,buf,sizeof(buf),&pwdbuf);
- if (pwdbuf)
- {
- if (asprintf(&epdir,"%s/.eplists/lists",pwdbuf->pw_dir)!=-1)
- {
- if (access(epdir,R_OK))
- {
- free(epdir);
- epdir=NULL;
- }
- else
- {
- conv=iconv_open("US-ASCII//TRANSLIT","UTF-8");
- }
- }
- else
- {
- epdir=NULL;
- }
- }
if (!epdir) return NULL;
- if (conv==(iconv_t) -1)
- {
- free(epdir);
- return NULL;
- }
int season,episode;
- if (!cParse::FetchSeasonEpisode(conv,epdir,Event->Title(),
+ if (!cParse::FetchSeasonEpisode(cep2ascii,cutf2ascii,epdir,Event->Title(),
Event->ShortText(),season,episode))
{
- //tsyslogs(Source,"no season/episode found for '%s'/'%s'",Event->Title(),Event->ShortText());
- free(epdir);
- iconv_close(conv);
+#ifdef VDRDEBUG
+ tsyslogs(Source,"no season/episode found for '%s'/'%s'",Event->Title(),Event->ShortText());
+#endif
return NULL;
}
@@ -975,8 +945,6 @@ cXMLTVEvent *cImport::AddXMLTVEvent(cEPGSource *Source,sqlite3 *Db, const char *
if (!xevent)
{
esyslogs(Source,"out of memory");
- free(epdir);
- iconv_close(conv);
return NULL;
}
@@ -994,8 +962,6 @@ cXMLTVEvent *cImport::AddXMLTVEvent(cEPGSource *Source,sqlite3 *Db, const char *
if (!Begin(Source,Db))
{
delete xevent;
- free(epdir);
- iconv_close(conv);
return NULL;
}
@@ -1008,8 +974,6 @@ cXMLTVEvent *cImport::AddXMLTVEvent(cEPGSource *Source,sqlite3 *Db, const char *
delete xevent;
xevent=NULL;
}
- free(epdir);
- iconv_close(conv);
return xevent;
}
@@ -1382,7 +1346,7 @@ bool cImport::DBExists()
}
-cImport::cImport(const char *EPGFile, cEPGMappings* Maps, cTEXTMappings *Texts)
+cImport::cImport(const char *EPGFile, const char *EPDir, cEPGMappings* Maps, cTEXTMappings *Texts)
{
maps=Maps;
texts=Texts;
@@ -1409,10 +1373,36 @@ cImport::cImport(const char *EPGFile, cEPGMappings* Maps, cTEXTMappings *Texts)
isyslog("codeset is '%s'",codeset);
conv = new cCharSetConv("UTF-8",codeset);
+ if (EPDir)
+ {
+ epdir=strdup(EPDir);
+ if (!epdir) return;
+ char *charset=strchr((char *) epdir,',');
+ if (charset)
+ {
+ *charset=0;
+ }
+ else
+ {
+ charset=(char *) "UTF-8";
+ }
+ cep2ascii=iconv_open(charset,"US-ASCII//TRANSLIT");
+ cutf2ascii=iconv_open("UTF-8","US-ASCII//TRANSLIT");
+ }
+ else
+ {
+ epdir=NULL;
+ }
}
cImport::~cImport()
{
+ if (epdir)
+ {
+ free((void *) epdir);
+ iconv_close(cep2ascii);
+ iconv_close(cutf2ascii);
+ }
if (codeset) free(codeset);
delete conv;
}
diff --git a/import.h b/import.h
index 747fcbd..8ab709d 100644
--- a/import.h
+++ b/import.h
@@ -41,6 +41,9 @@ private:
cTEXTMappings *texts;
cCharSetConv *conv;
char *codeset;
+ iconv_t cep2ascii;
+ iconv_t cutf2ascii;
+ const char *epdir;
bool pendingtransaction;
const char *epgfile;
char *RemoveLastCharFromDescription(char *description);
@@ -55,7 +58,7 @@ private:
char *RemoveNonASCII(const char *src);
cXMLTVEvent *PrepareAndReturn(sqlite3 *db, char *sql);
public:
- cImport(const char *EPGFile, cEPGMappings *Maps, cTEXTMappings *Texts);
+ cImport(const char *EPGFile, const char *EPDir, cEPGMappings *Maps, cTEXTMappings *Texts);
~cImport();
int Process(cEPGSource *Source, cEPGExecutor &myExecutor);
bool Begin(cEPGSource *Source, sqlite3 *Db);
diff --git a/maps.h b/maps.h
index 042b596..e12a4c9 100644
--- a/maps.h
+++ b/maps.h
@@ -40,7 +40,6 @@
#define OPT_RATING_TEXT 0x1000000
#define OPT_CATEGORIES_TEXT 0x2000000
-#define OPT_MERGELTEXT 0x10000000
#define OPT_APPEND 0x40000000
class cTEXTMapping : public cListObject
diff --git a/parse.cpp b/parse.cpp
index 26c14fe..94520e3 100644
--- a/parse.cpp
+++ b/parse.cpp
@@ -149,15 +149,17 @@ void cParse::RemoveNonAlphaNumeric(char *String)
return;
}
-bool cParse::FetchSeasonEpisode(iconv_t Conv, const char *EPDir, const char *Title,
- const char *ShortText, int &Season, int &Episode)
+bool cParse::FetchSeasonEpisode(iconv_t cEP2ASCII, iconv_t cUTF2ASCII, const char *EPDir,
+ const char *Title, const char *ShortText, int &Season, int &Episode)
{
+ // Title and ShortText are always UTF8 !
if (!EPDir) return false;
if (!ShortText) return false;
size_t slen=strlen(ShortText);
if (!slen) return false;
if (!Title) return false;
- if (Conv==(iconv_t) -1) return false;
+ if (cEP2ASCII==(iconv_t) -1) return false;
+ if (cUTF2ASCII==(iconv_t) -1) return false;
DIR *dir=opendir(EPDir);
if (!dir) return false;
@@ -200,7 +202,7 @@ bool cParse::FetchSeasonEpisode(iconv_t Conv, const char *EPDir, const char *Tit
char *FromPtr=(char *) ShortText;
char *ToPtr=(char *) dshorttext;
- if (iconv(Conv,&FromPtr,&slen,&ToPtr,&dlen)==(size_t) -1)
+ if (iconv(cUTF2ASCII,&FromPtr,&slen,&ToPtr,&dlen)==(size_t) -1)
{
free(dshorttext);
fclose(f);
@@ -230,7 +232,7 @@ bool cParse::FetchSeasonEpisode(iconv_t Conv, const char *EPDir, const char *Tit
dlen=sizeof(depshorttext);
FromPtr=(char *) epshorttext;
ToPtr=(char *) depshorttext;
- if (iconv(Conv,&FromPtr,&slen,&ToPtr,&dlen)!=(size_t) -1)
+ if (iconv(cEP2ASCII,&FromPtr,&slen,&ToPtr,&dlen)!=(size_t) -1)
{
RemoveNonAlphaNumeric(depshorttext);
if (!strlen(depshorttext))
@@ -541,12 +543,11 @@ bool cParse::FetchEvent(xmlNodePtr enode)
}
int season,episode;
- if (FetchSeasonEpisode(conv,epdir,xevent.Title(),xevent.ShortText(),season,episode))
+ if (FetchSeasonEpisode(cep2ascii,cutf2ascii,epdir,xevent.Title(),xevent.ShortText(),season,episode))
{
xevent.SetSeason(season);
xevent.SetEpisode(episode);
}
-
return xevent.HasTitle();
}
@@ -757,33 +758,30 @@ void cParse::CleanupLibXML()
xmlCleanupParser();
}
-cParse::cParse(const char *EPGFile, cEPGSource *Source, cEPGMappings *Maps)
+cParse::cParse(const char *EPGFile, const char *EPDir, cEPGSource *Source, cEPGMappings *Maps)
{
source=Source;
maps=Maps;
epgfile=EPGFile;
-
- struct passwd pwd,*pwdbuf;
- char buf[1024];
- getpwuid_r(getuid(),&pwd,buf,sizeof(buf),&pwdbuf);
- if (pwdbuf)
+ if (EPDir)
{
- if (asprintf(&epdir,"%s/.eplists/lists",pwdbuf->pw_dir)!=-1)
+ epdir=strdup(EPDir);
+ if (!epdir) return;
+ char *charset=strchr((char *) epdir,',');
+ if (charset)
{
- if (access(epdir,R_OK))
- {
- free(epdir);
- epdir=NULL;
- }
- else
- {
- conv=iconv_open("US-ASCII//TRANSLIT","UTF-8");
- }
+ *charset=0;
}
else
{
- epdir=NULL;
+ charset=(char *) "UTF-8";
}
+ cep2ascii=iconv_open(charset,"US-ASCII//TRANSLIT");
+ cutf2ascii=iconv_open("UTF-8","US-ASCII//TRANSLIT");
+ }
+ else
+ {
+ epdir=NULL;
}
}
@@ -791,7 +789,8 @@ cParse::~cParse()
{
if (epdir)
{
- free(epdir);
- iconv_close(conv);
+ free((void *) epdir);
+ iconv_close(cep2ascii);
+ iconv_close(cutf2ascii);
}
}
diff --git a/parse.h b/parse.h
index 378e901..4c4e7a0 100644
--- a/parse.h
+++ b/parse.h
@@ -29,8 +29,9 @@ class cParse
};
private:
- iconv_t conv;
- char *epdir;
+ iconv_t cep2ascii;
+ iconv_t cutf2ascii;
+ const char *epdir;
const char *epgfile;
cEPGSource *source;
cEPGMappings *maps;
@@ -38,12 +39,13 @@ private:
time_t ConvertXMLTVTime2UnixTime(char *xmltvtime);
bool FetchEvent(xmlNodePtr node);
public:
- cParse(const char *EPGFile, cEPGSource *Source, cEPGMappings *Maps);
+ cParse(const char *EPGFile, const char *EPDir, cEPGSource *Source, cEPGMappings *Maps);
~cParse();
int Process(cEPGExecutor &myExecutor, char *buffer, int bufsize);
static void RemoveNonAlphaNumeric(char *String);
- static bool FetchSeasonEpisode(iconv_t Conv, const char *EPDir, const char *Title,
- const char *ShortText, int &Season, int &Episode);
+ static bool FetchSeasonEpisode(iconv_t cEP2ASCII, iconv_t cUTF2ASCII, const char *EPDir,
+ const char *Title, const char *ShortText, int &Season,
+ int &Episode);
static void InitLibXML();
static void CleanupLibXML();
};
diff --git a/setup.cpp b/setup.cpp
index 8efc82e..ab92147 100644
--- a/setup.cpp
+++ b/setup.cpp
@@ -10,7 +10,6 @@
#include <vdr/osdbase.h>
#include <vdr/i18n.h>
#include <time.h>
-#include <pwd.h>
#define CHNUMWIDTH (numdigits(Channels.MaxNumber())+1)
@@ -83,18 +82,9 @@ void cMenuSetupXmltv2vdr::Output(void)
Add(first,true);
epEntry=0;
- struct passwd *pw=getpwuid(getuid());
- if (pw)
+ if (baseplugin->EPDir())
{
- char *path=NULL;
- if (asprintf(&path,"%s/.eplists/lists",pw->pw_dir)!=-1)
- {
- if (!access(path,R_OK))
- {
- Add(new cMenuEditBoolItem(tr("add season/episode on all timers"),&epall),true);
- }
- free(path);
- }
+ Add(new cMenuEditBoolItem(tr("add season/episode on all timers"),&epall),true);
}
Add(new cMenuEditBoolItem(tr("automatic wakeup"),&wakeup),true);
@@ -837,7 +827,7 @@ cMenuSetupXmltv2vdrChannelMap::cMenuSetupXmltv2vdrChannelMap(cPluginXmltv2vdr *P
SetTitle(title);
flags=map->Flags();
- c1=c2=c3=cm=0;
+ c1=c3=cm=0;
SetHelp(NULL,NULL,tr("Button$Reset"),tr("Button$Copy"));
output();
}
@@ -905,11 +895,6 @@ void cMenuSetupXmltv2vdrChannelMap::output(void)
{
Add(new cMyMenuEditBitItem(tr("short text"),&flags,USE_SHORTTEXT),true);
Add(new cMyMenuEditBitItem(tr("long text"),&flags,USE_LONGTEXT),true);
- c2=Current();
- if ((flags & USE_LONGTEXT)==USE_LONGTEXT)
- {
- Add(new cMyMenuEditBitItem(tr(" merge long texts"),&flags,OPT_MERGELTEXT),true);
- }
}
else
{
@@ -939,16 +924,9 @@ void cMenuSetupXmltv2vdrChannelMap::output(void)
Add(new cMyMenuEditBitItem(tr("video"),&flags,USE_VIDEO),true);
Add(new cMyMenuEditBitItem(tr("audio"),&flags,USE_AUDIO),true);
- struct passwd *pw=getpwuid(getuid());
- if (pw)
+ if (baseplugin->EPDir())
{
- char *path=NULL;
- if (asprintf(&path,"%s/.eplists/lists",pw->pw_dir)!=-1)
- {
- if (!access(path,R_OK))
- Add(new cMyMenuEditBitItem(tr("season and episode"),&flags,USE_SEASON),true);
- free(path);
- }
+ Add(new cMyMenuEditBitItem(tr("season and episode"),&flags,USE_SEASON),true);
}
hasmaps=false;
@@ -1001,8 +979,7 @@ eOSState cMenuSetupXmltv2vdrChannelMap::ProcessKey(eKeys Key)
case kLeft|k_Repeat:
case kRight:
case kRight|k_Repeat:
- if ((Current()==c1) || (Current()==c2) ||
- (Current()==c3)) output();
+ if ((Current()==c1) || (Current()==c3)) output();
break;
case kDown:
case kDown|k_Repeat:
diff --git a/setup.h b/setup.h
index 55001c4..1fb46df 100644
--- a/setup.h
+++ b/setup.h
@@ -136,7 +136,7 @@ private:
int getdaysmax();
cOsdItem *option(const char *s, bool yesno);
void epgmappingreplace(cEPGMapping *newmapping);
- int c1,c2,c3,cm;
+ int c1,c3,cm;
public:
cMenuSetupXmltv2vdrChannelMap(cPluginXmltv2vdr *Plugin, cMenuSetupXmltv2vdr *Menu, int Index);
~cMenuSetupXmltv2vdrChannelMap();
diff --git a/source.cpp b/source.cpp
index cf7d539..d674970 100644
--- a/source.cpp
+++ b/source.cpp
@@ -109,7 +109,7 @@ void cEPGExecutor::Action()
// -------------------------------------------------------------
cEPGSource::cEPGSource(const char *Name, const char *ConfDir, const char *EPGFile,
- cEPGMappings *Maps, cTEXTMappings *Texts)
+ const char *EPDir, cEPGMappings *Maps, cTEXTMappings *Texts)
{
if (strcmp(Name,EITSOURCE))
{
@@ -132,8 +132,8 @@ cEPGSource::cEPGSource(const char *Name, const char *ConfDir, const char *EPGFil
if (strcmp(Name,EITSOURCE))
{
ready2parse=ReadConfig();
- parse=new cParse(EPGFile,this, Maps);
- import=new cImport(EPGFile,Maps,Texts);
+ parse=new cParse(EPGFile,EPDir,this, Maps);
+ import=new cImport(EPGFile,EPDir,Maps,Texts);
dsyslogs(this,"is%sready2parse",(ready2parse && parse) ? " " : " not ");
}
else
@@ -846,8 +846,9 @@ time_t cEPGSources::NextRunTime()
return next;
}
-void cEPGSources::ReadIn(const char *ConfDir, const char *EpgFile, cEPGMappings *EPGMappings,
- cTEXTMappings *TextMappings, const char *SourceOrder, bool Reload)
+void cEPGSources::ReadIn(const char *ConfDir, const char *EpgFile, const char *EPDir,
+ cEPGMappings *EPGMappings, cTEXTMappings *TextMappings,
+ const char *SourceOrder, bool Reload)
{
if (Reload) Remove();
DIR *dir=opendir(EPGSOURCES);
@@ -877,7 +878,7 @@ void cEPGSources::ReadIn(const char *ConfDir, const char *EpgFile, cEPGMappings
id[4]=0;
if (!strcmp(id,"file") || !strcmp(id,"pipe"))
{
- Add(new cEPGSource(dirent->d_name,ConfDir,EpgFile,EPGMappings,TextMappings));
+ Add(new cEPGSource(dirent->d_name,ConfDir,EpgFile,EPDir,EPGMappings,TextMappings));
}
else
{
@@ -903,7 +904,7 @@ void cEPGSources::ReadIn(const char *ConfDir, const char *EpgFile, cEPGMappings
if (!Exists(EITSOURCE))
{
- Add(new cEPGSource(EITSOURCE,ConfDir,EpgFile,EPGMappings,TextMappings));
+ Add(new cEPGSource(EITSOURCE,ConfDir,EpgFile,EPDir,EPGMappings,TextMappings));
}
if (!SourceOrder) return;
diff --git a/source.h b/source.h
index 751752d..1937a7a 100644
--- a/source.h
+++ b/source.h
@@ -71,7 +71,7 @@ private:
cEPGChannels channels;
public:
cEPGSource(const char *Name,const char *ConfDir,const char *EPGFile,
- cEPGMappings *Maps, cTEXTMappings *Texts);
+ const char *EPDir, cEPGMappings *Maps, cTEXTMappings *Texts);
~cEPGSource();
bool Trace()
{
@@ -156,8 +156,9 @@ public:
class cEPGSources : public cList<cEPGSource>
{
public:
- void ReadIn(const char *ConfDir, const char *EpgFile, cEPGMappings *EPGMappings,
- cTEXTMappings *TextMappings, const char *SourceOrder, bool Reload=false);
+ void ReadIn(const char *ConfDir, const char *EpgFile, const char *EPDir,
+ cEPGMappings *EPGMappings, cTEXTMappings *TextMappings,
+ const char *SourceOrder, bool Reload=false);
bool RunItNow();
time_t NextRunTime();
bool Exists(const char *Name);
diff --git a/xmltv2vdr.cpp b/xmltv2vdr.cpp
index 740438f..ada9c87 100644
--- a/xmltv2vdr.cpp
+++ b/xmltv2vdr.cpp
@@ -10,6 +10,9 @@
#include <unistd.h>
#include <getopt.h>
#include <stdarg.h>
+#include <sqlite3.h>
+#include <sys/types.h>
+#include <pwd.h>
#include "setup.h"
#include "xmltv2vdr.h"
@@ -121,8 +124,8 @@ void logger(cEPGSource *source, char logtype, const char* format, ...)
// -------------------------------------------------------------
-cEPGHandler::cEPGHandler(const char *EpgFile, cEPGSources *Sources,
- cEPGMappings *Maps, cTEXTMappings *Texts) : import(EpgFile,Maps,Texts)
+cEPGHandler::cEPGHandler(const char *EpgFile, const char *EPDir, cEPGSources *Sources,
+ cEPGMappings *Maps, cTEXTMappings *Texts) : import(EpgFile,EPDir,Maps,Texts)
{
epall=false;
maps=Maps;
@@ -139,39 +142,39 @@ bool cEPGHandler::IgnoreChannel(const cChannel* Channel)
return maps->IgnoreChannel(Channel);
}
-bool cEPGHandler::check4proc(cEvent *event, bool &spth)
+bool cEPGHandler::check4proc(cEvent *event, bool &spth, cEPGMapping **map)
{
+ if (map) *map=NULL;
spth=false;
if (!event) return false;
- /*
- if (import.WasChanged(event)) {
- tsyslog("{%i} already seen %s",Event->EventID(),Event->Title());
- }
- */
if (now>(event->StartTime()+event->Duration())) return false; // event in the past?
if (!maps) return false;
if (!import.DBExists()) return false;
- if (!maps->ProcessChannel(event->ChannelID()))
+ cEPGMapping *t_map=maps->GetMap(event->ChannelID());
+ if (!t_map)
{
if (!epall) return false;
if (!event->HasTimer()) return false;
if (!event->ShortText()) return false;
spth=true;
}
+ *map=t_map;
return true;
}
bool cEPGHandler::SetShortText(cEvent* Event, const char* ShortText)
{
bool seth;
- if (!check4proc(Event,seth)) return false;
+ if (!check4proc(Event,seth,NULL)) return false;
if (import.WasChanged(Event))
{
// ok we already changed this event!
+#ifdef VDRDEBUG
tsyslog("{%i} %salready seen stext '%s'",Event->EventID(),seth ? "*" : "",
Event->Title());
+#endif
return true;
}
// prevent setting empty shorttext
@@ -188,7 +191,7 @@ bool cEPGHandler::SetShortText(cEvent* Event, const char* ShortText)
bool cEPGHandler::SetDescription(cEvent* Event, const char* Description)
{
bool seth;
- if (!check4proc(Event,seth)) return false;
+ if (!check4proc(Event,seth,NULL)) return false;
if (import.WasChanged(Event))
{
@@ -202,8 +205,10 @@ bool cEPGHandler::SetDescription(cEvent* Event, const char* Description)
Event->Title());
return false;
}
+#ifdef VDRDEBUG
tsyslog("{%i} %salready seen descr '%s'",Event->EventID(),seth ? "*" : "",
Event->Title());
+#endif
return true;
}
tsyslog("{%i} %ssetting descr of '%s'",Event->EventID(),seth ? "*" : "",
@@ -215,7 +220,8 @@ bool cEPGHandler::SetDescription(cEvent* Event, const char* Description)
bool cEPGHandler::HandleEvent(cEvent* Event)
{
bool special_epall_timer_handling;
- if (!check4proc(Event,special_epall_timer_handling)) return false;
+ cEPGMapping *map;
+ if (!check4proc(Event,special_epall_timer_handling,&map)) return false;
int Flags=0;
const char *ChannelID=strdup(*Event->ChannelID().ToString());
@@ -227,13 +233,7 @@ bool cEPGHandler::HandleEvent(cEvent* Event)
}
else
{
- cEPGMapping *map=maps->GetMap(Event->ChannelID());
- if (!map)
- {
- tsyslog("no map for channel %s",ChannelID);
- free((void*)ChannelID);
- return false;
- }
+ // map is always set if seth is not set
Flags=map->Flags();
}
@@ -291,8 +291,8 @@ bool cEPGHandler::SortSchedule(cSchedule* UNUSED(Schedule))
// -------------------------------------------------------------
-cEPGTimer::cEPGTimer(const char *EpgFile, cEPGSources *Sources, cEPGMappings *Maps,
- cTEXTMappings *Texts) : cThread("xmltv2vdr timer"),import(EpgFile,Maps,Texts)
+cEPGTimer::cEPGTimer(const char *EpgFile, const char *EPDir, cEPGSources *Sources, cEPGMappings *Maps,
+ cTEXTMappings *Texts) : cThread("xmltv2vdr timer"),import(EpgFile,EPDir,Maps,Texts)
{
sources=Sources;
maps=Maps;
@@ -301,24 +301,18 @@ cEPGTimer::cEPGTimer(const char *EpgFile, cEPGSources *Sources, cEPGMappings *Ma
void cEPGTimer::Action()
{
if (!import.DBExists()) return; // no database? -> exit immediately
- if (Timers.BeingEdited()) return;
- Timers.IncBeingEdited();
SetPriority(19);
if (ioprio_set(1,getpid(),7 | 3 << 13)==-1)
{
dsyslog("failed to set ioprio to 3,7");
}
- cSchedulesLock *schedulesLock = NULL;
- const cSchedules *schedules = NULL;
- schedulesLock = new cSchedulesLock(true,10); // wait 10ms for lock!
- schedules = cSchedules::Schedules(*schedulesLock);
- if (!schedules)
- {
- delete schedulesLock;
- Timers.DecBeingEdited();
- return;
- }
+ cSchedulesLock schedulesLock(true,10); // wait 10ms for lock!
+ const cSchedules *schedules = cSchedules::Schedules(schedulesLock);
+ if (!schedules) return;
+
+ if (Timers.BeingEdited()) return;
+ Timers.IncBeingEdited();
sqlite3 *db=NULL;
cEPGSource *source=sources->GetSource(EITSOURCE);
@@ -359,7 +353,6 @@ void cEPGTimer::Action()
sqlite3_close(db);
}
Timers.DecBeingEdited();
- delete schedulesLock;
cSchedules::Cleanup(true);
}
@@ -372,15 +365,9 @@ cHouseKeeping::cHouseKeeping(const char *EPGFile): cThread("xmltv2vdr housekeepi
void cHouseKeeping::Action()
{
- cSchedulesLock *schedulesLock = NULL;
- const cSchedules *schedules = NULL;
- schedulesLock = new cSchedulesLock(true,10); // wait 10ms for lock!
- schedules = cSchedules::Schedules(*schedulesLock);
- if (!schedules)
- {
- delete schedulesLock;
- return;
- }
+ cSchedulesLock schedulesLock(true,10); // wait 10ms for lock!
+ const cSchedules *schedules = cSchedules::Schedules(schedulesLock);
+ if (!schedules) return;
sqlite3 *db=NULL;
if (sqlite3_open_v2(epgfile,&db,SQLITE_OPEN_READWRITE,NULL)==SQLITE_OK)
@@ -407,7 +394,6 @@ void cHouseKeeping::Action()
}
}
sqlite3_close(db);
- delete schedulesLock;
}
// -------------------------------------------------------------
@@ -423,6 +409,7 @@ cPluginXmltv2vdr::cPluginXmltv2vdr(void) : epgexecutor(&epgsources)
srcorder=NULL;
epghandler=NULL;
epgtimer=NULL;
+ epdir=NULL;
housekeeping=NULL;
last_housetime_t=0;
last_maintime_t=0;
@@ -525,11 +512,15 @@ bool cPluginXmltv2vdr::EPGSourceMove(int From, int To)
const char *cPluginXmltv2vdr::CommandLineHelp(void)
{
// Return a string that describes all known command line options.
- return " -E FILE, --epgfile=FILE write the EPG data into the given FILE (default is\n"
- " 'epg.db' in the video directory) - best performance\n"
- " if located on a ramdisk\n"
- " -l FILE --logfile=FILE write trace logs into the given FILE (default is\n"
- " no trace log\n";
+ return " -e DIR, --episodes=DIR location of episode files: VDRSeriesTimer .episodes\n"
+ " or TheTVDB .xml (default is ~/.eplists/lists,UTF8)\n"
+ " Add UTF-8 or ISO8859-15 to the path to specify the\n"
+ " charset used in the files, e.g. /vdr/myepisodes,UTF8\n"
+ " -E FILE, --epgfile=FILE write the EPG data into the given FILE (default is\n"
+ " 'epg.db' in the video directory) - best performance\n"
+ " if located on a ramdisk\n"
+ " -l FILE --logfile=FILE write trace logs into the given FILE (default is\n"
+ " no trace log\n";
}
@@ -538,24 +529,45 @@ bool cPluginXmltv2vdr::ProcessArgs(int argc, char *argv[])
// Command line argument processing
static struct option long_options[] =
{
+ { "episodes", required_argument, NULL, 'e'},
{ "epgfile", required_argument, NULL, 'E'},
{ "logfile", required_argument, NULL, 'l'},
{ 0,0,0,0 }
};
int c;
- while ((c = getopt_long(argc, argv, "E:l:", long_options, NULL)) != -1)
+ char *comma=NULL;
+ while ((c = getopt_long(argc, argv, "e:E:l:", long_options, NULL)) != -1)
{
switch (c)
{
+ case 'e':
+ if (epdir) free(epdir);
+ epdir=strdup(optarg);
+ if (!epdir) break;
+ comma=strchr(epdir,',');
+ if (comma) *comma=0;
+ if (access(epdir,R_OK)!=-1)
+ {
+ isyslog("using dir '%s' for episodes",epdir);
+ *comma=',';
+ }
+ else
+ {
+ free(epdir);
+ epdir=NULL;
+ }
+ break;
case 'E':
if (epgfile) free(epgfile);
epgfile=strdup(optarg);
+ if (!epgfile) break;
isyslog("using file '%s' for epgdata",optarg);
break;
case 'l':
if (logfile) free(logfile);
logfile=strdup(optarg);
+ if (!logfile) break;
isyslog("using file '%s' for log",optarg);
break;
default:
@@ -580,13 +592,34 @@ bool cPluginXmltv2vdr::Start(void)
{
if (asprintf(&epgfile,"%s/epg.db",VideoDirectory)==-1)return false;
}
+ if (!epdir)
+ {
+ struct passwd pwd,*pwdbuf;
+ char buf[1024];
+ getpwuid_r(getuid(),&pwd,buf,sizeof(buf),&pwdbuf);
+ if (pwdbuf)
+ {
+ if (asprintf(&epdir,"%s/.eplists/lists",pwdbuf->pw_dir)!=-1)
+ {
+ if (access(epdir,R_OK))
+ {
+ free(epdir);
+ epdir=NULL;
+ }
+ else
+ {
+ isyslog("using dir '%s' for episodes",epdir);
+ }
+ }
+ }
+ }
cParse::InitLibXML();
ReadInEPGSources();
- epghandler = new cEPGHandler(epgfile,&epgsources,&epgmappings,&textmappings);
- epgtimer = new cEPGTimer(epgfile,&epgsources,&epgmappings,&textmappings);
+ epghandler = new cEPGHandler(epgfile,epdir,&epgsources,&epgmappings,&textmappings);
+ epgtimer = new cEPGTimer(epgfile,epdir,&epgsources,&epgmappings,&textmappings);
housekeeping = new cHouseKeeping(epgfile);
-
+
if (sqlite3_threadsafe()==0) esyslog("sqlite3 not threadsafe!");
return true;
}
@@ -621,6 +654,11 @@ void cPluginXmltv2vdr::Stop(void)
free(epgfile);
epgfile=NULL;
}
+ if (epdir)
+ {
+ free(epdir);
+ epdir=NULL;
+ }
if (logfile)
{
free(logfile);
diff --git a/xmltv2vdr.h b/xmltv2vdr.h
index 6210d98..85691b9 100644
--- a/xmltv2vdr.h
+++ b/xmltv2vdr.h
@@ -68,9 +68,9 @@ private:
bool epall;
sqlite3 *db;
time_t now;
- bool check4proc(cEvent *event, bool &spth);
+ bool check4proc(cEvent *event, bool &spth, cEPGMapping **map);
public:
- cEPGHandler(const char *EpgFile, cEPGSources *Sources,
+ cEPGHandler(const char *EpgFile, const char *EPDir, cEPGSources *Sources,
cEPGMappings *Maps, cTEXTMappings *Texts);
void SetEPAll(bool Value)
{
@@ -94,7 +94,8 @@ private:
cEPGMappings *maps;
cImport import;
public:
- cEPGTimer(const char *EpgFile, cEPGSources *Sources, cEPGMappings *Maps,cTEXTMappings *Texts);
+ cEPGTimer(const char *EpgFile, const char *EPDir, cEPGSources *Sources,
+ cEPGMappings *Maps,cTEXTMappings *Texts);
bool StillRunning()
{
return Running();
@@ -130,6 +131,7 @@ private:
time_t last_epcheck_t;
char *confdir;
char *epgfile;
+ char *epdir;
char *srcorder;
bool epall;
bool wakeup;
@@ -157,9 +159,13 @@ public:
{
return wakeup;
}
+ const char *EPDir()
+ {
+ return epdir;
+ }
void ReadInEPGSources(bool Reload=false)
{
- epgsources.ReadIn(confdir,epgfile,&epgmappings,&textmappings,srcorder,Reload);
+ epgsources.ReadIn(confdir,epgfile,epdir,&epgmappings,&textmappings,srcorder,Reload);
}
bool EPGSourceMove(int From, int To);
int EPGSourceCount()