summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Dolze <vdr@dolze.de>2012-04-27 21:19:40 +0200
committerJochen Dolze <vdr@dolze.de>2012-04-27 21:19:40 +0200
commitc9a685f765354edbd90ca999ba9fabcdbd570b5d (patch)
tree2092e8a62e63498573ce71a42823b5a569e2df28
parent40889067514769b356eb50d60d6a75889aeb99e3 (diff)
downloadvdr-plugin-xmltv2vdr-c9a685f765354edbd90ca999ba9fabcdbd570b5d.tar.gz
vdr-plugin-xmltv2vdr-c9a685f765354edbd90ca999ba9fabcdbd570b5d.tar.bz2
Changed error output for sqlite3_prepare_v2
Moved codeset recognition to start function
-rw-r--r--README13
-rw-r--r--import.cpp34
-rw-r--r--import.h8
-rw-r--r--source.cpp15
-rw-r--r--source.h8
-rw-r--r--xmltv2vdr.cpp69
-rw-r--r--xmltv2vdr.h12
7 files changed, 95 insertions, 64 deletions
diff --git a/README b/README
index dddf965..a8ae3f5 100644
--- a/README
+++ b/README
@@ -15,8 +15,8 @@ See the file COPYING for more information.
Description:
Add epg info from epg sources into vdr. xmltv2vdr just imports data in
-xmltv format which must be provided by an external source (which is not
-part of this package)
+xmltv format which must be provided by an external source (please look
+into the dist directory for sources)
Interface for sources:
@@ -28,8 +28,11 @@ pipe (binary with the same name is called by xmltv2vdr-plugin, and
must be in the path). There can be additional fields in the first
line seperated with semicolons. The second option gives the time when
the epg data will be updated from the origin, the third option informs
-the plugin, if a pin is needed for this source (0/1).
-The second line shows the maximum days which will be provieded.
+the plugin, if a pin is needed for this source (0/1), the fourth option
+is used to determine if the source is providing epgimages (files
+must be placed in /var/lib/epgsources under a directory with a name
+similar to the name of the source)
+The second line shows the maximum days which will be provided.
The next lines are unique channelnames, provided by the source.
There can be application dependend data after each channelname. Note,
that the plugin/VDR must be able to read this control file.
@@ -53,7 +56,7 @@ rtl.de
sat1.de
prosieben.de
-file
+file;05:15;0;1
7
rtl.de;004
sat1.de;005
diff --git a/import.cpp b/import.cpp
index e547910..e633e3e 100644
--- a/import.cpp
+++ b/import.cpp
@@ -8,8 +8,6 @@
#include <sqlite3.h>
#include <ctype.h>
#include <time.h>
-#include <locale.h>
-#include <langinfo.h>
#include <pcrecpp.h>
#include <unistd.h>
#include <sys/types.h>
@@ -905,7 +903,7 @@ cXMLTVEvent *cImport::PrepareAndReturn(sqlite3 *db, char *sql)
int ret=sqlite3_prepare_v2(db,sql,strlen(sql),&stmt,NULL);
if (ret!=SQLITE_OK)
{
- esyslog("%i %s",ret,sqlite3_errmsg(db));
+ esyslog("%i %s (par)",ret,sqlite3_errmsg(db));
free(sql);
return NULL;
}
@@ -1242,10 +1240,11 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor)
}
sqlite3_stmt *stmt;
- if (sqlite3_prepare_v2(db,sql,strlen(sql),&stmt,NULL)!=SQLITE_OK)
+ int ret=sqlite3_prepare_v2(db,sql,strlen(sql),&stmt,NULL);
+ if (ret!=SQLITE_OK)
{
+ esyslogs(Source,"%i %s (p)",ret,sqlite3_errmsg(db));
sqlite3_close(db);
- esyslogs(Source,"failed to prepare %s",sql);
free(sql);
delete schedulesLock;
return 141;
@@ -1346,31 +1345,13 @@ bool cImport::DBExists()
}
-cImport::cImport(const char *EPGFile, const char *EPDir, cEPGMappings* Maps, cTEXTMappings *Texts)
+cImport::cImport(const char *EPGFile, const char *EPDir, const char *CodeSet, cEPGMappings* Maps, cTEXTMappings *Texts)
{
maps=Maps;
texts=Texts;
pendingtransaction=false;
epgfile=EPGFile;
-
- codeset=NULL;
- if (setlocale(LC_CTYPE,""))
- codeset=strdup(nl_langinfo(CODESET));
- else
- {
- char *LangEnv=getenv("LANG");
- if (LangEnv)
- {
- codeset=strdup(strchr(LangEnv,'.'));
- if (codeset)
- codeset++; // skip dot
- }
- }
- if (!codeset)
- {
- codeset=strdup("US-ASCII//TRANSLIT");
- }
- isyslog("codeset is '%s'",codeset);
+ codeset=CodeSet;
conv = new cCharSetConv("UTF-8",codeset);
if (EPDir)
@@ -1390,7 +1371,7 @@ cImport::cImport(const char *EPGFile, const char *EPDir, cEPGMappings* Maps, cTE
cutf2ascii=iconv_open("UTF-8","US-ASCII//TRANSLIT");
}
else
- {
+ {
epdir=NULL;
}
}
@@ -1403,6 +1384,5 @@ cImport::~cImport()
iconv_close(cep2ascii);
iconv_close(cutf2ascii);
}
- if (codeset) free(codeset);
delete conv;
}
diff --git a/import.h b/import.h
index 8ab709d..b278cae 100644
--- a/import.h
+++ b/import.h
@@ -40,10 +40,10 @@ private:
cEPGMappings *maps;
cTEXTMappings *texts;
cCharSetConv *conv;
- char *codeset;
+ const char *codeset;
iconv_t cep2ascii;
iconv_t cutf2ascii;
- const char *epdir;
+ const char *epdir;
bool pendingtransaction;
const char *epgfile;
char *RemoveLastCharFromDescription(char *description);
@@ -58,7 +58,7 @@ private:
char *RemoveNonASCII(const char *src);
cXMLTVEvent *PrepareAndReturn(sqlite3 *db, char *sql);
public:
- cImport(const char *EPGFile, const char *EPDir, cEPGMappings *Maps, cTEXTMappings *Texts);
+ cImport(const char *EPGFile, const char *EPDir, const char *CodeSet, cEPGMappings *Maps, cTEXTMappings *Texts);
~cImport();
int Process(cEPGSource *Source, cEPGExecutor &myExecutor);
bool Begin(cEPGSource *Source, sqlite3 *Db);
@@ -67,7 +67,7 @@ public:
bool PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule, cEvent *Event,
cXMLTVEvent *xEvent, int Flags);
bool UpdateXMLTVEvent(cEPGSource *Source, sqlite3 *Db, const cEvent *Event, cXMLTVEvent *xEvent,
- const char *Description);
+ const char *Description);
cXMLTVEvent *SearchXMLTVEvent(sqlite3 **Db, const char *ChannelID, const cEvent *Event);
cXMLTVEvent *AddXMLTVEvent(cEPGSource *Source, sqlite3 *Db, const char *ChannelID,
const cEvent *Event, const char *EITDescription);
diff --git a/source.cpp b/source.cpp
index d674970..501e700 100644
--- a/source.cpp
+++ b/source.cpp
@@ -109,7 +109,8 @@ void cEPGExecutor::Action()
// -------------------------------------------------------------
cEPGSource::cEPGSource(const char *Name, const char *ConfDir, const char *EPGFile,
- const char *EPDir, cEPGMappings *Maps, cTEXTMappings *Texts)
+ const char *EPDir, const char *CodeSet, cEPGMappings *Maps,
+ cTEXTMappings *Texts)
{
if (strcmp(Name,EITSOURCE))
{
@@ -133,7 +134,7 @@ cEPGSource::cEPGSource(const char *Name, const char *ConfDir, const char *EPGFil
{
ready2parse=ReadConfig();
parse=new cParse(EPGFile,EPDir,this, Maps);
- import=new cImport(EPGFile,EPDir,Maps,Texts);
+ import=new cImport(EPGFile,EPDir,CodeSet,Maps,Texts);
dsyslogs(this,"is%sready2parse",(ready2parse && parse) ? " " : " not ");
}
else
@@ -847,8 +848,9 @@ time_t cEPGSources::NextRunTime()
}
void cEPGSources::ReadIn(const char *ConfDir, const char *EpgFile, const char *EPDir,
- cEPGMappings *EPGMappings, cTEXTMappings *TextMappings,
- const char *SourceOrder, bool Reload)
+ const char *CodeSet, cEPGMappings *EPGMappings,
+ cTEXTMappings *TextMappings, const char *SourceOrder,
+ bool Reload)
{
if (Reload) Remove();
DIR *dir=opendir(EPGSOURCES);
@@ -878,7 +880,7 @@ void cEPGSources::ReadIn(const char *ConfDir, const char *EpgFile, const char *E
id[4]=0;
if (!strcmp(id,"file") || !strcmp(id,"pipe"))
{
- Add(new cEPGSource(dirent->d_name,ConfDir,EpgFile,EPDir,EPGMappings,TextMappings));
+ Add(new cEPGSource(dirent->d_name,ConfDir,EpgFile,EPDir,CodeSet,EPGMappings,TextMappings));
}
else
{
@@ -904,7 +906,8 @@ void cEPGSources::ReadIn(const char *ConfDir, const char *EpgFile, const char *E
if (!Exists(EITSOURCE))
{
- Add(new cEPGSource(EITSOURCE,ConfDir,EpgFile,EPDir,EPGMappings,TextMappings));
+ Add(new cEPGSource(EITSOURCE,ConfDir,EpgFile,EPDir,CodeSet,
+ EPGMappings,TextMappings));
}
if (!SourceOrder) return;
diff --git a/source.h b/source.h
index 1937a7a..b62c772 100644
--- a/source.h
+++ b/source.h
@@ -71,7 +71,8 @@ private:
cEPGChannels channels;
public:
cEPGSource(const char *Name,const char *ConfDir,const char *EPGFile,
- const char *EPDir, cEPGMappings *Maps, cTEXTMappings *Texts);
+ const char *EPDir, const char *CodeSet, cEPGMappings *Maps,
+ cTEXTMappings *Texts);
~cEPGSource();
bool Trace()
{
@@ -157,8 +158,9 @@ class cEPGSources : public cList<cEPGSource>
{
public:
void ReadIn(const char *ConfDir, const char *EpgFile, const char *EPDir,
- cEPGMappings *EPGMappings, cTEXTMappings *TextMappings,
- const char *SourceOrder, bool Reload=false);
+ const char *CodeSet, 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 ada9c87..f44a89f 100644
--- a/xmltv2vdr.cpp
+++ b/xmltv2vdr.cpp
@@ -10,6 +10,8 @@
#include <unistd.h>
#include <getopt.h>
#include <stdarg.h>
+#include <locale.h>
+#include <langinfo.h>
#include <sqlite3.h>
#include <sys/types.h>
#include <pwd.h>
@@ -124,8 +126,8 @@ void logger(cEPGSource *source, char logtype, const char* format, ...)
// -------------------------------------------------------------
-cEPGHandler::cEPGHandler(const char *EpgFile, const char *EPDir, cEPGSources *Sources,
- cEPGMappings *Maps, cTEXTMappings *Texts) : import(EpgFile,EPDir,Maps,Texts)
+cEPGHandler::cEPGHandler(const char *EpgFile, const char *EPDir, const char *CodeSet, cEPGSources *Sources,
+ cEPGMappings *Maps, cTEXTMappings *Texts) : import(EpgFile,EPDir,CodeSet,Maps,Texts)
{
epall=false;
maps=Maps;
@@ -291,8 +293,8 @@ bool cEPGHandler::SortSchedule(cSchedule* UNUSED(Schedule))
// -------------------------------------------------------------
-cEPGTimer::cEPGTimer(const char *EpgFile, const char *EPDir, cEPGSources *Sources, cEPGMappings *Maps,
- cTEXTMappings *Texts) : cThread("xmltv2vdr timer"),import(EpgFile,EPDir,Maps,Texts)
+cEPGTimer::cEPGTimer(const char *EpgFile, const char *EPDir, const char *CodeSet, cEPGSources *Sources, cEPGMappings *Maps,
+ cTEXTMappings *Texts) : cThread("xmltv2vdr timer"),import(EpgFile,EPDir,CodeSet,Maps,Texts)
{
sources=Sources;
maps=Maps;
@@ -411,6 +413,7 @@ cPluginXmltv2vdr::cPluginXmltv2vdr(void) : epgexecutor(&epgsources)
epgtimer=NULL;
epdir=NULL;
housekeeping=NULL;
+ codeset=NULL;
last_housetime_t=0;
last_maintime_t=0;
last_epcheck_t=0;
@@ -458,10 +461,12 @@ int cPluginXmltv2vdr::GetLastImportSource()
char sql[]="select srcidx from epg where srcidx<>99 order by starttime desc limit 1";
sqlite3_stmt *stmt;
- if (sqlite3_prepare_v2(db,sql,strlen(sql),&stmt,NULL)!=SQLITE_OK)
+
+ int ret=sqlite3_prepare_v2(db,sql,strlen(sql),&stmt,NULL);
+ if (ret!=SQLITE_OK)
{
+ esyslog("%i %s (glis)",ret,sqlite3_errmsg(db));
sqlite3_close(db);
- tsyslog("failed to prepare %s",sql);
return -1;
}
@@ -537,7 +542,7 @@ bool cPluginXmltv2vdr::ProcessArgs(int argc, char *argv[])
int c;
char *comma=NULL;
- while ((c = getopt_long(argc, argv, "e:E:l:", long_options, NULL)) != -1)
+ while ((c = getopt_long(argc, argv, "l:e:E:", long_options, NULL)) != -1)
{
switch (c)
{
@@ -549,7 +554,6 @@ bool cPluginXmltv2vdr::ProcessArgs(int argc, char *argv[])
if (comma) *comma=0;
if (access(epdir,R_OK)!=-1)
{
- isyslog("using dir '%s' for episodes",epdir);
*comma=',';
}
else
@@ -562,13 +566,13 @@ bool cPluginXmltv2vdr::ProcessArgs(int argc, char *argv[])
if (epgfile) free(epgfile);
epgfile=strdup(optarg);
if (!epgfile) break;
- isyslog("using file '%s' for epgdata",optarg);
+// 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);
+// isyslog("using file '%s' for log",optarg);
break;
default:
return false;
@@ -592,6 +596,7 @@ bool cPluginXmltv2vdr::Start(void)
{
if (asprintf(&epgfile,"%s/epg.db",VideoDirectory)==-1)return false;
}
+ isyslog("using file '%s' for epg database",epgfile);
if (!epdir)
{
struct passwd pwd,*pwdbuf;
@@ -608,19 +613,50 @@ bool cPluginXmltv2vdr::Start(void)
}
else
{
- isyslog("using dir '%s' for episodes",epdir);
+ isyslog("using dir '%s' (UTF-8) for episodes",epdir);
}
}
}
}
- cParse::InitLibXML();
+ else
+ {
+ char *cs=strchr(epdir,',');
+ if (cs)
+ {
+ *cs=0;
+ isyslog("using dir '%s' (%s) for episodes",epdir,cs+1);
+ *cs=',';
+ }
+ else
+ {
+ isyslog("using dir '%s' (UTF-8) for episodes",epdir);
+ }
+ }
+ if (setlocale(LC_CTYPE,""))
+ codeset=strdup(nl_langinfo(CODESET));
+ else
+ {
+ char *LangEnv=getenv("LANG");
+ if (LangEnv)
+ {
+ codeset=strdup(strchr(LangEnv,'.'));
+ if (codeset)
+ codeset++; // skip dot
+ }
+ }
+ if (!codeset)
+ {
+ codeset=strdup("US-ASCII//TRANSLIT");
+ }
+ isyslog("codeset is '%s'",codeset);
ReadInEPGSources();
- epghandler = new cEPGHandler(epgfile,epdir,&epgsources,&epgmappings,&textmappings);
- epgtimer = new cEPGTimer(epgfile,epdir,&epgsources,&epgmappings,&textmappings);
+ epghandler = new cEPGHandler(epgfile,epdir,codeset,&epgsources,&epgmappings,&textmappings);
+ epgtimer = new cEPGTimer(epgfile,epdir,codeset,&epgsources,&epgmappings,&textmappings);
housekeeping = new cHouseKeeping(epgfile);
if (sqlite3_threadsafe()==0) esyslog("sqlite3 not threadsafe!");
+ cParse::InitLibXML();
return true;
}
@@ -669,6 +705,11 @@ void cPluginXmltv2vdr::Stop(void)
free(srcorder);
srcorder=NULL;
}
+ if (codeset)
+ {
+ free(codeset);
+ codeset=NULL;
+ }
}
void cPluginXmltv2vdr::Housekeeping(void)
diff --git a/xmltv2vdr.h b/xmltv2vdr.h
index 85691b9..30b6354 100644
--- a/xmltv2vdr.h
+++ b/xmltv2vdr.h
@@ -70,8 +70,8 @@ private:
time_t now;
bool check4proc(cEvent *event, bool &spth, cEPGMapping **map);
public:
- cEPGHandler(const char *EpgFile, const char *EPDir, cEPGSources *Sources,
- cEPGMappings *Maps, cTEXTMappings *Texts);
+ cEPGHandler(const char *EpgFile, const char *EPDir, const char *CodeSet,
+ cEPGSources *Sources, cEPGMappings *Maps, cTEXTMappings *Texts);
void SetEPAll(bool Value)
{
epall=Value;
@@ -94,8 +94,8 @@ private:
cEPGMappings *maps;
cImport import;
public:
- cEPGTimer(const char *EpgFile, const char *EPDir, cEPGSources *Sources,
- cEPGMappings *Maps,cTEXTMappings *Texts);
+ cEPGTimer(const char *EpgFile, const char *EPDir, const char *CodeSet,
+ cEPGSources *Sources, cEPGMappings *Maps,cTEXTMappings *Texts);
bool StillRunning()
{
return Running();
@@ -132,6 +132,7 @@ private:
char *confdir;
char *epgfile;
char *epdir;
+ char *codeset;
char *srcorder;
bool epall;
bool wakeup;
@@ -165,7 +166,8 @@ public:
}
void ReadInEPGSources(bool Reload=false)
{
- epgsources.ReadIn(confdir,epgfile,epdir,&epgmappings,&textmappings,srcorder,Reload);
+ epgsources.ReadIn(confdir,epgfile,epdir,codeset,&epgmappings,
+ &textmappings,srcorder,Reload);
}
bool EPGSourceMove(int From, int To);
int EPGSourceCount()