mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-26 15:02:50 +02:00
imdb: cosmetics
Origin commit data
------------------
Commit: 4ef7333bf9
Author: vanhofen <vanhofen@gmx.de>
Date: 2017-05-29 (Mon, 29 May 2017)
Origin message was:
------------------
- imdb: cosmetics
This commit is contained in:
@@ -1645,7 +1645,7 @@ int CEpgData::showIMDb(bool splash)
|
||||
//titel
|
||||
std::string title = imdb->getIMDbElement("Title");
|
||||
|
||||
if(((title.find("IMDb: Google Download fehlgeschlagen")) != std::string::npos))
|
||||
if(((title.find(imdb->search_error)) != std::string::npos))
|
||||
return 1;
|
||||
|
||||
// clear epg array
|
||||
|
@@ -42,11 +42,12 @@
|
||||
|
||||
CIMDB::CIMDB()
|
||||
{
|
||||
surl = "http://www.google.de/search?q=";
|
||||
soutfile = "/tmp/google.out";
|
||||
IMDburl = "http://www.omdbapi.com/?plot=full&r=json&i=";
|
||||
IMDbAPI = "/tmp/imdb.json";
|
||||
omdbapiKey = "&apikey=20711f9e";
|
||||
search_url = "http://www.google.de/search?q=";
|
||||
search_outfile = "/tmp/google.out";
|
||||
search_error = "IMDb: Google download failed";
|
||||
imdb_url = "http://www.omdbapi.com/?plot=full&r=json&i=";
|
||||
imdb_outfile = "/tmp/imdb.json";
|
||||
omdb_apikey = "&apikey=20711f9e";
|
||||
posterfile = "/tmp/imdb.jpg";
|
||||
stars_bg = ICONSDIR "/stars_bg.png";
|
||||
stars = ICONSDIR "/stars.png";
|
||||
@@ -203,38 +204,39 @@ std::string CIMDB::parseFile(std::string search1, std::string search2, const cha
|
||||
return(ret);
|
||||
}
|
||||
|
||||
std::string CIMDB::googleIMDb(std::string searchStr)
|
||||
std::string CIMDB::googleIMDb(std::string s)
|
||||
{
|
||||
CHTTPTool httpTool;
|
||||
std::string ret = "IMDb: Google Download fehlgeschlagen";
|
||||
std::string httpString = "imdb+";
|
||||
char* searchStr_ = (char*) searchStr.c_str();
|
||||
std::string ret = search_error;
|
||||
std::string search_string("");
|
||||
char* search_char = (char*) s.c_str();
|
||||
|
||||
m.clear();
|
||||
unlink(soutfile.c_str());
|
||||
unlink(IMDbAPI.c_str());
|
||||
unlink(search_outfile.c_str());
|
||||
unlink(imdb_outfile.c_str());
|
||||
unlink(posterfile.c_str());
|
||||
|
||||
while (*searchStr_!=0)
|
||||
while (*search_char != 0)
|
||||
{
|
||||
if ( (*searchStr_==' ') )
|
||||
if (*search_char == ' ')
|
||||
{
|
||||
httpString += '+';
|
||||
} else
|
||||
{
|
||||
httpString += *searchStr_;
|
||||
search_string += '+';
|
||||
}
|
||||
searchStr_++;
|
||||
else
|
||||
{
|
||||
search_string += *search_char;
|
||||
}
|
||||
search_char++;
|
||||
}
|
||||
|
||||
std::string url = surl + utf82url(httpString) + "%20site:www.imdb.com";
|
||||
std::string url = search_url + utf82url(search_string) + "%20site:www.imdb.com";
|
||||
|
||||
if (httpTool.downloadFile(url, soutfile.c_str()))
|
||||
if (httpTool.downloadFile(url, search_outfile.c_str()))
|
||||
{
|
||||
ret = parseFile("http://www.imdb.com/title/", ">", soutfile.c_str());
|
||||
ret = parseFile("http://www.imdb.com/title/", ">", search_outfile.c_str());
|
||||
|
||||
if(ret.empty())
|
||||
ret = parseFile("http://www.imdb.de/title/", ">", soutfile.c_str());
|
||||
ret = parseFile("http://www.imdb.de/title/", ">", search_outfile.c_str());
|
||||
|
||||
std::string delimiters = "/&;";
|
||||
size_t next = ret.find_first_of(delimiters, 0);
|
||||
@@ -250,7 +252,7 @@ void CIMDB::initMap( std::map<std::string, std::string>& my )
|
||||
Json::Reader reader;
|
||||
|
||||
std::ostringstream ss;
|
||||
std::ifstream fh(IMDbAPI.c_str(),std::ifstream::in);
|
||||
std::ifstream fh(imdb_outfile.c_str(),std::ifstream::in);
|
||||
ss << fh.rdbuf();
|
||||
std::string filedata = ss.str();
|
||||
|
||||
@@ -301,14 +303,14 @@ int CIMDB::getIMDb(const std::string& epgTitle)
|
||||
CHTTPTool httpTool;
|
||||
int ret = 0;
|
||||
|
||||
std::string imdb_ID = googleIMDb(epgTitle);
|
||||
std::string imdb_id = googleIMDb(epgTitle);
|
||||
|
||||
if(((imdb_ID.find("IMDb: ")) != std::string::npos))
|
||||
if(((imdb_id.find(search_error)) != std::string::npos))
|
||||
return ret;
|
||||
|
||||
std::string url = IMDburl + imdb_ID + omdbapiKey;
|
||||
std::string url = imdb_url + imdb_id + omdb_apikey;
|
||||
|
||||
if (httpTool.downloadFile(url, IMDbAPI.c_str()))
|
||||
if (httpTool.downloadFile(url, imdb_outfile.c_str()))
|
||||
{
|
||||
initMap(m);
|
||||
|
||||
@@ -457,8 +459,8 @@ void CIMDB::StringReplace(std::string &str, const std::string search, const std:
|
||||
|
||||
void CIMDB::cleanup()
|
||||
{
|
||||
if (access(soutfile.c_str(), F_OK) == 0)
|
||||
unlink(soutfile.c_str());
|
||||
if (access(search_outfile.c_str(), F_OK) == 0)
|
||||
unlink(search_outfile.c_str());
|
||||
if (access(posterfile.c_str(), F_OK) == 0)
|
||||
unlink(posterfile.c_str());
|
||||
}
|
||||
|
@@ -37,13 +37,15 @@ class CIMDB
|
||||
~CIMDB();
|
||||
static CIMDB* getInstance();
|
||||
|
||||
std::string surl;
|
||||
std::string soutfile;
|
||||
std::string IMDbAPI;
|
||||
std::string search_url;
|
||||
std::string search_outfile;
|
||||
std::string search_error;
|
||||
std::string imdb_outfile;
|
||||
std::string posterfile;
|
||||
std::string stars_bg;
|
||||
std::string stars;
|
||||
|
||||
|
||||
int getIMDb(const std::string& epgTitle);
|
||||
std::string getFilename(CZapitChannel * channel, uint64_t id);
|
||||
void StringReplace(std::string &str, const std::string search, const std::string rstr);
|
||||
@@ -59,9 +61,9 @@ class CIMDB
|
||||
|
||||
private:
|
||||
int acc;
|
||||
std::string IMDburl;
|
||||
std::string omdbapiKey;
|
||||
std::string googleIMDb(std::string searchStr);
|
||||
std::string imdb_url;
|
||||
std::string omdb_apikey;
|
||||
std::string googleIMDb(std::string s);
|
||||
std::string utf82url(std::string s);
|
||||
std::string parseString(std::string search1, std::string search2, std::string str);
|
||||
std::string parseFile(std::string search1, std::string search2, const char* file, std::string firstline="", int line_offset=0);
|
||||
|
Reference in New Issue
Block a user