summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Dolze <vdr@dolze.de>2012-04-16 22:01:56 +0200
committerJochen Dolze <vdr@dolze.de>2012-04-16 22:01:56 +0200
commit9b07d3bea3d386cb4760db0609753e8b29b79e61 (patch)
tree11e2dc8d4f6798b251cf4997a5ae8a0befd06706
parent8ba37f7d026b5fdafd5f9c4f1c60f30fde464b6f (diff)
downloadvdr-plugin-xmltv2vdr-9b07d3bea3d386cb4760db0609753e8b29b79e61.tar.gz
vdr-plugin-xmltv2vdr-9b07d3bea3d386cb4760db0609753e8b29b79e61.tar.bz2
Changed Epghandler
-rw-r--r--import.cpp29
-rw-r--r--import.h2
-rw-r--r--xmltv2vdr.cpp91
-rw-r--r--xmltv2vdr.h17
4 files changed, 118 insertions, 21 deletions
diff --git a/import.cpp b/import.cpp
index 8d1c0bf..c63de59 100644
--- a/import.cpp
+++ b/import.cpp
@@ -407,7 +407,7 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule,
if (!strcasecmp(xEvent->ShortText(),Event->Title()))
{
Source->Tlog("title and subtitle equal, clearing subtitle");
- Event->SetShortText("");
+ Event->SetShortText(NULL);
}
else
{
@@ -660,12 +660,6 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule,
}
}
}
-#if VDRVERSNUM >= 10711 || EPGHANDLER
- if (xEvent->ParentalRating())
- {
- Event->SetParentalRating(xEvent->ParentalRating());
- }
-#endif
}
if (((Flags & USE_STARRATING)==USE_STARRATING) && (xEvent->StarRating()->Size()))
@@ -731,9 +725,21 @@ bool cImport::PutEvent(cEPGSource *Source, sqlite3 *Db, cSchedule* Schedule,
free(description);
}
}
+
+#if VDRVERSNUM >= 10711 || EPGHANDLER
+ if ((Flags & USE_RATING)==USE_RATING)
+ {
+ if (xEvent->ParentalRating() && xEvent->ParentalRating()>Event->ParentalRating())
+ {
+ Event->SetParentalRating(xEvent->ParentalRating());
+ }
+ }
+#endif
+
#if VDRVERSNUM < 10726 && (!EPGHANDLER)
event->SetTableID(0); // prevent EIT EPG to update this event
#endif
+
if ((!append) && (changed))
{
start=Event->StartTime();
@@ -842,12 +848,12 @@ bool cImport::FetchXMLTVEvent(sqlite3_stmt *stmt, cXMLTVEvent *xevent)
return true;
}
-cXMLTVEvent *cImport::PrepareAndReturn(sqlite3 *db, char *sql, sqlite3_stmt *stmt)
+cXMLTVEvent *cImport::PrepareAndReturn(sqlite3 *db, char *sql)
{
if (!db) return NULL;
if (!sql) return NULL;
- if (!stmt) return NULL;
+ sqlite3_stmt *stmt=NULL;
int ret=sqlite3_prepare_v2(db,sql,strlen(sql),&stmt,NULL);
if (ret!=SQLITE_OK)
{
@@ -1049,7 +1055,6 @@ cXMLTVEvent *cImport::SearchXMLTVEvent(sqlite3 **Db, const char *ChannelID, cons
}
cXMLTVEvent *xevent=NULL;
- sqlite3_stmt *stmt=NULL;
char *sql=NULL;
if (asprintf(&sql,"select channelid,eventid,starttime,duration,title,origtitle,shorttext,description," \
@@ -1061,7 +1066,7 @@ cXMLTVEvent *cImport::SearchXMLTVEvent(sqlite3 **Db, const char *ChannelID, cons
return NULL;
}
- xevent=PrepareAndReturn(*Db,sql,stmt);
+ xevent=PrepareAndReturn(*Db,sql);
if (xevent) return xevent;
int eventTimeDiff=0;
@@ -1102,7 +1107,7 @@ cXMLTVEvent *cImport::SearchXMLTVEvent(sqlite3 **Db, const char *ChannelID, cons
}
free(sqltitle);
- xevent=PrepareAndReturn(*Db,sql,stmt);
+ xevent=PrepareAndReturn(*Db,sql);
if (xevent) return xevent;
return NULL;
diff --git a/import.h b/import.h
index b778d43..787ce12 100644
--- a/import.h
+++ b/import.h
@@ -59,7 +59,7 @@ private:
cEvent *SearchVDREvent(cEPGSource *source, cSchedule* schedule, cXMLTVEvent *event);
bool FetchXMLTVEvent(sqlite3_stmt *stmt, cXMLTVEvent *xevent);
char *RemoveNonASCII(const char *src);
- cXMLTVEvent *PrepareAndReturn(sqlite3 *db, char *sql, sqlite3_stmt *stmt);
+ cXMLTVEvent *PrepareAndReturn(sqlite3 *db, char *sql);
public:
cImport(const char *EPGFile, cEPGMappings *Maps, cTEXTMappings *Texts);
~cImport();
diff --git a/xmltv2vdr.cpp b/xmltv2vdr.cpp
index 93e1b65..8e36138 100644
--- a/xmltv2vdr.cpp
+++ b/xmltv2vdr.cpp
@@ -106,11 +106,89 @@ bool cEPGHandler::IgnoreChannel(const cChannel* Channel)
return maps->IgnoreChannel(Channel);
}
-bool cEPGHandler::SetContents(cEvent* UNUSED(Event), uchar* UNUSED(Contents))
+bool cEPGHandler::FixEpgBugs(cEvent* Event)
{
- return false;
+ if (!Event) return false;
+ if (!maps) return false;
+ if (!import) return false;
+ if (!baseplugin) return false;
+
+ bool special_epall_timer_handling=false;
+ if (!maps->ProcessChannel(Event->ChannelID()))
+ {
+ if (!epall) return false;
+ if (!Event->HasTimer()) return false;
+ if (!Event->ShortText()) return false;
+ special_epall_timer_handling=true;
+ }
+
+ if (!baseplugin->IsIdle(false))
+ {
+ if (import->WasChanged(Event)) return true;
+ return false;
+ }
+
+ int Flags=0;
+ const char *ChannelID;
+
+ if (special_epall_timer_handling)
+ {
+ cChannel *chan=Channels.GetByChannelID(Event->ChannelID());
+ if (!chan) return false;
+ Flags=USE_SEASON;
+ ChannelID=chan->Name();
+ }
+ else
+ {
+ cEPGMapping *map=maps->GetMap(Event->ChannelID());
+ if (!map) return false;
+ Flags=map->Flags();
+ ChannelID=map->ChannelName();
+ }
+
+ cEPGSource *source=NULL;
+ cXMLTVEvent *xevent=import->SearchXMLTVEvent(&db,ChannelID,Event);
+ if (!xevent)
+ {
+ if (!epall) return false;
+ source=sources->GetSource(EITSOURCE);
+ xevent=import->AddXMLTVEvent(source,db,ChannelID,Event,Event->Description());
+ if (!xevent) return false;
+ }
+ else
+ {
+ source=sources->GetSource(xevent->Source());
+ }
+ if (!source)
+ {
+ delete xevent;
+ return false;
+ }
+
+ bool update=false;
+
+ if (!xevent->EITEventID()) update=true;
+ if (!xevent->EITDescription() && Event->Description()) update=true;
+ if (xevent->EITDescription() && Event->Description() &&
+ strcasecmp(xevent->EITDescription(),Event->Description())) update=true;
+
+ if (update)
+ {
+ if (!import->UpdateXMLTVEvent(source,db,Event,xevent->EventID(),
+ Event->EventID(),Event->Description()))
+ {
+ delete xevent;
+ return false;
+ }
+ }
+
+ import->PutEvent(source,db,(cSchedule *) Event->Schedule(),Event,xevent,Flags);
+ delete xevent;
+ return false; // let VDR fix the bugs!
}
+
+/*
bool cEPGHandler::SetDescription(cEvent* Event, const char* Description)
{
if (!Event) return false;
@@ -200,6 +278,11 @@ bool cEPGHandler::SetDescription(cEvent* Event, const char* Description)
Event,last.xEvent(),last.Flags(),IMPORT_DESCRIPTION);
}
+bool cEPGHandler::SetContents(cEvent* UNUSED(Event), uchar* UNUSED(Contents))
+{
+ return false;
+}
+
bool cEPGHandler::SetParentalRating(cEvent* Event, int ParentalRating)
{
if (!Event) return false;
@@ -268,7 +351,6 @@ bool cEPGHandler::SetShortText(cEvent* Event, const char* UNUSED(ShortText))
if (!last.isSame(Event->EventID()))
{
last.Clear();
-
if (!maps->ProcessChannel(Event->ChannelID())) return false;
if (!baseplugin->IsIdle(false))
@@ -276,7 +358,6 @@ bool cEPGHandler::SetShortText(cEvent* Event, const char* UNUSED(ShortText))
if (import->WasChanged(Event)) return true;
return false;
}
-
cEPGMapping *map=maps->GetMap(Event->ChannelID());
if (!map) return false;
@@ -311,6 +392,7 @@ bool cEPGHandler::SetShortText(cEvent* Event, const char* UNUSED(ShortText))
}
return ret;
}
+*/
bool cEPGHandler::SortSchedule(cSchedule* UNUSED(Schedule))
{
@@ -320,6 +402,7 @@ bool cEPGHandler::SortSchedule(cSchedule* UNUSED(Schedule))
sqlite3_close(db);
db=NULL;
}
+ dsyslog("RRR: EOF");
return false; // we dont sort!
}
diff --git a/xmltv2vdr.h b/xmltv2vdr.h
index 668e632..ce431b2 100644
--- a/xmltv2vdr.h
+++ b/xmltv2vdr.h
@@ -36,10 +36,11 @@ public:
{
return false;
}
- virtual bool SetShortText(cEvent *UNUSED(Event), const char *UNUSED(ShortText))
+ virtual bool FixEpgBugs(cEvent *UNUSED(Event))
{
return false;
}
+ /*
virtual bool SetDescription(cEvent *UNUSED(Event), const char *UNUSED(Description))
{
return false;
@@ -52,6 +53,11 @@ public:
{
return false;
}
+ virtual bool SetShortText(cEvent *UNUSED(Event), const char *UNUSED(ShortText))
+ {
+ return false;
+ }
+ */
virtual bool SortSchedule(cSchedule *Schedule)
{
return false;
@@ -99,7 +105,7 @@ private:
bool epall;
sqlite3 *db;
void closedb(void);
- cEPGHandlerState last;
+ //cEPGHandlerState last;
public:
cEPGHandler(cPluginXmltv2vdr *Plugin, const char *EpgFile, cEPGSources *Sources,
cEPGMappings *Maps, cTEXTMappings *Texts);
@@ -113,10 +119,13 @@ public:
}
virtual ~cEPGHandler();
virtual bool IgnoreChannel(const cChannel *Channel);
- virtual bool SetShortText(cEvent *Event, const char *ShortText);
+ virtual bool FixEpgBugs(cEvent *Event);
+ /*
virtual bool SetDescription(cEvent *Event, const char *Description);
virtual bool SetContents(cEvent *Event, uchar *Contents);
virtual bool SetParentalRating(cEvent *Event, int ParentalRating);
+ virtual bool SetShortText(cEvent *Event, const char *ShortText);
+ */
virtual bool SortSchedule(cSchedule *Schedule);
};
@@ -155,7 +164,7 @@ class cPluginXmltv2vdr : public cPlugin
private:
cEPGHandler *epghandler;
cEPGTimer *epgtimer;
- cHouseKeeping *housekeeping;
+ cHouseKeeping *housekeeping;
cEPGExecutor epgexecutor;
cEPGMappings epgmappings;
cEPGSources epgsources;