From 35b94ecc0a50a4aaed48e609ea3981b873389924 Mon Sep 17 00:00:00 2001 From: FlatTV Date: Sat, 9 Jul 2016 15:00:49 +0200 Subject: [PATCH] imdb.cpp: cleanup before download and reduce timeouts Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/1b5b6f4cb27fb954d84c973f913652392fb4d6fa Author: FlatTV Date: 2016-07-09 (Sat, 09 Jul 2016) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/imdb.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/gui/imdb.cpp b/src/gui/imdb.cpp index 6738139e4..98d5d7e40 100644 --- a/src/gui/imdb.cpp +++ b/src/gui/imdb.cpp @@ -223,6 +223,11 @@ std::string CIMDB::googleIMDb(std::string searchStr) std::string httpString = "imdb+"; char* searchStr_ = (char*) searchStr.c_str(); + m.clear(); + unlink(soutfile.c_str()); + unlink(IMDbAPI.c_str()); + unlink(posterfile.c_str()); + while (*searchStr_!=0) { if ( (*searchStr_==' ') ) @@ -293,7 +298,7 @@ int CIMDB::getIMDb(const std::string& epgTitle) std::string url = IMDburl + imdb_ID; - if(httpTool.downloadFile(url, IMDbAPI.c_str())) + if(httpTool.downloadFile(url, IMDbAPI.c_str(), -1, /*connecttimeout*/2, /*timeout*/5)) { initMap(m); @@ -306,13 +311,17 @@ int CIMDB::getIMDb(const std::string& epgTitle) // std::cout << it->first << " => " << it->second << '\n'; //download Poster - if(httpTool.downloadFile(m["Poster"], posterfile.c_str())) - ret = 2; - else { - ret = 1; - if (access(posterfile.c_str(), F_OK) == 0) - unlink(posterfile.c_str()); + if(m["Poster"] != "N/A") + { + if(httpTool.downloadFile(m["Poster"], posterfile.c_str())) + return 2; + else { + return 1; + if (access(posterfile.c_str(), F_OK) == 0) + unlink(posterfile.c_str()); + } } + ret=2; } return ret; @@ -328,6 +337,9 @@ void CIMDB::getIMDbData(std::string& txt) txt += "Regisseur: "+m["Director"]+"\n"; txt += "Drehbuch: "+m["Writer"]+"\n\n"; txt += "Darsteller: "+m["Actors"]+"\n"; + + if(m["imdbID"].empty() || m["Response"]!="True") + txt = "Keine Daten gefunden"; } std::string CIMDB::getFilename(CZapitChannel * channel, uint64_t id)