summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Dolze <vdr@dolze.de>2012-06-24 16:16:46 +0200
committerJochen Dolze <vdr@dolze.de>2012-06-24 16:16:46 +0200
commit2688f79af07c3c833d6c49f0e174d7e966660dd2 (patch)
tree706e5bafb9fe1b6828a5eacad21e41570fd7c716
parentf154606bd1e8c560c99fd31ca0e3e1fabc94491e (diff)
downloadvdr-plugin-xmltv2vdr-2688f79af07c3c833d6c49f0e174d7e966660dd2.tar.gz
vdr-plugin-xmltv2vdr-2688f79af07c3c833d6c49f0e174d7e966660dd2.tar.bz2
Updatet linkpictures function
Added svdrp TIMR function Improved season and episode matching
-rw-r--r--import.cpp128
-rw-r--r--import.h3
-rw-r--r--parse.cpp7
-rw-r--r--xmltv2vdr.cpp27
4 files changed, 106 insertions, 59 deletions
diff --git a/import.cpp b/import.cpp
index 13af118..1883f70 100644
--- a/import.cpp
+++ b/import.cpp
@@ -283,7 +283,7 @@ bool cImport::WasChanged(cEvent* Event)
return true;
}
-void cImport::LinkPictures(const char *Source, cXMLTVStringList *Pics, tEventID DestID, tChannelID ChanID)
+void cImport::LinkPictures(const char *Source, cXMLTVStringList *Pics, tEventID DestID, tChannelID ChanID, bool MakeOld)
{
// source-pics are located in /var/lib/epgsources/%SOURCE%-img/
// dest-pics are located in imgdir (default /var/cache/vdr/epgimages)
@@ -291,15 +291,19 @@ void cImport::LinkPictures(const char *Source, cXMLTVStringList *Pics, tEventID
for (int i=0; i<Pics->Size(); i++)
{
char *pic=(*Pics)[i];
+
+ char *ext=strrchr(pic,'.');
+ if (!ext) continue;
+
+ ext++;
+ char *dst,*dstold=NULL;
+ int ret;
+
char *src;
if (asprintf(&src,"/var/lib/epgsources/%s-img/%s",Source,pic)==-1) return;
- char *ext=strrchr(pic,'.');
- if (ext)
+ if (MakeOld)
{
- ext++;
- char *dst,*dstold;
- int ret;
if (!i)
{
ret=asprintf(&dstold,"%s/%i.%s",g->ImgDir(),DestID,ext);
@@ -313,75 +317,85 @@ void cImport::LinkPictures(const char *Source, cXMLTVStringList *Pics, tEventID
free(src);
return;
}
+ }
- if (!i)
- {
- ret=asprintf(&dst,"%s/%s_%i.%s",g->ImgDir(),*ChanID.ToString(),DestID,ext);
- }
- else
- {
- ret=asprintf(&dst,"%s/%s_%i_%i.%s",g->ImgDir(),*ChanID.ToString(),DestID,i,ext);
- }
- if (ret==-1)
+ if (!i)
+ {
+ ret=asprintf(&dst,"%s/%s_%i.%s",g->ImgDir(),*ChanID.ToString(),DestID,ext);
+ }
+ else
+ {
+ ret=asprintf(&dst,"%s/%s_%i_%i.%s",g->ImgDir(),*ChanID.ToString(),DestID,i,ext);
+ }
+ if (ret==-1)
+ {
+ free(src);
+ if (dstold) free(dstold);
+ return;
+ }
+
+ struct stat statbuf;
+ if (MakeOld)
+ {
+ if (stat(dstold,&statbuf)!=-1)
{
- free(src);
- free(dstold);
- return;
+ unlink(dstold);
}
-
- struct stat statbuf;
- if (stat(dstold,&statbuf)==-1)
+ if (symlink(src,dstold)==-1)
{
- if (symlink(src,dstold)==-1)
+ if (!i)
{
- if (!i)
- {
- tsyslog("failed to link %s to %i.%s",pic,DestID,ext);
- }
- else
- {
- tsyslog("failed to link %s to %i_%i.%s",pic,DestID,i,ext);
- }
+ tsyslog("failed to link %s to %i.%s",pic,DestID,ext);
}
else
{
- if (!i)
- {
- tsyslog("linked %s to %i.%s",pic,DestID,ext);
- }
- else
- {
- tsyslog("linked %s to %i_%i.%s",pic,DestID,i,ext);
- }
+ tsyslog("failed to link %s to %i_%i.%s",pic,DestID,i,ext);
}
}
-
- if (stat(dst,&statbuf)==-1)
+ else
{
- if (symlink(src,dst)==-1)
+ if (!i)
{
- if (!i)
- {
- tsyslog("failed to link %s to %s_%i.%s",pic,*ChanID.ToString(),DestID,ext);
- }
- else
- {
- tsyslog("failed to link %s to %s_%i_%i.%s",pic,*ChanID.ToString(),DestID,i,ext);
- }
+ tsyslog("linked %s to %i.%s",pic,DestID,ext);
}
else
{
- if (!i)
- {
- tsyslog("linked %s to %s_%i.%s",pic,*ChanID.ToString(),DestID,ext);
- }
- else
- {
- tsyslog("linked %s to %s_%i_%i.%s",pic,*ChanID.ToString(),DestID,i,ext);
- }
+ tsyslog("linked %s to %i_%i.%s",pic,DestID,i,ext);
}
}
}
+
+ if (stat(dst,&statbuf)!=-1)
+ {
+ unlink(dst);
+ }
+ if (symlink(src,dst)==-1)
+ {
+ if (!i)
+ {
+ tsyslog("failed to link %s to %s_%i.%s",pic,*ChanID.ToString(),DestID,ext);
+ }
+ else
+ {
+ tsyslog("failed to link %s to %s_%i_%i.%s",pic,*ChanID.ToString(),DestID,i,ext);
+ }
+ }
+ else
+ {
+ if (!i)
+ {
+ tsyslog("linked %s to %s_%i.%s",pic,*ChanID.ToString(),DestID,ext);
+ }
+ else
+ {
+ tsyslog("linked %s to %s_%i_%i.%s",pic,*ChanID.ToString(),DestID,i,ext);
+ }
+ }
+
+ free(src);
+ free(dst);
+ if (dstold) free(dstold);
+
}
}
diff --git a/import.h b/import.h
index e61c60f..8a007f3 100644
--- a/import.h
+++ b/import.h
@@ -58,7 +58,8 @@ private:
public:
cImport(cGlobals *Global);
~cImport();
- void LinkPictures(const char *Source, cXMLTVStringList *Pics, tEventID DestID, tChannelID ChanID);
+ void LinkPictures(const char *Source, cXMLTVStringList *Pics, tEventID DestID,
+ tChannelID ChanID, bool MakeOld=true);
int Process(cEPGSource *Source, cEPGExecutor &myExecutor);
bool Begin(cEPGSource *Source, sqlite3 *Db);
bool Commit(cEPGSource *Source, sqlite3 *Db);
diff --git a/parse.cpp b/parse.cpp
index 2169384..e7fcb62 100644
--- a/parse.cpp
+++ b/parse.cpp
@@ -124,6 +124,13 @@ void cParse::RemoveNonAlphaNumeric(char *String)
len--;
continue;
}
+ if ((*p=='i') && (*(p+1) && *(p+1)=='e'))
+ {
+ memmove(p,p+1,len-pos);
+ len--;
+ *p='y';
+ continue;
+ }
p++;
pos++;
}
diff --git a/xmltv2vdr.cpp b/xmltv2vdr.cpp
index 8be1334..9e18ad8 100644
--- a/xmltv2vdr.cpp
+++ b/xmltv2vdr.cpp
@@ -1039,6 +1039,8 @@ const char **cPluginXmltv2vdr::SVDRPHelpPages(void)
" Delete xmltv2vdr epg database (triggers update)\n",
"HOUS\n"
" Start housekeeping manually\n",
+ "TIMR\n"
+ " Start timerthread manually\n",
NULL
};
return HelpPages;
@@ -1107,12 +1109,35 @@ cString cPluginXmltv2vdr::SVDRPCommand(const char *Command, const char *Option,
output="epgfile parameter not set\n";
}
}
+ if (!strcasecmp(Command,"TIMR"))
+ {
+ if (!epgexecutor.Active() && g.EPGTimer() && !g.EPGTimer()->Active())
+ {
+ g.EPGTimer()->Start();
+ last_timer_t=(time(NULL)/600)*600;
+ ReplyCode=250;
+ output="timerthread started\n";
+ }
+ else
+ {
+ if (g.EPGTimer())
+ {
+ ReplyCode=550;
+ output="system busy\n";
+ }
+ else
+ {
+ ReplyCode=550;
+ output="no timerthread\n";
+ }
+ }
+ }
if (!strcasecmp(Command,"HOUS"))
{
if (!epgexecutor.Active() && !housekeeping.Active())
{
housekeeping.Start();
- last_housetime_t=(time(NULL) / 3600)*3600;
+ last_housetime_t=(time(NULL)/3600)*3600;
ReplyCode=250;
output="housekeeping started\n";
}