summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouis <louis.braun@gmx.de>2013-08-30 16:10:51 +0200
committerlouis <louis.braun@gmx.de>2013-08-30 16:10:51 +0200
commitb503c5238ea1593c209d0a9cdfd8bca29efe90c3 (patch)
tree9efa926f72a8491dc8eca22bd119204e1766abb5
parent2e460f46395dd61931d3dd431a7ad8dd465f1b81 (diff)
downloadvdr-plugin-tvscraper-b503c5238ea1593c209d0a9cdfd8bca29efe90c3.tar.gz
vdr-plugin-tvscraper-b503c5238ea1593c209d0a9cdfd8bca29efe90c3.tar.bz2
Version 0.0.4
-rw-r--r--HISTORY6
-rw-r--r--themoviedbscraper/themoviedbscraper.c27
-rw-r--r--themoviedbscraper/themoviedbscraper.h1
-rw-r--r--tools/stringhelpers.c20
-rw-r--r--tvscraper.c3
-rw-r--r--worker.c15
6 files changed, 64 insertions, 8 deletions
diff --git a/HISTORY b/HISTORY
index ff217dd..d69b584 100644
--- a/HISTORY
+++ b/HISTORY
@@ -21,4 +21,8 @@ Version 0.0.3
- Removed quotation marks around search strings
Version 0.0.4
-- Scrap a running recording if it is not scraped already
+- Scrap a running recording also if the corresponding
+ channel was not scraped already
+- do some more sophisticated search for recordings
+ first replace all "-" with " " in rec title
+ second remove everything behind "-" in rec title
diff --git a/themoviedbscraper/themoviedbscraper.c b/themoviedbscraper/themoviedbscraper.c
index 8dd05df..2874030 100644
--- a/themoviedbscraper/themoviedbscraper.c
+++ b/themoviedbscraper/themoviedbscraper.c
@@ -27,6 +27,10 @@ void cMovieDBScraper::Scrap(const cEvent *event, int recordingID) {
if (config.enableDebug)
esyslog("tvscraper: scraping movie \"%s\"", movieName.c_str());
int movieID = SearchMovie(movieName);
+ if ((movieID < 1) && (recordingID > 0)){
+ //if recording, do some more sophisticated search
+ movieID = SearchMovieElaborated(movieName);
+ }
if (movieID < 1) {
if (config.enableDebug)
esyslog("tvscraper: nothing found for \"%s\"", movieName.c_str());
@@ -116,6 +120,29 @@ int cMovieDBScraper::SearchMovie(string movieName) {
return movieID;
}
+int cMovieDBScraper::SearchMovieElaborated(string movieName) {
+ int movieID = -1;
+ //first remove all "-"
+ string movieNameMod = str_replace("-", " ", movieName);
+ if (config.enableDebug)
+ esyslog("tvscraper: scraping movie \"%s\"", movieNameMod.c_str());
+ movieID = SearchMovie(movieNameMod);
+ if (movieID > 0)
+ return movieID;
+
+ //now remove everything after "-"
+ movieNameMod = str_cut("-", movieName);
+ if (movieNameMod.size() > 3) {
+ if (config.enableDebug)
+ esyslog("tvscraper: scraping movie \"%s\"", movieNameMod.c_str());
+ movieID = SearchMovie(movieNameMod);
+ }
+ if (movieID > 0)
+ return movieID;
+
+ return movieID;
+}
+
cMovieDbMovie *cMovieDBScraper::ReadMovie(int movieID) {
stringstream url;
url << baseURL << "/movie/" << movieID << "?api_key=" << apiKey << "&language=" << language.c_str();
diff --git a/themoviedbscraper/themoviedbscraper.h b/themoviedbscraper/themoviedbscraper.h
index 3560fb5..c6de7b6 100644
--- a/themoviedbscraper/themoviedbscraper.h
+++ b/themoviedbscraper/themoviedbscraper.h
@@ -19,6 +19,7 @@ private:
map<string, int> cache;
bool parseJSON(string jsonString);
int SearchMovie(string movieName);
+ int SearchMovieElaborated(string movieName);
cMovieDbMovie *ReadMovie(int movieID);
cMovieDbActors *ReadActors(int movieID);
void StoreMedia(cMovieDbMovie *movie, cMovieDbActors *actors);
diff --git a/tools/stringhelpers.c b/tools/stringhelpers.c
new file mode 100644
index 0000000..2eb3c8c
--- /dev/null
+++ b/tools/stringhelpers.c
@@ -0,0 +1,20 @@
+using namespace std;
+//replace all "search" with "replace" in "subject"
+string str_replace(const string& search, const string& replace, const string& subject) {
+ string str = subject;
+ size_t pos = 0;
+ while((pos = str.find(search, pos)) != string::npos) {
+ str.replace(pos, search.length(), replace);
+ pos += replace.length();
+ }
+ return str;
+}
+//cut string after first "search"
+string str_cut(const string& search, const string& subject) {
+ string str = subject;
+ size_t found = str.find_first_of(search);
+ if (found != string::npos) {
+ return str.substr(0, found);
+ }
+ return "";
+}
diff --git a/tvscraper.c b/tvscraper.c
index f3197ff..6c45942 100644
--- a/tvscraper.c
+++ b/tvscraper.c
@@ -11,6 +11,7 @@
#include "tools/filesystem.c"
#include "tools/fuzzy.c"
#include "tools/splitstring.c"
+#include "tools/stringhelpers.c"
#include "config.c"
cTVScraperConfig config;
#include "tvscraperdb.c"
@@ -27,7 +28,7 @@ cTVScraperConfig config;
#include "imageserver.c"
#include "setup.c"
-static const char *VERSION = "0.0.3";
+static const char *VERSION = "0.0.4";
static const char *DESCRIPTION = "Scraping movie and series info";
static const char *MAINMENUENTRY = "TV Scraper";
diff --git a/worker.c b/worker.c
index 85bbfaa..9344f8f 100644
--- a/worker.c
+++ b/worker.c
@@ -181,15 +181,20 @@ void cTVScraperWorker::CheckRunningTimers(void) {
scrapType type = GetScrapType(event);
if (type == scrapSeries) {
if (!db->SetRecordingSeries((int)event->EventID())) {
- tvdbScraper->Scrap(event, (int)event->EventID());
+ if (ConnectScrapers()) {
+ tvdbScraper->Scrap(event, (int)event->EventID());
+ }
}
} else if (type == scrapMovie) {
if (!db->SetRecordingMovie((int)event->EventID())) {
- moviedbScraper->Scrap(event, (int)event->EventID());
+ if (ConnectScrapers()) {
+ moviedbScraper->Scrap(event, (int)event->EventID());
+ }
}
}
}
}
+ DisconnectScrapers();
}
bool cTVScraperWorker::StartScrapping(void) {
@@ -206,6 +211,7 @@ bool cTVScraperWorker::StartScrapping(void) {
void cTVScraperWorker::Action(void) {
if (!startLoop)
return;
+
mutex.Lock();
dsyslog("tvscraper: waiting %d minutes to start main loop", initSleep / 1000 / 60);
waitCondition.TimedWait(mutex, initSleep);
@@ -220,10 +226,7 @@ void cTVScraperWorker::Action(void) {
DisconnectScrapers();
continue;
}
- if (ConnectScrapers()) {
- CheckRunningTimers();
- DisconnectScrapers();
- }
+ CheckRunningTimers();
if (StartScrapping()) {
dsyslog("tvscraper: start scraping epg");
db->ClearOutdated(movieDir);