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
|
// Constants
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
static const char *VERSION = "0.1.3";
|
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 *DESCRIPTION = "'scraper2vdr' plugin";
|
||||||
static const char *MAINMENUENTRY = "Scraper2Vdr";
|
static const char *MAINMENUENTRY = "Scraper2Vdr";
|
||||||
|
|
||||||
@ -34,6 +36,7 @@ public:
|
|||||||
cPluginScraper2vdr(void);
|
cPluginScraper2vdr(void);
|
||||||
virtual ~cPluginScraper2vdr();
|
virtual ~cPluginScraper2vdr();
|
||||||
virtual const char *Version(void) { return VERSION; }
|
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 *Description(void) { return DESCRIPTION; }
|
||||||
virtual const char *CommandLineHelp(void);
|
virtual const char *CommandLineHelp(void);
|
||||||
virtual bool ProcessArgs(int argc, char *argv[]);
|
virtual bool ProcessArgs(int argc, char *argv[]);
|
||||||
|
65
update.c
65
update.c
@ -46,6 +46,7 @@ cUpdate::cUpdate(cScrapManager *manager) : cThread("update thread started", true
|
|||||||
imgPathSeries = config.imageDir + "/series";
|
imgPathSeries = config.imageDir + "/series";
|
||||||
imgPathMovies = config.imageDir + "/movies";
|
imgPathMovies = config.imageDir + "/movies";
|
||||||
lastScrap = 0;
|
lastScrap = 0;
|
||||||
|
lastInit = 0;
|
||||||
forceUpdate = false;
|
forceUpdate = false;
|
||||||
forceRecordingUpdate = false;
|
forceRecordingUpdate = false;
|
||||||
forceVideoDirUpdate = false;
|
forceVideoDirUpdate = false;
|
||||||
@ -185,18 +186,19 @@ int cUpdate::initDb() {
|
|||||||
selectImg->build(")");
|
selectImg->build(")");
|
||||||
selectImg->build(" from %s where ", tSeriesMedia->TableName());
|
selectImg->build(" from %s where ", tSeriesMedia->TableName());
|
||||||
selectImg->bind(cTableSeriesMedia::fiSeriesId, cDBS::bndIn | cDBS::bndSet);
|
selectImg->bind(cTableSeriesMedia::fiSeriesId, cDBS::bndIn | cDBS::bndSet);
|
||||||
|
selectImg->bind(cTableSeriesMedia::fiMediaType, cDBS::bndIn | cDBS::bndSet, " and ");
|
||||||
status += selectImg->prepare();
|
status += selectImg->prepare();
|
||||||
|
|
||||||
// select episode image
|
// select episode image
|
||||||
|
|
||||||
imageSize.setField(&imageSizeDef);
|
episodeImageSize.setField(&imageSizeDef);
|
||||||
selectEpisodeImg = new cDbStatement(tSeriesMedia);
|
selectEpisodeImg = new cDbStatement(tSeriesMedia);
|
||||||
selectEpisodeImg->build("select ");
|
selectEpisodeImg->build("select ");
|
||||||
selectEpisodeImg->bind(cTableSeriesMedia::fiMediaWidth, cDBS::bndOut);
|
selectEpisodeImg->bind(cTableSeriesMedia::fiMediaWidth, cDBS::bndOut);
|
||||||
selectEpisodeImg->bind(cTableSeriesMedia::fiMediaHeight, cDBS::bndOut, ", ");
|
selectEpisodeImg->bind(cTableSeriesMedia::fiMediaHeight, cDBS::bndOut, ", ");
|
||||||
selectEpisodeImg->bind(cTableSeriesMedia::fiMediaContent, cDBS::bndOut, ", ");
|
selectEpisodeImg->bind(cTableSeriesMedia::fiMediaContent, cDBS::bndOut, ", ");
|
||||||
selectEpisodeImg->build(", length(");
|
selectEpisodeImg->build(", length(");
|
||||||
selectEpisodeImg->bind(&imageSize, cDBS::bndOut);
|
selectEpisodeImg->bind(&episodeImageSize, cDBS::bndOut);
|
||||||
selectEpisodeImg->build(")");
|
selectEpisodeImg->build(")");
|
||||||
selectEpisodeImg->build(" from %s where ", tSeriesMedia->TableName());
|
selectEpisodeImg->build(" from %s where ", tSeriesMedia->TableName());
|
||||||
selectEpisodeImg->bind(cTableSeriesMedia::fiSeriesId, cDBS::bndIn | cDBS::bndSet);
|
selectEpisodeImg->bind(cTableSeriesMedia::fiSeriesId, cDBS::bndIn | cDBS::bndSet);
|
||||||
@ -433,19 +435,48 @@ int cUpdate::CheckConnection(int& timeout) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool cUpdate::CheckEpgdBusy(void) {
|
bool cUpdate::CheckEpgdBusy(void) {
|
||||||
int busy = false;
|
int busy = false;
|
||||||
vdrDb->clear();
|
vdrDb->clear();
|
||||||
vdrDb->setValue(cTableVdrs::fiUuid, EPGDNAME);
|
vdrDb->setValue(cTableVdrs::fiUuid, EPGDNAME);
|
||||||
|
|
||||||
if (vdrDb->find()) {
|
if (vdrDb->find()) {
|
||||||
Es::State epgdState = cEpgdState::toState(vdrDb->getStrValue(cTableVdrs::fiState));
|
Es::State epgdState = cEpgdState::toState(vdrDb->getStrValue(cTableVdrs::fiState));
|
||||||
// ignore esBusyImages until we don't write this table
|
// ignore esBusyImages until we don't write this table
|
||||||
if (epgdState >= cEpgdState::esBusy && epgdState < cEpgdState::esBusyImages)
|
if (epgdState >= cEpgdState::esBusy && epgdState < cEpgdState::esBusyImages)
|
||||||
busy = true;
|
busy = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
vdrDb->reset();
|
vdrDb->reset();
|
||||||
return busy;
|
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 cUpdate::ReadScrapedEvents(void) {
|
||||||
@ -558,7 +589,7 @@ void cUpdate::LoadEpisodeImage(cTVDBSeries *series, int episodeId, string path)
|
|||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
if (!imgExists) {
|
if (!imgExists) {
|
||||||
int size = imageSize.getIntValue();
|
int size = episodeImageSize.getIntValue();
|
||||||
if (FILE* fh = fopen(imgPath.c_str(), "w")) {
|
if (FILE* fh = fopen(imgPath.c_str(), "w")) {
|
||||||
fwrite(tSeriesMedia->getStrValue(cTableSeriesMedia::fiMediaContent), 1, size, fh);
|
fwrite(tSeriesMedia->getStrValue(cTableSeriesMedia::fiMediaContent), 1, size, fh);
|
||||||
fclose(fh);
|
fclose(fh);
|
||||||
@ -1216,6 +1247,7 @@ void cUpdate::Action()
|
|||||||
time_t lastCleanup = time(0);
|
time_t lastCleanup = time(0);
|
||||||
bool init = true;
|
bool init = true;
|
||||||
|
|
||||||
|
|
||||||
while (loopActive && Running())
|
while (loopActive && Running())
|
||||||
{
|
{
|
||||||
int reconnectTimeout; // set by checkConnection
|
int reconnectTimeout; // set by checkConnection
|
||||||
@ -1225,6 +1257,9 @@ void cUpdate::Action()
|
|||||||
if (CheckConnection(reconnectTimeout) != success)
|
if (CheckConnection(reconnectTimeout) != success)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (init)
|
||||||
|
lastInit = LastPluginInit();
|
||||||
|
|
||||||
// auch beim init auf den epgd warten, wenn der gerade busy ist müssen die sich User etwas gedulden ;)
|
// auch beim init auf den epgd warten, wenn der gerade busy ist müssen die sich User etwas gedulden ;)
|
||||||
|
|
||||||
if (CheckEpgdBusy())
|
if (CheckEpgdBusy())
|
||||||
@ -1352,7 +1387,7 @@ void cUpdate::Action()
|
|||||||
|
|
||||||
worked = no;
|
worked = no;
|
||||||
}
|
}
|
||||||
|
SaveLastPluginInit();
|
||||||
loopActive = no;
|
loopActive = no;
|
||||||
tell(0, "Update thread ended (pid=%d)", getpid());
|
tell(0, "Update thread ended (pid=%d)", getpid());
|
||||||
}
|
}
|
||||||
|
4
update.h
4
update.h
@ -31,6 +31,7 @@ class cUpdate : public cThread {
|
|||||||
cTableMovieMedia* tMovieMedia;
|
cTableMovieMedia* tMovieMedia;
|
||||||
cTableRecordings* tRecordings;
|
cTableRecordings* tRecordings;
|
||||||
int lastScrap;
|
int lastScrap;
|
||||||
|
time_t lastInit;
|
||||||
cCondVar waitCondition;
|
cCondVar waitCondition;
|
||||||
cMutex mutex;
|
cMutex mutex;
|
||||||
bool forceUpdate;
|
bool forceUpdate;
|
||||||
@ -42,6 +43,8 @@ class cUpdate : public cThread {
|
|||||||
int dbConnected(int force = no) { return connection && (!force || connection->check() == success); };
|
int dbConnected(int force = no) { return connection && (!force || connection->check() == success); };
|
||||||
int CheckConnection(int& timeout);
|
int CheckConnection(int& timeout);
|
||||||
bool CheckEpgdBusy(void);
|
bool CheckEpgdBusy(void);
|
||||||
|
time_t LastPluginInit(void);
|
||||||
|
void SaveLastPluginInit(void);
|
||||||
void Action(void);
|
void Action(void);
|
||||||
int ReadScrapedEvents(void);
|
int ReadScrapedEvents(void);
|
||||||
//SERIES
|
//SERIES
|
||||||
@ -89,6 +92,7 @@ class cUpdate : public cThread {
|
|||||||
cDbStatement* selectCleanupRecordings;
|
cDbStatement* selectCleanupRecordings;
|
||||||
|
|
||||||
cDbValue imageSize;
|
cDbValue imageSize;
|
||||||
|
cDbValue episodeImageSize;
|
||||||
cDbValue posterSize;
|
cDbValue posterSize;
|
||||||
cDbValue series_id;
|
cDbValue series_id;
|
||||||
cDbValue actorImageSize;
|
cDbValue actorImageSize;
|
||||||
|
Loading…
Reference in New Issue
Block a user