summaryrefslogtreecommitdiff
path: root/import.cpp
diff options
context:
space:
mode:
authorJochen Dolze <vdr@dolze.de>2012-06-07 23:18:25 +0200
committerJochen Dolze <vdr@dolze.de>2012-06-07 23:18:25 +0200
commitd4519d42c150b7e34e8a469f520574bb97217fd3 (patch)
treebb58cc6279c503cdd5af9cb8f10e3eed106f080c /import.cpp
parent7aedd14481ef10a566819f316c0ec131552617be (diff)
downloadvdr-plugin-xmltv2vdr-d4519d42c150b7e34e8a469f520574bb97217fd3.tar.gz
vdr-plugin-xmltv2vdr-d4519d42c150b7e34e8a469f520574bb97217fd3.tar.bz2
Added sorting of epg entries
Added episode, "tagestipp" and "toptipp" to epgdata2xmltv
Diffstat (limited to 'import.cpp')
-rw-r--r--import.cpp556
1 files changed, 289 insertions, 267 deletions
diff --git a/import.cpp b/import.cpp
index b5076d1..7722a00 100644
--- a/import.cpp
+++ b/import.cpp
@@ -253,13 +253,13 @@ char *cImport::AddEOT2Description(char *description, bool checkutf8)
if (checkutf8)
{
- if (!codeset)
+ if (!g->Codeset())
{
description=strcatrealloc(description,nbspUTF8);
}
else
{
- if (strncasecmp(codeset,"UTF-8",5) || strncasecmp(codeset,"UTF8",4))
+ if (strncasecmp(g->Codeset(),"UTF-8",5) || strncasecmp(g->Codeset(),"UTF8",4))
{
description=strcatrealloc(description,nbsp);
}
@@ -303,11 +303,11 @@ void cImport::LinkPictures(const char *Source, cXMLTVStringList *Pics, tEventID
int ret;
if (!i)
{
- ret=asprintf(&dstold,"%s/%i.%s",imgdir,DestID,ext);
+ ret=asprintf(&dstold,"%s/%i.%s",g->ImgDir(),DestID,ext);
}
else
{
- ret=asprintf(&dstold,"%s/%i_%i.%s",imgdir,DestID,i,ext);
+ ret=asprintf(&dstold,"%s/%i_%i.%s",g->ImgDir(),DestID,i,ext);
}
if (ret==-1)
{
@@ -317,11 +317,11 @@ void cImport::LinkPictures(const char *Source, cXMLTVStringList *Pics, tEventID
if (!i)
{
- ret=asprintf(&dst,"%s/%s_%i.%s",imgdir,*ChanID.ToString(),DestID,ext);
+ ret=asprintf(&dst,"%s/%s_%i.%s",g->ImgDir(),*ChanID.ToString(),DestID,ext);
}
else
{
- ret=asprintf(&dst,"%s/%s_%i_%i.%s",imgdir,*ChanID.ToString(),DestID,i,ext);
+ ret=asprintf(&dst,"%s/%s_%i_%i.%s",g->ImgDir(),*ChanID.ToString(),DestID,i,ext);
}
if (ret==-1)
{
@@ -386,234 +386,26 @@ void cImport::LinkPictures(const char *Source, cXMLTVStringList *Pics, tEventID
}
}
-bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule,
- cEvent *Event, cXMLTVEvent *xEvent,int Flags)
+char *cImport::Add2Description(char *description, cXMLTVEvent *xEvent, int Flags, int what)
{
- if (!Source) return false;
- if (!Db) return false;
- if (!xEvent) return false;
-
-#define CHANGED_NOTHING 0
-#define CHANGED_TITLE 1
-#define CHANGED_SHORTTEXT 2
-#define CHANGED_DESCRIPTION 4
-
- struct tm tm;
- char from[80];
- char till[80];
- time_t start,end;
-
- int changed=CHANGED_NOTHING;
- bool append=false;
- bool retcode=false;
- bool added=false;
-
- if ((Flags & OPT_APPEND)==OPT_APPEND) append=true;
-
- if (append && !Event)
- {
- if (!Schedule) return false;
- start=xEvent->StartTime();
- end=start+xEvent->Duration();
-
- /* checking the "space" for our new event */
- cEvent *prev=GetEventBefore(Schedule,start);
- if (prev)
- {
- if (cEvent *next=(cEvent *) prev->Next())
- {
- if (prev->EndTime()==next->StartTime())
- {
- localtime_r(&start,&tm);
- strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm);
- localtime_r(&end,&tm);
- strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm);
- esyslogs(Source,"cannot add '%s'@%s-%s",xEvent->Title(),from,till);
-
- time_t pstart=prev->StartTime();
- time_t pstop=prev->EndTime();
- localtime_r(&pstart,&tm);
- strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm);
- localtime_r(&pstop,&tm);
- strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm);
- esyslogs(Source,"found '%s'@%s-%s",prev->Title(),from,till);
-
- time_t nstart=next->StartTime();
- time_t nstop=next->EndTime();
- localtime_r(&nstart,&tm);
- strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm);
- localtime_r(&nstop,&tm);
- strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm);
- esyslogs(Source,"found '%s'@%s-%s",next->Title(),from,till);
- return false;
- }
-
- if (end>next->StartTime())
- {
- int diff=(int) difftime(prev->EndTime(),start);
- if (diff>300)
- {
-
- localtime_r(&start,&tm);
- strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm);
- localtime_r(&end,&tm);
- strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm);
- esyslogs(Source,"cannot add '%s'@%s-%s",xEvent->Title(),from,till);
-
- time_t nstart=next->StartTime();
- time_t nstop=next->EndTime();
- localtime_r(&nstart,&tm);
- strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm);
- localtime_r(&nstop,&tm);
- strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm);
- esyslogs(Source,"found '%s'@%s-%s",next->Title(),from,till);
- return false;
- }
- else
- {
- xEvent->SetDuration(xEvent->Duration()-diff);
- }
- }
- }
- else
- {
- // no next event, check for gaps
- if (prev->EndTime()!=start)
- {
- tsyslogs(Source,"detected gap of %lis",(long int)(start-prev->EndTime()));
- }
- }
-
- if (prev->EndTime()>start)
- {
- int diff=(int) difftime(prev->EndTime(),start);
- if (diff>300)
- {
- localtime_r(&start,&tm);
- strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm);
- localtime_r(&end,&tm);
- strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm);
- esyslogs(Source,"cannot add '%s'@%s-%s",xEvent->Title(),from,till);
-
- time_t pstart=prev->StartTime();
- time_t pstop=prev->EndTime();
- localtime_r(&pstart,&tm);
- strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm);
- localtime_r(&pstop,&tm);
- strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm);
- esyslogs(Source,"found '%s'@%s-%s",prev->Title(),from,till);
- return false;
- }
- else
- {
- prev->SetDuration(prev->Duration()-diff);
- }
- }
-
- if (!xEvent->Duration())
- {
- if (!prev->Duration())
- {
- prev->SetDuration(start-prev->StartTime());
- }
- }
- }
- /* add event */
- Event=new cEvent(xEvent->EventID());
- if (!Event) return false;
- Event->SetStartTime(start);
- Event->SetDuration(xEvent->Duration());
- Event->SetTitle(xEvent->Title());
- Event->SetVersion(0);
- Event->SetTableID(0);
- Schedule->AddEvent(Event);
- Schedule->Sort();
- added=true;
- if (xEvent->Pics()->Size() && Source->UsePics())
- {
- /* here's a good place to link pictures! */
- LinkPictures(xEvent->Source(),xEvent->Pics(),Event->EventID(),Event->ChannelID());
- }
- if (Source->Trace())
- {
- localtime_r(&start,&tm);
- strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm);
- localtime_r(&end,&tm);
- strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm);
- tsyslogs(Source,"{%5i} adding '%s'/'%s'@%s-%s",xEvent->EventID(),xEvent->Title(),
- xEvent->ShortText(),from,till);
- }
- retcode=true;
- }
-
- if (!Event) return false;
-
- if (!append)
+ if (what==USE_LONGTEXT)
{
- const char *eitdescription=Event->Description();
- if (WasChanged(Event)) eitdescription=NULL; // we cannot use Event->Description() - it is already changed!
- if (!xEvent->EITEventID() || eitdescription)
- {
- if (!xEvent->EITEventID() && xEvent->Pics()->Size() && Source->UsePics())
- {
- /* here's a good place to link pictures! */
- LinkPictures(xEvent->Source(),xEvent->Pics(),Event->EventID(),Event->ChannelID());
- }
- UpdateXMLTVEvent(Source,Db,Event,xEvent,eitdescription);
- }
- }
-
- if ((Flags & USE_TITLE)==USE_TITLE)
- {
- if (xEvent->Title() && (strlen(xEvent->Title())>0))
- {
- const char *dp=conv->Convert(xEvent->Title());
- if (!Event->Title() || strcmp(Event->Title(),dp))
- {
- Event->SetTitle(dp);
- changed|=CHANGED_TITLE; // title really changed
- }
- }
- }
-
- if (((Flags & USE_SHORTTEXT)==USE_SHORTTEXT) || (append))
- {
- if (xEvent->ShortText() && (strlen(xEvent->ShortText())>0))
+ if (((Flags & USE_LONGTEXT)==USE_LONGTEXT) || ((Flags & OPT_APPEND)==OPT_APPEND))
{
- if (!strcasecmp(xEvent->ShortText(),Event->Title()))
- {
- tsyslogs(Source,"title and subtitle equal, clearing subtitle");
- Event->SetShortText(NULL);
- }
- else
+ if (xEvent->Description() && (strlen(xEvent->Description())>0))
{
- const char *dp=conv->Convert(xEvent->ShortText());
- if (!Event->ShortText() || strcmp(Event->ShortText(),dp))
- {
- Event->SetShortText(dp);
- changed|=CHANGED_SHORTTEXT; // shorttext really changed
- }
+ description=Add2Description(description,xEvent->Description());
}
}
- }
- char *description=NULL;
- if (((Flags & USE_LONGTEXT)==USE_LONGTEXT) || (append))
- {
- if (xEvent->Description() && (strlen(xEvent->Description())>0))
+ if (!description && xEvent->EITDescription() && (strlen(xEvent->EITDescription())>0))
{
- description=strdup(xEvent->Description());
+ description=Add2Description(description,xEvent->EITDescription());
}
+ description=Add2Description(description,"\n");
}
- if (!description && xEvent->EITDescription() && (strlen(xEvent->EITDescription())>0))
- {
- description=strdup(xEvent->EITDescription());
- }
-
- description=Add2Description(description,"\n");
-
- if ((Flags & USE_CREDITS)==USE_CREDITS)
+ if (what==USE_CREDITS)
{
cXMLTVStringList *credits=xEvent->Credits();
if (credits->Size())
@@ -639,7 +431,7 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule,
(strcasecmp(ctype,"director"))) add=false;
if (add)
{
- cTEXTMapping *text=texts->GetMap(ctype);
+ cTEXTMapping *text=g->TEXTMappings()->GetMap(ctype);
if ((Flags & CREDITS_LIST)==CREDITS_LIST)
{
if (oldtext!=text)
@@ -678,28 +470,28 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule,
}
}
- if ((Flags & USE_COUNTRYDATE)==USE_COUNTRYDATE)
+ if (what==USE_COUNTRYDATE)
{
if (xEvent->Country())
{
- cTEXTMapping *text=texts->GetMap("country");
+ cTEXTMapping *text=g->TEXTMappings()->GetMap("country");
if (text) description=Add2Description(description,text->Value(),xEvent->Country());
}
if (xEvent->Year())
{
- cTEXTMapping *text=texts->GetMap("year");
+ cTEXTMapping *text=g->TEXTMappings()->GetMap("year");
if (text) description=Add2Description(description,text->Value(),xEvent->Year());
}
}
- if (((Flags & USE_ORIGTITLE)==USE_ORIGTITLE) && (xEvent->OrigTitle()))
+ if ((what==USE_ORIGTITLE) && (xEvent->OrigTitle()))
{
- cTEXTMapping *text=texts->GetMap("originaltitle");
+ cTEXTMapping *text=g->TEXTMappings()->GetMap("originaltitle");
if (text) description=Add2Description(description,text->Value(),xEvent->OrigTitle());
}
- if (((Flags & USE_CATEGORIES)==USE_CATEGORIES) && (xEvent->Category()->Size()))
+ if ((what==USE_CATEGORIES) && (xEvent->Category()->Size()))
{
- cTEXTMapping *text=texts->GetMap("category");
+ cTEXTMapping *text=g->TEXTMappings()->GetMap("category");
if (text)
{
cXMLTVStringList *categories=xEvent->Category();
@@ -713,9 +505,9 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule,
}
}
- if (((Flags & USE_VIDEO)==USE_VIDEO) && (xEvent->Video()->Size()))
+ if ((what==USE_VIDEO) && (xEvent->Video()->Size()))
{
- cTEXTMapping *text=texts->GetMap("video");
+ cTEXTMapping *text=g->TEXTMappings()->GetMap("video");
if (text)
{
description=Add2Description(description,text->Value());
@@ -741,7 +533,7 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule,
{
if (!strcasecmp(vval,"no"))
{
- cTEXTMapping *text=texts->GetMap("blacknwhite");
+ cTEXTMapping *text=g->TEXTMappings()->GetMap("blacknwhite");
description=Add2Description(description,text->Value());
}
}
@@ -757,11 +549,11 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule,
}
}
- if ((Flags & USE_AUDIO)==USE_AUDIO)
+ if (what==USE_AUDIO)
{
if (xEvent->Audio())
{
- cTEXTMapping *text=texts->GetMap("audio");
+ cTEXTMapping *text=g->TEXTMappings()->GetMap("audio");
if (text)
{
description=Add2Description(description,text->Value());
@@ -774,7 +566,7 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule,
}
else
{
- cTEXTMapping *text=texts->GetMap(xEvent->Audio());
+ cTEXTMapping *text=g->TEXTMappings()->GetMap(xEvent->Audio());
if (text)
{
description=Add2Description(description,text->Value());
@@ -784,28 +576,28 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule,
}
}
}
- if ((Flags & USE_SEASON)==USE_SEASON)
+ if (what==USE_SEASON)
{
if (xEvent->Season())
{
- cTEXTMapping *text=texts->GetMap("season");
+ cTEXTMapping *text=g->TEXTMappings()->GetMap("season");
if (text) description=Add2Description(description,text->Value(),xEvent->Season());
}
if (xEvent->Episode())
{
- cTEXTMapping *text=texts->GetMap("episode");
+ cTEXTMapping *text=g->TEXTMappings()->GetMap("episode");
if (text) description=Add2Description(description,text->Value(),xEvent->Episode());
}
if (xEvent->EpisodeOverall())
{
- cTEXTMapping *text=texts->GetMap("episodeoverall");
+ cTEXTMapping *text=g->TEXTMappings()->GetMap("episodeoverall");
if (text) description=Add2Description(description,text->Value(),xEvent->EpisodeOverall());
}
}
- if (((Flags & USE_RATING)==USE_RATING) && (xEvent->Rating()->Size()))
+ if ((what==USE_RATING) && (xEvent->Rating()->Size()))
{
#if VDRVERSNUM < 10711 && !EPGHANDLER
Flags|=OPT_RATING_TEXT; // always add to text if we dont have the internal tag!
@@ -835,9 +627,9 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule,
}
}
- if (((Flags & USE_STARRATING)==USE_STARRATING) && (xEvent->StarRating()->Size()))
+ if ((what==USE_STARRATING) && (xEvent->StarRating()->Size()))
{
- cTEXTMapping *text=texts->GetMap("starrating");
+ cTEXTMapping *text=g->TEXTMappings()->GetMap("starrating");
if (text)
{
description=Add2Description(description,text->Value());
@@ -872,9 +664,9 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule,
}
}
- if (((Flags & USE_REVIEW)==USE_REVIEW) && (xEvent->Review()->Size()))
+ if ((what==USE_REVIEW) && (xEvent->Review()->Size()))
{
- cTEXTMapping *text=texts->GetMap("review");
+ cTEXTMapping *text=g->TEXTMappings()->GetMap("review");
if (text)
{
cXMLTVStringList *review=xEvent->Review();
@@ -885,6 +677,243 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule,
}
}
+ return description;
+}
+
+bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule,
+ cEvent *Event, cXMLTVEvent *xEvent,int Flags)
+{
+ if (!Source) return false;
+ if (!Db) return false;
+ if (!xEvent) return false;
+ if (!g) return false;
+
+#define CHANGED_NOTHING 0
+#define CHANGED_TITLE 1
+#define CHANGED_SHORTTEXT 2
+#define CHANGED_DESCRIPTION 4
+
+ struct tm tm;
+ char from[80];
+ char till[80];
+ time_t start,end;
+
+ int changed=CHANGED_NOTHING;
+ bool append=false;
+ bool retcode=false;
+ bool added=false;
+
+ if ((Flags & OPT_APPEND)==OPT_APPEND) append=true;
+
+ if (append && !Event)
+ {
+ if (!Schedule) return false;
+ start=xEvent->StartTime();
+ end=start+xEvent->Duration();
+
+ /* checking the "space" for our new event */
+ cEvent *prev=GetEventBefore(Schedule,start);
+ if (prev)
+ {
+ if (cEvent *next=(cEvent *) prev->Next())
+ {
+ if (prev->EndTime()==next->StartTime())
+ {
+ localtime_r(&start,&tm);
+ strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm);
+ localtime_r(&end,&tm);
+ strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm);
+ esyslogs(Source,"cannot add '%s'@%s-%s",xEvent->Title(),from,till);
+
+ time_t pstart=prev->StartTime();
+ time_t pstop=prev->EndTime();
+ localtime_r(&pstart,&tm);
+ strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm);
+ localtime_r(&pstop,&tm);
+ strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm);
+ esyslogs(Source,"found '%s'@%s-%s",prev->Title(),from,till);
+
+ time_t nstart=next->StartTime();
+ time_t nstop=next->EndTime();
+ localtime_r(&nstart,&tm);
+ strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm);
+ localtime_r(&nstop,&tm);
+ strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm);
+ esyslogs(Source,"found '%s'@%s-%s",next->Title(),from,till);
+ return false;
+ }
+
+ if (end>next->StartTime())
+ {
+ int diff=(int) difftime(prev->EndTime(),start);
+ if (diff>300)
+ {
+
+ localtime_r(&start,&tm);
+ strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm);
+ localtime_r(&end,&tm);
+ strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm);
+ esyslogs(Source,"cannot add '%s'@%s-%s",xEvent->Title(),from,till);
+
+ time_t nstart=next->StartTime();
+ time_t nstop=next->EndTime();
+ localtime_r(&nstart,&tm);
+ strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm);
+ localtime_r(&nstop,&tm);
+ strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm);
+ esyslogs(Source,"found '%s'@%s-%s",next->Title(),from,till);
+ return false;
+ }
+ else
+ {
+ xEvent->SetDuration(xEvent->Duration()-diff);
+ }
+ }
+ }
+ else
+ {
+ // no next event, check for gaps
+ if (prev->EndTime()!=start)
+ {
+ tsyslogs(Source,"detected gap of %lis",(long int)(start-prev->EndTime()));
+ }
+ }
+
+ if (prev->EndTime()>start)
+ {
+ int diff=(int) difftime(prev->EndTime(),start);
+ if (diff>300)
+ {
+ localtime_r(&start,&tm);
+ strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm);
+ localtime_r(&end,&tm);
+ strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm);
+ esyslogs(Source,"cannot add '%s'@%s-%s",xEvent->Title(),from,till);
+
+ time_t pstart=prev->StartTime();
+ time_t pstop=prev->EndTime();
+ localtime_r(&pstart,&tm);
+ strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm);
+ localtime_r(&pstop,&tm);
+ strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm);
+ esyslogs(Source,"found '%s'@%s-%s",prev->Title(),from,till);
+ return false;
+ }
+ else
+ {
+ prev->SetDuration(prev->Duration()-diff);
+ }
+ }
+
+ if (!xEvent->Duration())
+ {
+ if (!prev->Duration())
+ {
+ prev->SetDuration(start-prev->StartTime());
+ }
+ }
+ }
+ /* add event */
+ Event=new cEvent(xEvent->EventID());
+ if (!Event) return false;
+ Event->SetStartTime(start);
+ Event->SetDuration(xEvent->Duration());
+ Event->SetTitle(xEvent->Title());
+ Event->SetVersion(0);
+ Event->SetTableID(0);
+ Schedule->AddEvent(Event);
+ Schedule->Sort();
+ added=true;
+ if (xEvent->Pics()->Size() && Source->UsePics())
+ {
+ /* here's a good place to link pictures! */
+ LinkPictures(xEvent->Source(),xEvent->Pics(),Event->EventID(),Event->ChannelID());
+ }
+ if (Source->Trace())
+ {
+ localtime_r(&start,&tm);
+ strftime(from,sizeof(from)-1,"%b %d %H:%M",&tm);
+ localtime_r(&end,&tm);
+ strftime(till,sizeof(till)-1,"%b %d %H:%M",&tm);
+ tsyslogs(Source,"{%5i} adding '%s'/'%s'@%s-%s",xEvent->EventID(),xEvent->Title(),
+ xEvent->ShortText(),from,till);
+ }
+ retcode=true;
+ }
+
+ if (!Event) return false;
+
+ if (!append)
+ {
+ const char *eitdescription=Event->Description();
+ if (WasChanged(Event)) eitdescription=NULL; // we cannot use Event->Description() - it is already changed!
+ if (!xEvent->EITEventID() || eitdescription)
+ {
+ if (!xEvent->EITEventID() && xEvent->Pics()->Size() && Source->UsePics())
+ {
+ /* here's a good place to link pictures! */
+ LinkPictures(xEvent->Source(),xEvent->Pics(),Event->EventID(),Event->ChannelID());
+ }
+ UpdateXMLTVEvent(Source,Db,Event,xEvent,eitdescription);
+ }
+ }
+
+ if ((Flags & USE_TITLE)==USE_TITLE)
+ {
+ if (xEvent->Title() && (strlen(xEvent->Title())>0))
+ {
+ const char *dp=conv->Convert(xEvent->Title());
+ if (!Event->Title() || strcmp(Event->Title(),dp))
+ {
+ Event->SetTitle(dp);
+ changed|=CHANGED_TITLE; // title really changed
+ }
+ }
+ }
+
+ if (((Flags & USE_SHORTTEXT)==USE_SHORTTEXT) || (append))
+ {
+ if (xEvent->ShortText() && (strlen(xEvent->ShortText())>0))
+ {
+ if (!strcasecmp(xEvent->ShortText(),Event->Title()))
+ {
+ tsyslogs(Source,"title and subtitle equal, clearing subtitle");
+ Event->SetShortText(NULL);
+ }
+ else
+ {
+ const char *dp=conv->Convert(xEvent->ShortText());
+ if (!Event->ShortText() || strcmp(Event->ShortText(),dp))
+ {
+ Event->SetShortText(dp);
+ changed|=CHANGED_SHORTTEXT; // shorttext really changed
+ }
+ }
+ }
+ }
+
+ char *description=NULL;
+
+ const char *ot=g->Order();
+ if (!ot) return false;
+
+ while (*ot)
+ {
+ if (*ot==',') ot++;
+ if (!strncmp(ot,"LOT",3)) description=Add2Description(description,xEvent,Flags,USE_LONGTEXT);
+ if (!strncmp(ot,"CRS",3)) description=Add2Description(description,xEvent,Flags,USE_CREDITS);
+ if (!strncmp(ot,"CAD",3)) description=Add2Description(description,xEvent,Flags,USE_COUNTRYDATE);
+ if (!strncmp(ot,"ORT",3)) description=Add2Description(description,xEvent,Flags,USE_ORIGTITLE);
+ if (!strncmp(ot,"CAT",3)) description=Add2Description(description,xEvent,Flags,USE_CATEGORIES);
+ if (!strncmp(ot,"VID",3)) description=Add2Description(description,xEvent,Flags,USE_VIDEO);
+ if (!strncmp(ot,"AUD",3)) description=Add2Description(description,xEvent,Flags,USE_AUDIO);
+ if (!strncmp(ot,"SEE",3)) description=Add2Description(description,xEvent,Flags,USE_SEASON);
+ if (!strncmp(ot,"RAT",3)) description=Add2Description(description,xEvent,Flags,USE_RATING);
+ if (!strncmp(ot,"STR",3)) description=Add2Description(description,xEvent,Flags,USE_STARRATING);
+ if (!strncmp(ot,"REV",3)) description=Add2Description(description,xEvent,Flags,USE_REVIEW);
+ ot+=3;
+ }
+
if (description)
{
description=RemoveLastCharFromDescription(description);
@@ -1257,9 +1286,9 @@ cXMLTVEvent *cImport::SearchXMLTVEvent(sqlite3 **Db,const char *ChannelID, const
if (!*Db)
{
// we need READWRITE because the epg.db maybe updated later
- if (sqlite3_open_v2(epgfile,Db,SQLITE_OPEN_READWRITE,NULL)!=SQLITE_OK)
+ if (sqlite3_open_v2(g->EPGFile(),Db,SQLITE_OPEN_READWRITE,NULL)!=SQLITE_OK)
{
- esyslog("failed to open %s",epgfile);
+ esyslog("failed to open %s",g->EPGFile());
*Db=NULL;
return NULL;
}
@@ -1400,9 +1429,9 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor)
dsyslogs(Source,"importing from db");
sqlite3 *db=NULL;
- if (sqlite3_open(epgfile,&db)!=SQLITE_OK)
+ if (sqlite3_open(g->EPGFile(),&db)!=SQLITE_OK)
{
- esyslogs(Source,"failed to open %s",epgfile);
+ esyslogs(Source,"failed to open %s",g->EPGFile());
delete schedulesLock;
return 141;
}
@@ -1441,7 +1470,7 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor)
cXMLTVEvent xevent;
if (FetchXMLTVEvent(stmt,&xevent))
{
- cEPGMapping *map=maps->GetMap(tChannelID::FromString(xevent.ChannelID()));
+ cEPGMapping *map=g->EPGMappings()->GetMap(tChannelID::FromString(xevent.ChannelID()));
if (!map)
{
if (lerr!=IMPORT_NOMAPPING)
@@ -1532,41 +1561,34 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor)
bool cImport::DBExists()
{
- if (!epgfile) return true; // is this safe?
+ if (!g->EPGFile()) return true; // is this safe?
struct stat statbuf;
- if (stat(epgfile,&statbuf)==-1) return false; // no database
+ if (stat(g->EPGFile(),&statbuf)==-1) return false; // no database
if (!statbuf.st_size) return false; // no database
return true;
}
cImport::cImport(cGlobals *Global)
{
- maps=Global->EPGMappings();
- texts=Global->TEXTMappings();
- epgfile=Global->EPGFile();
- codeset=Global->Codeset();
- imgdir=Global->ImgDir();
+ g=Global;
pendingtransaction=false;
- conv = new cCharSetConv("UTF-8",codeset);
+ conv = new cCharSetConv("UTF-8",g->Codeset());
- epdir=Global->EPDir();
- if (epdir)
+ if (Global->EPDir())
{
cep2ascii=iconv_open("ASCII//TRANSLIT",Global->EPCodeset());
cutf2ascii=iconv_open("ASCII//TRANSLIT","UTF-8");
}
else
{
- epdir=NULL;
+ cep2ascii=(iconv_t) -1;
+ cutf2ascii=(iconv_t) -1;
}
}
cImport::~cImport()
{
- if (epdir)
- {
- iconv_close(cep2ascii);
- iconv_close(cutf2ascii);
- }
+ if (cep2ascii!=(iconv_t) -1) iconv_close(cep2ascii);
+ if (cutf2ascii!=(iconv_t) -1) iconv_close(cutf2ascii);
delete conv;
}