mirror of
https://projects.vdr-developer.org/git/vdr-plugin-scraper2vdr.git
synced 2023-10-19 17:58:31 +02:00
fixed a bug that wrong pictures are stored in local fs
This commit is contained in:
parent
e5d994a044
commit
d736d269a1
@ -14,6 +14,8 @@
|
||||
// Constants
|
||||
//***************************************************************************
|
||||
static const char *VERSION = "0.1.3";
|
||||
static const char *VERSION_DATE = "14.05.2014";
|
||||
#define DB_API 4
|
||||
static const char *DESCRIPTION = "'scraper2vdr' plugin";
|
||||
static const char *MAINMENUENTRY = "Scraper2Vdr";
|
||||
|
||||
@ -34,6 +36,7 @@ public:
|
||||
cPluginScraper2vdr(void);
|
||||
virtual ~cPluginScraper2vdr();
|
||||
virtual const char *Version(void) { return VERSION; }
|
||||
virtual const char *VersionDate(void) { return VERSION_DATE; }
|
||||
virtual const char *Description(void) { return DESCRIPTION; }
|
||||
virtual const char *CommandLineHelp(void);
|
||||
virtual bool ProcessArgs(int argc, char *argv[]);
|
||||
|
43
update.c
43
update.c
@ -46,6 +46,7 @@ cUpdate::cUpdate(cScrapManager *manager) : cThread("update thread started", true
|
||||
imgPathSeries = config.imageDir + "/series";
|
||||
imgPathMovies = config.imageDir + "/movies";
|
||||
lastScrap = 0;
|
||||
lastInit = 0;
|
||||
forceUpdate = false;
|
||||
forceRecordingUpdate = false;
|
||||
forceVideoDirUpdate = false;
|
||||
@ -185,18 +186,19 @@ int cUpdate::initDb() {
|
||||
selectImg->build(")");
|
||||
selectImg->build(" from %s where ", tSeriesMedia->TableName());
|
||||
selectImg->bind(cTableSeriesMedia::fiSeriesId, cDBS::bndIn | cDBS::bndSet);
|
||||
selectImg->bind(cTableSeriesMedia::fiMediaType, cDBS::bndIn | cDBS::bndSet, " and ");
|
||||
status += selectImg->prepare();
|
||||
|
||||
// select episode image
|
||||
|
||||
imageSize.setField(&imageSizeDef);
|
||||
episodeImageSize.setField(&imageSizeDef);
|
||||
selectEpisodeImg = new cDbStatement(tSeriesMedia);
|
||||
selectEpisodeImg->build("select ");
|
||||
selectEpisodeImg->bind(cTableSeriesMedia::fiMediaWidth, cDBS::bndOut);
|
||||
selectEpisodeImg->bind(cTableSeriesMedia::fiMediaHeight, cDBS::bndOut, ", ");
|
||||
selectEpisodeImg->bind(cTableSeriesMedia::fiMediaContent, cDBS::bndOut, ", ");
|
||||
selectEpisodeImg->build(", length(");
|
||||
selectEpisodeImg->bind(&imageSize, cDBS::bndOut);
|
||||
selectEpisodeImg->bind(&episodeImageSize, cDBS::bndOut);
|
||||
selectEpisodeImg->build(")");
|
||||
selectEpisodeImg->build(" from %s where ", tSeriesMedia->TableName());
|
||||
selectEpisodeImg->bind(cTableSeriesMedia::fiSeriesId, cDBS::bndIn | cDBS::bndSet);
|
||||
@ -448,6 +450,35 @@ bool cUpdate::CheckEpgdBusy(void) {
|
||||
return busy;
|
||||
}
|
||||
|
||||
time_t cUpdate::LastPluginInit(void) {
|
||||
time_t init = 0;
|
||||
vdrDb->clear();
|
||||
vdrDb->setValue(cTableVdrs::fiUuid, config.uuid.c_str());
|
||||
if (vdrDb->find()) {
|
||||
init = vdrDb->getIntValue(cTableVdrs::fiUpdSp);
|
||||
}
|
||||
char buf[50+TB];
|
||||
strftime(buf, 50, "%y.%m.%d %H:%M:%S", localtime(&init));
|
||||
tell(0, "Last plugin init was at '%s'", buf);
|
||||
vdrDb->setValue(cTableVdrs::fiState, "attached");
|
||||
vdrDb->store();
|
||||
return init;
|
||||
}
|
||||
|
||||
void cUpdate::SaveLastPluginInit(void) {
|
||||
char* v;
|
||||
asprintf(&v, "vdr %s scraper2vdr 0.1.3", VDRVERSION);
|
||||
vdrDb->clear();
|
||||
vdrDb->setValue(cTableVdrs::fiUuid, config.uuid.c_str());
|
||||
vdrDb->setValue(cTableVdrs::fiIp, getFirstIp());
|
||||
vdrDb->setValue(cTableVdrs::fiName, getHostName());
|
||||
vdrDb->setValue(cTableVdrs::fiVersion, v);
|
||||
vdrDb->setValue(cTableVdrs::fiState, "detached");
|
||||
vdrDb->setValue(cTableVdrs::fiMaster, "n");
|
||||
vdrDb->store();
|
||||
free(v);
|
||||
}
|
||||
|
||||
int cUpdate::ReadScrapedEvents(void) {
|
||||
int eventId = 0;
|
||||
int seriesId = 0;
|
||||
@ -558,7 +589,7 @@ void cUpdate::LoadEpisodeImage(cTVDBSeries *series, int episodeId, string path)
|
||||
|
||||
if (res) {
|
||||
if (!imgExists) {
|
||||
int size = imageSize.getIntValue();
|
||||
int size = episodeImageSize.getIntValue();
|
||||
if (FILE* fh = fopen(imgPath.c_str(), "w")) {
|
||||
fwrite(tSeriesMedia->getStrValue(cTableSeriesMedia::fiMediaContent), 1, size, fh);
|
||||
fclose(fh);
|
||||
@ -1216,6 +1247,7 @@ void cUpdate::Action()
|
||||
time_t lastCleanup = time(0);
|
||||
bool init = true;
|
||||
|
||||
|
||||
while (loopActive && Running())
|
||||
{
|
||||
int reconnectTimeout; // set by checkConnection
|
||||
@ -1225,6 +1257,9 @@ void cUpdate::Action()
|
||||
if (CheckConnection(reconnectTimeout) != success)
|
||||
continue;
|
||||
|
||||
if (init)
|
||||
lastInit = LastPluginInit();
|
||||
|
||||
// auch beim init auf den epgd warten, wenn der gerade busy ist müssen die sich User etwas gedulden ;)
|
||||
|
||||
if (CheckEpgdBusy())
|
||||
@ -1352,7 +1387,7 @@ void cUpdate::Action()
|
||||
|
||||
worked = no;
|
||||
}
|
||||
|
||||
SaveLastPluginInit();
|
||||
loopActive = no;
|
||||
tell(0, "Update thread ended (pid=%d)", getpid());
|
||||
}
|
||||
|
4
update.h
4
update.h
@ -31,6 +31,7 @@ class cUpdate : public cThread {
|
||||
cTableMovieMedia* tMovieMedia;
|
||||
cTableRecordings* tRecordings;
|
||||
int lastScrap;
|
||||
time_t lastInit;
|
||||
cCondVar waitCondition;
|
||||
cMutex mutex;
|
||||
bool forceUpdate;
|
||||
@ -42,6 +43,8 @@ class cUpdate : public cThread {
|
||||
int dbConnected(int force = no) { return connection && (!force || connection->check() == success); };
|
||||
int CheckConnection(int& timeout);
|
||||
bool CheckEpgdBusy(void);
|
||||
time_t LastPluginInit(void);
|
||||
void SaveLastPluginInit(void);
|
||||
void Action(void);
|
||||
int ReadScrapedEvents(void);
|
||||
//SERIES
|
||||
@ -89,6 +92,7 @@ class cUpdate : public cThread {
|
||||
cDbStatement* selectCleanupRecordings;
|
||||
|
||||
cDbValue imageSize;
|
||||
cDbValue episodeImageSize;
|
||||
cDbValue posterSize;
|
||||
cDbValue series_id;
|
||||
cDbValue actorImageSize;
|
||||
|
Loading…
Reference in New Issue
Block a user