summaryrefslogtreecommitdiff
path: root/import.cpp
diff options
context:
space:
mode:
authorJochen Dolze <vdr@dolze.de>2012-04-27 07:14:27 +0200
committerJochen Dolze <vdr@dolze.de>2012-04-27 07:14:27 +0200
commit40889067514769b356eb50d60d6a75889aeb99e3 (patch)
tree186f332caabe653bd458773623bd49739bb10ef2 /import.cpp
parentfaab1db375b46658959c22ddbd1977bc1fdeb50b (diff)
downloadvdr-plugin-xmltv2vdr-40889067514769b356eb50d60d6a75889aeb99e3.tar.gz
vdr-plugin-xmltv2vdr-40889067514769b356eb50d60d6a75889aeb99e3.tar.bz2
Added -e parameter for path to episodes dir
Diffstat (limited to 'import.cpp')
-rw-r--r--import.cpp74
1 files changed, 32 insertions, 42 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;
}