summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY3
-rw-r--r--Makefile7
-rw-r--r--conf/override.conf23
-rw-r--r--config.h6
-rw-r--r--imageserver.c6
-rw-r--r--imageserver.h3
-rw-r--r--overrides.c110
-rw-r--r--overrides.h23
-rw-r--r--themoviedbscraper/themoviedbscraper.c7
-rw-r--r--themoviedbscraper/themoviedbscraper.h3
-rw-r--r--thetvdbscraper/thetvdbscraper.c7
-rw-r--r--thetvdbscraper/thetvdbscraper.h3
-rw-r--r--tvscraper.c9
-rw-r--r--worker.c12
-rw-r--r--worker.h10
15 files changed, 212 insertions, 20 deletions
diff --git a/HISTORY b/HISTORY
index 1946ce7..8f46bf7 100644
--- a/HISTORY
+++ b/HISTORY
@@ -34,3 +34,6 @@ Version 0.0.5
- modification of sophisticated movie search
also "(" are considered and text is cutted, depending
if "(" or "-" occur first in search string
+- introduced possibility to ignore titles, set scrap
+ type and substitute search strings manually. See file
+ "conf/override.conf" in source tree for explanation.
diff --git a/Makefile b/Makefile
index 52439ba..b1a8662 100644
--- a/Makefile
+++ b/Makefile
@@ -20,6 +20,7 @@ PKGCFG = $(if $(VDRDIR),$(shell pkg-config --variable=$(1) $(VDRDIR)/vdr.pc),$(s
LIBDIR = $(call PKGCFG,libdir)
LOCDIR = $(call PKGCFG,locdir)
PLGCFG = $(call PKGCFG,plgcfg)
+PLGCONFDIR = $(call PKGCFG,configdir)/plugins/$(PLUGIN)
#
TMPDIR ?= /tmp
@@ -113,7 +114,11 @@ $(SOFILE): $(OBJS)
install-lib: $(SOFILE)
install -D $^ $(DESTDIR)$(LIBDIR)/$^.$(APIVERSION)
-install: install-lib install-i18n
+install-conf:
+ @mkdir -p $(PLGCONFDIR)
+ @if [ ! -f $(PLGCONFDIR)/override.conf ]; then cp conf/override.conf $(PLGCONFDIR); fi;
+
+install: install-lib install-i18n install-conf
dist: $(I18Npo) clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)
diff --git a/conf/override.conf b/conf/override.conf
new file mode 100644
index 0000000..b9d523c
--- /dev/null
+++ b/conf/override.conf
@@ -0,0 +1,23 @@
+# tvscraper override.conf
+# -----------------------------------------------------------------
+# Usage
+# -----------------------------------------------------------------
+# ignore EPG Entries or recordings with title "string" completely
+# -----------------------------------------------------------------
+# ignore;string
+# -----------------------------------------------------------------
+# define scrap type if type of EPG event or recording with title
+# "string" is not detected correctly
+# type is either "series" or "movie"
+# -----------------------------------------------------------------
+# settype;string;type
+# -----------------------------------------------------------------
+# always substitute search string of EPG event or recording with
+# title "string" with "substitution"
+# -----------------------------------------------------------------
+# substitute;string;substitution
+# -----------------------------------------------------------------
+
+ignore;Galileo
+settype;Tatort;series
+settype;Sherlock;series
diff --git a/config.h b/config.h
index 88cce72..83901b4 100644
--- a/config.h
+++ b/config.h
@@ -3,6 +3,12 @@
using namespace std;
+enum scrapType {
+ scrapSeries,
+ scrapMovie,
+ scrapNone
+};
+
class cTVScraperConfig {
private:
string baseDir;
diff --git a/imageserver.c b/imageserver.c
index 2fb14a4..f638355 100644
--- a/imageserver.c
+++ b/imageserver.c
@@ -2,8 +2,9 @@
using namespace std;
-cImageServer::cImageServer(cTVScraperDB *db) {
+cImageServer::cImageServer(cTVScraperDB *db, cOverRides *overrides) {
this->db = db;
+ this->overrides = overrides;
}
cImageServer::~cImageServer() {
@@ -11,6 +12,9 @@ cImageServer::~cImageServer() {
scrapType cImageServer::GetScrapType(const cEvent *event) {
scrapType type = scrapNone;
+ type = overrides->Type(event->Title());
+ if (type != scrapNone)
+ return type;
int duration = event->Duration() / 60;
if ((duration > 9) && (duration <= 75)) {
type = scrapSeries;
diff --git a/imageserver.h b/imageserver.h
index a8bfd8b..6661684 100644
--- a/imageserver.h
+++ b/imageserver.h
@@ -5,8 +5,9 @@ using namespace std;
class cImageServer {
private:
cTVScraperDB *db;
+ cOverRides *overrides;
public:
- cImageServer(cTVScraperDB *db);
+ cImageServer(cTVScraperDB *db, cOverRides *overrides);
virtual ~cImageServer(void);
scrapType GetScrapType(const cEvent *event);
int GetID(int eventID, scrapType type, bool isRecording);
diff --git a/overrides.c b/overrides.c
new file mode 100644
index 0000000..2eb9e4e
--- /dev/null
+++ b/overrides.c
@@ -0,0 +1,110 @@
+#include <map>
+#include "overrides.h"
+
+using namespace std;
+
+cOverRides::cOverRides(void) {
+}
+
+cOverRides::~cOverRides() {
+}
+
+void cOverRides::ReadConfig(string confDir) {
+ stringstream sstrConfFile;
+ sstrConfFile << confDir << "/override.conf";
+ string confFile = sstrConfFile.str();
+ dsyslog("tvscraper: reading overrides from %s", confFile.c_str());
+ if (access(confFile.c_str(), F_OK) == 0) {
+ FILE *f = fopen(confFile.c_str(), "r");
+ if (f) {
+ char *s;
+ cReadLine ReadLine;
+ while ((s = ReadLine.Read(f)) != NULL) {
+ char *p = strchr(s, '#');
+ if (p)
+ *p = 0;
+ stripspace(s);
+ if (!isempty(s)) {
+ ReadConfigLine(s);
+ }
+ }
+ fclose(f);
+ }
+ }
+}
+
+void cOverRides::ReadConfigLine(string line) {
+ splitstring s(line.c_str());
+ vector<string> flds = s.split(';');
+ if (flds.size() > 0) {
+ if (!flds[0].compare("ignore")) {
+ if (flds.size() == 2) {
+ ignores.push_back(flds[1]);
+ }
+ } else if (!flds[0].compare("settype")) {
+ if (flds.size() == 3) {
+ if (!flds[2].compare("series")) {
+ searchTypes.insert(pair<string, scrapType>(flds[1], scrapSeries));
+ } else if (!flds[2].compare("movie")) {
+ searchTypes.insert(pair<string, scrapType>(flds[1], scrapMovie));
+ }
+ }
+ } else if (!flds[0].compare("substitute")) {
+ if (flds.size() == 3) {
+ substitutes.insert(pair<string, string>(flds[1], flds[2]));
+ }
+ }
+ }
+}
+
+bool cOverRides::Ignore(string title) {
+ vector<string>::iterator pos;
+ for ( pos = ignores.begin(); pos != ignores.end(); ++pos) {
+ if (!title.compare(pos->c_str())) {
+ if (config.enableDebug)
+ esyslog("tvscraper: ignoring \"%s\" because of override.conf", title.c_str());
+ return true;
+ }
+ }
+ return false;
+}
+
+string cOverRides::Substitute(string title) {
+ map<string,string>::iterator hit = substitutes.find(title);
+ if (hit != substitutes.end()) {
+ if (config.enableDebug)
+ esyslog("tvscraper: substitute \"%s\" with \"%s\" because of override.conf", title.c_str(), ((string)hit->second).c_str());
+ return (string)hit->second;
+ }
+ return title;
+}
+
+scrapType cOverRides::Type(string title) {
+ map<string,scrapType>::iterator hit = searchTypes.find(title);
+ if (hit != searchTypes.end()) {
+ if (config.enableDebug)
+ esyslog("tvscraper: using type %d for \"%s\" because of override.conf", (int)hit->second, title.c_str());
+ return (scrapType)hit->second;
+ }
+ return scrapNone;
+}
+
+void cOverRides::Dump(void) {
+ esyslog("tvscraper: ignoring the following titles:");
+ vector<string>::iterator pos;
+ for ( pos = ignores.begin(); pos != ignores.end(); ++pos) {
+ esyslog("tvscraper: ignore \"%s\"", pos->c_str());
+ }
+
+ esyslog("tvscraper: fixed scrap types for the following titles:");
+ map<string,scrapType>::iterator pos2;
+ for( pos2 = searchTypes.begin(); pos2 != searchTypes.end(); ++pos2) {
+ esyslog("tvscraper: title \"%s\" has Type %d", ((string)pos2->first).c_str(), (int)pos2->second);
+ }
+
+ esyslog("tvscraper: substitutions for the following titles:");
+ map<string,string>::iterator pos3;
+ for( pos3 = substitutes.begin(); pos3 != substitutes.end(); ++pos3) {
+ esyslog("tvscraper: substitute \"%s\" with \"%s\"", ((string)pos3->first).c_str(), ((string)pos3->second).c_str());
+ }
+}
diff --git a/overrides.h b/overrides.h
new file mode 100644
index 0000000..23ea229
--- /dev/null
+++ b/overrides.h
@@ -0,0 +1,23 @@
+#ifndef __TVSCRAPER_OVERRIDES_H
+#define __TVSCRAPER_OVERRIDES_H
+
+using namespace std;
+
+// --- cOverRides --------------------------------------------------------
+
+class cOverRides {
+private:
+ vector<string> ignores;
+ map<string,scrapType> searchTypes;
+ map<string,string> substitutes;
+ void ReadConfigLine(string line);
+public:
+ cOverRides(void);
+ virtual ~cOverRides(void);
+ void ReadConfig(string confDir);
+ bool Ignore(string title);
+ string Substitute(string title);
+ scrapType Type(string title);
+ void Dump(void);
+};
+#endif //__TVSCRAPER_OVERRIDES_H \ No newline at end of file
diff --git a/themoviedbscraper/themoviedbscraper.c b/themoviedbscraper/themoviedbscraper.c
index 77021eb..aadbb72 100644
--- a/themoviedbscraper/themoviedbscraper.c
+++ b/themoviedbscraper/themoviedbscraper.c
@@ -7,12 +7,13 @@
using namespace std;
-cMovieDBScraper::cMovieDBScraper(string baseDir, cTVScraperDB *db, string language) {
+cMovieDBScraper::cMovieDBScraper(string baseDir, cTVScraperDB *db, string language, cOverRides *overrides) {
apiKey = "abb01b5a277b9c2c60ec0302d83c5ee9";
this->language = language;
baseURL = "api.themoviedb.org/3";
this->baseDir = baseDir;
this->db = db;
+ this->overrides = overrides;
posterSize = "w500";
backdropSize = "w1280";
actorthumbSize = "h632";
@@ -23,6 +24,10 @@ cMovieDBScraper::~cMovieDBScraper() {
void cMovieDBScraper::Scrap(const cEvent *event, int recordingID) {
string movieName = event->Title();
+ if (overrides->Ignore(movieName)) {
+ return;
+ }
+ movieName = overrides->Substitute(movieName);
int eventID = (int)event->EventID();
if (config.enableDebug)
esyslog("tvscraper: scraping movie \"%s\"", movieName.c_str());
diff --git a/themoviedbscraper/themoviedbscraper.h b/themoviedbscraper/themoviedbscraper.h
index fe6104f..5bd5e89 100644
--- a/themoviedbscraper/themoviedbscraper.h
+++ b/themoviedbscraper/themoviedbscraper.h
@@ -16,6 +16,7 @@ private:
string backdropSize;
string actorthumbSize;
cTVScraperDB *db;
+ cOverRides *overrides;
map<string, int> cache;
bool parseJSON(string jsonString);
int SearchMovie(string movieName);
@@ -25,7 +26,7 @@ private:
cMovieDbActors *ReadActors(int movieID);
void StoreMedia(cMovieDbMovie *movie, cMovieDbActors *actors);
public:
- cMovieDBScraper(string baseDir, cTVScraperDB *db, string language);
+ cMovieDBScraper(string baseDir, cTVScraperDB *db, string language, cOverRides *overrides);
virtual ~cMovieDBScraper(void);
bool Connect(void);
void Scrap(const cEvent *event, int recordingID = 0);
diff --git a/thetvdbscraper/thetvdbscraper.c b/thetvdbscraper/thetvdbscraper.c
index 19cbc7e..f4b4b83 100644
--- a/thetvdbscraper/thetvdbscraper.c
+++ b/thetvdbscraper/thetvdbscraper.c
@@ -8,12 +8,13 @@
using namespace std;
-cTVDBScraper::cTVDBScraper(string baseDir, cTVScraperDB *db, string language) {
+cTVDBScraper::cTVDBScraper(string baseDir, cTVScraperDB *db, string language, cOverRides *overrides) {
apiKey = "E9DBB94CA50832ED";
baseURL = "thetvdb.com";
this->baseDir = baseDir;
this->language = language;
this->db = db;
+ this->overrides = overrides;
mirrors = NULL;
}
@@ -24,6 +25,10 @@ cTVDBScraper::~cTVDBScraper() {
void cTVDBScraper::Scrap(const cEvent *event, int recordingID) {
string seriesName = event->Title();
+ if (overrides->Ignore(seriesName)) {
+ return;
+ }
+ seriesName = overrides->Substitute(seriesName);
if (config.enableDebug)
esyslog("tvscraper: scraping series \"%s\"", seriesName.c_str());
int eventID = (int)event->EventID();
diff --git a/thetvdbscraper/thetvdbscraper.h b/thetvdbscraper/thetvdbscraper.h
index 2e45f75..296c70b 100644
--- a/thetvdbscraper/thetvdbscraper.h
+++ b/thetvdbscraper/thetvdbscraper.h
@@ -12,6 +12,7 @@ private:
string baseDir;
string language;
cTVScraperDB *db;
+ cOverRides *overrides;
map<string, int> cache;
cTVDBMirrors *mirrors;
cTVDBSeries *ReadSeries(string seriesName);
@@ -19,7 +20,7 @@ private:
cTVDBActors *ReadSeriesActors(int seriesID);
void StoreMedia(cTVDBSeries *series, cTVDBSeriesMedia *media, cTVDBActors *actors);
public:
- cTVDBScraper(string baseDir, cTVScraperDB *db, string language);
+ cTVDBScraper(string baseDir, cTVScraperDB *db, string language, cOverRides *overrides);
virtual ~cTVDBScraper(void);
bool Connect(void);
void Scrap(const cEvent *event, int recordingID = 0);
diff --git a/tvscraper.c b/tvscraper.c
index 6c45942..71e5859 100644
--- a/tvscraper.c
+++ b/tvscraper.c
@@ -14,6 +14,7 @@
#include "tools/stringhelpers.c"
#include "config.c"
cTVScraperConfig config;
+#include "overrides.c"
#include "tvscraperdb.c"
#include "thetvdbscraper/tvdbmirrors.c"
#include "thetvdbscraper/tvdbseries.c"
@@ -38,6 +39,7 @@ private:
cTVScraperDB *db;
cTVScraperWorker *workerThread;
cImageServer *imageServer;
+ cOverRides *overrides;
public:
cPluginTvscraper(void);
virtual ~cPluginTvscraper();
@@ -105,8 +107,10 @@ bool cPluginTvscraper::Start(void) {
esyslog("tvscraper: could not connect to Database. Aborting!");
return false;
};
- imageServer = new cImageServer(db);
- workerThread = new cTVScraperWorker(db);
+ overrides = new cOverRides();
+ overrides->ReadConfig(cPlugin::ConfigDirectory(PLUGIN_NAME_I18N));
+ imageServer = new cImageServer(db, overrides);
+ workerThread = new cTVScraperWorker(db, overrides);
workerThread->SetDirectories();
workerThread->SetLanguage();
workerThread->Start();
@@ -120,6 +124,7 @@ void cPluginTvscraper::Stop(void) {
delete workerThread;
delete imageServer;
delete db;
+ delete overrides;
}
void cPluginTvscraper::Housekeeping(void) {
diff --git a/worker.c b/worker.c
index 5e3ac49..759e082 100644
--- a/worker.c
+++ b/worker.c
@@ -3,11 +3,12 @@
using namespace std;
-cTVScraperWorker::cTVScraperWorker(cTVScraperDB *db) : cThread("tvscraper", true) {
+cTVScraperWorker::cTVScraperWorker(cTVScraperDB *db, cOverRides *overrides) : cThread("tvscraper", true) {
startLoop = true;
scanVideoDir = false;
manualScan = false;
this->db = db;
+ this->overrides = overrides;
moviedbScraper = NULL;
tvdbScraper = NULL;
initSleep = 2 * 60 * 1000;
@@ -78,6 +79,9 @@ void cTVScraperWorker::SetDirectories(void) {
scrapType cTVScraperWorker::GetScrapType(const cEvent *event) {
scrapType type = scrapNone;
+ type = overrides->Type(event->Title());
+ if (type != scrapNone)
+ return type;
int duration = event->Duration() / 60;
if ((duration > 9) && (duration <= 75)) {
type = scrapSeries;
@@ -89,14 +93,14 @@ scrapType cTVScraperWorker::GetScrapType(const cEvent *event) {
bool cTVScraperWorker::ConnectScrapers(void) {
if (!moviedbScraper) {
- moviedbScraper = new cMovieDBScraper(movieDir, db, language);
+ moviedbScraper = new cMovieDBScraper(movieDir, db, language, overrides);
if (!moviedbScraper->Connect()) {
esyslog("tvscraper: ERROR, connection to TheMovieDB failed");
return false;
}
}
if (!tvdbScraper) {
- tvdbScraper = new cTVDBScraper(seriesDir, db, language);
+ tvdbScraper = new cTVDBScraper(seriesDir, db, language, overrides);
if (!tvdbScraper->Connect()) {
esyslog("tvscraper: ERROR, connection to TheTVDB failed");
return false;
@@ -215,7 +219,7 @@ void cTVScraperWorker::Action(void) {
mutex.Lock();
dsyslog("tvscraper: waiting %d minutes to start main loop", initSleep / 1000 / 60);
waitCondition.TimedWait(mutex, initSleep);
-
+
while (Running()) {
if (scanVideoDir) {
scanVideoDir = false;
diff --git a/worker.h b/worker.h
index d89ab8b..bf107b5 100644
--- a/worker.h
+++ b/worker.h
@@ -3,12 +3,6 @@
// --- cTVScraperWorker -------------------------------------------------------------
-enum scrapType {
- scrapSeries,
- scrapMovie,
- scrapNone
-};
-
class cTVScraperWorker : public cThread {
private:
bool startLoop;
@@ -16,8 +10,10 @@ private:
bool manualScan;
string language;
string plgBaseDir;
+ string plgConfDir;
string seriesDir;
string movieDir;
+ cOverRides *overrides;
int initSleep;
int loopSleep;
cCondVar waitCondition;
@@ -33,7 +29,7 @@ private:
void ScrapRecordings(void);
bool StartScrapping(void);
public:
- cTVScraperWorker(cTVScraperDB *db);
+ cTVScraperWorker(cTVScraperDB *db, cOverRides *overrides);
virtual ~cTVScraperWorker(void);
void SetLanguage(void);
void SetDirectories(void);