summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY4
-rw-r--r--themoviedbscraper/themoviedbscraper.c49
-rw-r--r--themoviedbscraper/themoviedbscraper.h1
-rw-r--r--worker.c2
4 files changed, 44 insertions, 12 deletions
diff --git a/HISTORY b/HISTORY
index 4422ba7..1946ce7 100644
--- a/HISTORY
+++ b/HISTORY
@@ -30,3 +30,7 @@ Version 0.0.4
Version 0.0.5
- Fixed a bug that banner is only filled with path if
image exists in Filesystem
+- str_cut removes ending space
+- modification of sophisticated movie search
+ also "(" are considered and text is cutted, depending
+ if "(" or "-" occur first in search string
diff --git a/themoviedbscraper/themoviedbscraper.c b/themoviedbscraper/themoviedbscraper.c
index 2874030..77021eb 100644
--- a/themoviedbscraper/themoviedbscraper.c
+++ b/themoviedbscraper/themoviedbscraper.c
@@ -122,24 +122,51 @@ int cMovieDBScraper::SearchMovie(string movieName) {
int cMovieDBScraper::SearchMovieElaborated(string movieName) {
int movieID = -1;
+
+ size_t posHyphen = movieName.find_first_of("-");
+ size_t posBracket = movieName.find_first_of("(");
+ bool hasHyphen = (posHyphen != string::npos)?true:false;
+ bool hasBracket = (posBracket != string::npos)?true:false;
+ string movieNameMod;
//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;
+ if (hasBracket) {
+ movieNameMod = str_replace("-", " ", movieName);
+ if (config.enableDebug)
+ esyslog("tvscraper: scraping movie \"%s\"", movieNameMod.c_str());
+ movieID = SearchMovie(movieNameMod);
+ if (movieID > 0)
+ return movieID;
+ }
+ //if both hyphens and brackets found, check what comes first
+ if (hasHyphen && hasBracket) {
+ //if bracket comes after hyphen, remove bracket first
+ if (posBracket > posHyphen) {
+ movieID = SearchMovieModified("(", movieName);
+ if (movieID > 0)
+ return movieID;
+ movieID = SearchMovieModified("-", movieName);
+ } else {
+ movieID = SearchMovieModified("-", movieName);
+ if (movieID > 0)
+ return movieID;
+ movieID = SearchMovieModified("(", movieName);
+ }
+ } else if (hasHyphen) {
+ movieID = SearchMovieModified("-", movieName);
+ } else if (hasBracket) {
+ movieID = SearchMovieModified("(", movieName);
+ }
+ return movieID;
+}
- //now remove everything after "-"
- movieNameMod = str_cut("-", movieName);
+int cMovieDBScraper::SearchMovieModified(string separator, string movieName) {
+ int movieID = -1;
+ string movieNameMod = str_cut(separator, 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;
}
diff --git a/themoviedbscraper/themoviedbscraper.h b/themoviedbscraper/themoviedbscraper.h
index c6de7b6..fe6104f 100644
--- a/themoviedbscraper/themoviedbscraper.h
+++ b/themoviedbscraper/themoviedbscraper.h
@@ -20,6 +20,7 @@ private:
bool parseJSON(string jsonString);
int SearchMovie(string movieName);
int SearchMovieElaborated(string movieName);
+ int SearchMovieModified(string separator, string movieName);
cMovieDbMovie *ReadMovie(int movieID);
cMovieDbActors *ReadActors(int movieID);
void StoreMedia(cMovieDbMovie *movie, cMovieDbActors *actors);
diff --git a/worker.c b/worker.c
index 9344f8f..5e3ac49 100644
--- a/worker.c
+++ b/worker.c
@@ -215,7 +215,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;