mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-07 05:38:33 +02:00
- imdb/tmdb: more unifications; function names
Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -1200,7 +1200,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start
|
|||||||
//show IMDb info
|
//show IMDb info
|
||||||
imdb_active = true;
|
imdb_active = true;
|
||||||
showIMDb(true); //show splashscreen only
|
showIMDb(true); //show splashscreen only
|
||||||
imdb->getIMDb(epgData.title);
|
imdb->getMovieDetails(epgData.title);
|
||||||
showIMDb();
|
showIMDb();
|
||||||
showTimerEventBar(true, !mp_info && isCurrentEPG(channel_id), mp_info); //show buttons
|
showTimerEventBar(true, !mp_info && isCurrentEPG(channel_id), mp_info); //show buttons
|
||||||
timeoutEnd = CRCInput::calcTimeoutEnd(timeout);
|
timeoutEnd = CRCInput::calcTimeoutEnd(timeout);
|
||||||
|
@@ -299,7 +299,7 @@ void CIMDB::initMap( std::map<std::string, std::string>& my )
|
|||||||
//my["Type"] = root.get("Type", "").asString();
|
//my["Type"] = root.get("Type", "").asString();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CIMDB::getIMDb(const std::string& epgTitle)
|
int CIMDB::getMovieDetails(const std::string& epgTitle)
|
||||||
{
|
{
|
||||||
CHTTPTool httpTool;
|
CHTTPTool httpTool;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@@ -350,7 +350,7 @@ int CIMDB::getIMDb(const std::string& epgTitle)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CIMDB::checkIMDbElement(std::string element)
|
bool CIMDB::checkElement(std::string element)
|
||||||
{
|
{
|
||||||
if (m[element].empty() || m[element].compare("N/A") == 0)
|
if (m[element].empty() || m[element].compare("N/A") == 0)
|
||||||
return false;
|
return false;
|
||||||
@@ -366,34 +366,34 @@ std::string CIMDB::getEPGText()
|
|||||||
std::string epgtext("");
|
std::string epgtext("");
|
||||||
|
|
||||||
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_VOTES) + ": " + m["imdbVotes"] + "\n";
|
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_VOTES) + ": " + m["imdbVotes"] + "\n";
|
||||||
if (checkIMDbElement("Metascore"))
|
if (checkElement("Metascore"))
|
||||||
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_METASCORE) + ": " + m["Metascore"] + "/100\n";
|
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_METASCORE) + ": " + m["Metascore"] + "/100\n";
|
||||||
epgtext += "\n";
|
epgtext += "\n";
|
||||||
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_TITLE) + ": " + m["Title"] + "\n";
|
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_TITLE) + ": " + m["Title"] + "\n";
|
||||||
if (checkIMDbElement("Released"))
|
if (checkElement("Released"))
|
||||||
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_RELEASED) + ": " + m["Country"] + ", " + m["Released"] + "\n";
|
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_RELEASED) + ": " + m["Country"] + ", " + m["Released"] + "\n";
|
||||||
if (checkIMDbElement("Runtime"))
|
if (checkElement("Runtime"))
|
||||||
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_RUNTIME) + ": " + m["Runtime"] + "\n";
|
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_RUNTIME) + ": " + m["Runtime"] + "\n";
|
||||||
if (checkIMDbElement("Genre"))
|
if (checkElement("Genre"))
|
||||||
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_GENRE) + ": " + m["Genre"] + "\n";
|
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_GENRE) + ": " + m["Genre"] + "\n";
|
||||||
if (checkIMDbElement("Awards"))
|
if (checkElement("Awards"))
|
||||||
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_AWARDS) + ": " + m["Awards"] + "\n";
|
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_AWARDS) + ": " + m["Awards"] + "\n";
|
||||||
if (checkIMDbElement("Director"))
|
if (checkElement("Director"))
|
||||||
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_DIRECTOR) + ": " + m["Director"] + "\n";
|
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_DIRECTOR) + ": " + m["Director"] + "\n";
|
||||||
if (checkIMDbElement("Writer"))
|
if (checkElement("Writer"))
|
||||||
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_WRITER) + ": " + m["Writer"] + "\n";
|
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_WRITER) + ": " + m["Writer"] + "\n";
|
||||||
if (checkIMDbElement("Production"))
|
if (checkElement("Production"))
|
||||||
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_PRODUCTION) + ": " + m["Production"] + "\n";
|
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_PRODUCTION) + ": " + m["Production"] + "\n";
|
||||||
if (checkIMDbElement("Website"))
|
if (checkElement("Website"))
|
||||||
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_WEBSITE) + ": " + m["Website"] + "\n";
|
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_WEBSITE) + ": " + m["Website"] + "\n";
|
||||||
if (checkIMDbElement("BoxOffice"))
|
if (checkElement("BoxOffice"))
|
||||||
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_BOXOFFICE) + ": " + m["BoxOffice"] + "\n";
|
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_BOXOFFICE) + ": " + m["BoxOffice"] + "\n";
|
||||||
if (checkIMDbElement("Actors"))
|
if (checkElement("Actors"))
|
||||||
{
|
{
|
||||||
epgtext += "\n";
|
epgtext += "\n";
|
||||||
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_ACTORS) + ": " + m["Actors"] + "\n";
|
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_ACTORS) + ": " + m["Actors"] + "\n";
|
||||||
}
|
}
|
||||||
if (checkIMDbElement("Plot"))
|
if (checkElement("Plot"))
|
||||||
{
|
{
|
||||||
epgtext += "\n";
|
epgtext += "\n";
|
||||||
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_PLOT) + ": " + m["Plot"];
|
epgtext += g_Locale->getString(LOCALE_IMDB_DATA_PLOT) + ": " + m["Plot"];
|
||||||
@@ -406,24 +406,24 @@ std::string CIMDB::getMovieText()
|
|||||||
{
|
{
|
||||||
std::string movietext("");
|
std::string movietext("");
|
||||||
|
|
||||||
if (checkIMDbElement("Plot"))
|
if (checkElement("Plot"))
|
||||||
{
|
{
|
||||||
movietext = m["Plot"] + "\n";
|
movietext = m["Plot"] + "\n";
|
||||||
if (checkIMDbElement("Title"))
|
if (checkElement("Title"))
|
||||||
{
|
{
|
||||||
movietext += "\n";
|
movietext += "\n";
|
||||||
movietext += g_Locale->getString(LOCALE_IMDB_DATA_TITLE) + ": ";
|
movietext += g_Locale->getString(LOCALE_IMDB_DATA_TITLE) + ": ";
|
||||||
movietext += m["Title"];
|
movietext += m["Title"];
|
||||||
}
|
}
|
||||||
if (checkIMDbElement("Country"))
|
if (checkElement("Country"))
|
||||||
{
|
{
|
||||||
movietext += "\n";
|
movietext += "\n";
|
||||||
movietext += g_Locale->getString(LOCALE_IMDB_DATA_RELEASED) + ": ";
|
movietext += g_Locale->getString(LOCALE_IMDB_DATA_RELEASED) + ": ";
|
||||||
movietext += m["Country"];
|
movietext += m["Country"];
|
||||||
if (checkIMDbElement("Released"))
|
if (checkElement("Released"))
|
||||||
movietext += ", " + m["Released"];
|
movietext += ", " + m["Released"];
|
||||||
}
|
}
|
||||||
if (checkIMDbElement("Actors"))
|
if (checkElement("Actors"))
|
||||||
{
|
{
|
||||||
movietext += "\n";
|
movietext += "\n";
|
||||||
movietext += g_Locale->getString(LOCALE_IMDB_DATA_ACTORS) + ": ";
|
movietext += g_Locale->getString(LOCALE_IMDB_DATA_ACTORS) + ": ";
|
||||||
|
@@ -53,7 +53,7 @@ class CIMDB
|
|||||||
std::string imdb_outfile;
|
std::string imdb_outfile;
|
||||||
std::string posterfile;
|
std::string posterfile;
|
||||||
|
|
||||||
int getIMDb(const std::string& epgTitle);
|
int getMovieDetails(const std::string& epgTitle);
|
||||||
std::string getFilename(CZapitChannel * channel, uint64_t id);
|
std::string getFilename(CZapitChannel * channel, uint64_t id);
|
||||||
void StringReplace(std::string &str, const std::string search, const std::string rstr);
|
void StringReplace(std::string &str, const std::string search, const std::string rstr);
|
||||||
void cleanup();
|
void cleanup();
|
||||||
@@ -64,7 +64,7 @@ class CIMDB
|
|||||||
std::string getPoster() { return posterfile;}
|
std::string getPoster() { return posterfile;}
|
||||||
bool hasPoster() { return (access(posterfile.c_str(), F_OK) == 0); }
|
bool hasPoster() { return (access(posterfile.c_str(), F_OK) == 0); }
|
||||||
|
|
||||||
bool checkIMDbElement(std::string element);
|
bool checkElement(std::string element);
|
||||||
//FIXME: what if m[element] doesn't exist?
|
//FIXME: what if m[element] doesn't exist?
|
||||||
std::string getIMDbElement(std::string element) { return m[element]; };
|
std::string getIMDbElement(std::string element) { return m[element]; };
|
||||||
};
|
};
|
||||||
|
@@ -74,9 +74,9 @@ void CTMDB::setTitle(std::string epgtitle)
|
|||||||
hintbox->paint();
|
hintbox->paint();
|
||||||
|
|
||||||
std::string lang = Lang2ISO639_1(g_settings.language);
|
std::string lang = Lang2ISO639_1(g_settings.language);
|
||||||
GetMovieDetails(lang);
|
getMovieDetails(lang);
|
||||||
if ((minfo.result < 1 || minfo.overview.empty()) && lang != "en")
|
if ((minfo.result < 1 || minfo.overview.empty()) && lang != "en")
|
||||||
GetMovieDetails("en", true);
|
getMovieDetails("en", true);
|
||||||
|
|
||||||
if(hintbox){
|
if(hintbox){
|
||||||
hintbox->hide();
|
hintbox->hide();
|
||||||
@@ -85,7 +85,7 @@ void CTMDB::setTitle(std::string epgtitle)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CTMDB::GetData(std::string url, Json::Value *root)
|
bool CTMDB::getData(std::string url, Json::Value *root)
|
||||||
{
|
{
|
||||||
std::string answer;
|
std::string answer;
|
||||||
if (!getUrl(url, answer))
|
if (!getUrl(url, answer))
|
||||||
@@ -101,13 +101,13 @@ bool CTMDB::GetData(std::string url, Json::Value *root)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CTMDB::GetMovieDetails(std::string lang, bool second)
|
bool CTMDB::getMovieDetails(std::string lang, bool second)
|
||||||
{
|
{
|
||||||
printf("[TMDB]: %s\n",__func__);
|
printf("[TMDB]: %s\n",__func__);
|
||||||
Json::Value root;
|
Json::Value root;
|
||||||
const std::string urlapi = "http://api.themoviedb.org/3/";
|
const std::string urlapi = "http://api.themoviedb.org/3/";
|
||||||
std::string url = urlapi + "search/multi?api_key="+key+"&language="+lang+"&query=" + encodeUrl(minfo.epgtitle);
|
std::string url = urlapi + "search/multi?api_key="+key+"&language="+lang+"&query=" + encodeUrl(minfo.epgtitle);
|
||||||
if(!(GetData(url, &root)))
|
if(!(getData(url, &root)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
minfo.result = root.get("total_results",0).asInt();
|
minfo.result = root.get("total_results",0).asInt();
|
||||||
@@ -119,7 +119,7 @@ bool CTMDB::GetMovieDetails(std::string lang, bool second)
|
|||||||
printf("[TMDB]: second try\n");
|
printf("[TMDB]: second try\n");
|
||||||
title.replace(pos1, pos2-pos1+1, "");
|
title.replace(pos1, pos2-pos1+1, "");
|
||||||
url = urlapi + "search/multi?api_key="+key+"&language="+lang+"&query=" + encodeUrl(title);
|
url = urlapi + "search/multi?api_key="+key+"&language="+lang+"&query=" + encodeUrl(title);
|
||||||
if(!(GetData(url, &root)))
|
if(!(getData(url, &root)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
minfo.result = root.get("total_results",0).asInt();
|
minfo.result = root.get("total_results",0).asInt();
|
||||||
@@ -140,7 +140,7 @@ bool CTMDB::GetMovieDetails(std::string lang, bool second)
|
|||||||
}
|
}
|
||||||
if (minfo.id > -1) {
|
if (minfo.id > -1) {
|
||||||
url = urlapi+minfo.media_type+"/"+to_string(minfo.id)+"?api_key="+key+"&language="+lang+"&append_to_response=credits";
|
url = urlapi+minfo.media_type+"/"+to_string(minfo.id)+"?api_key="+key+"&language="+lang+"&append_to_response=credits";
|
||||||
if(!(GetData(url, &root)))
|
if(!(getData(url, &root)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
minfo.overview = root.get("overview","").asString();
|
minfo.overview = root.get("overview","").asString();
|
||||||
|
@@ -50,8 +50,8 @@ class CTMDB
|
|||||||
tmdbinfo minfo;
|
tmdbinfo minfo;
|
||||||
CHintBox* hintbox;
|
CHintBox* hintbox;
|
||||||
std::string key; // tmdb api key
|
std::string key; // tmdb api key
|
||||||
bool GetMovieDetails(std::string lang, bool second = false);
|
bool getMovieDetails(std::string lang, bool second = false);
|
||||||
bool GetData(std::string url, Json::Value *root);
|
bool getData(std::string url, Json::Value *root);
|
||||||
void selectResult(Json::Value elements, int results, int &used_result);
|
void selectResult(Json::Value elements, int results, int &used_result);
|
||||||
std::string posterfile;
|
std::string posterfile;
|
||||||
|
|
||||||
|
@@ -813,7 +813,7 @@ int CMovieBrowser::exec(CMenuTarget* parent, const std::string & actionKey)
|
|||||||
|
|
||||||
std::string title = m_movieSelectionHandler->epgTitle;
|
std::string title = m_movieSelectionHandler->epgTitle;
|
||||||
CIMDB *imdb = CIMDB::getInstance();
|
CIMDB *imdb = CIMDB::getInstance();
|
||||||
imdb->getIMDb(title);
|
imdb->getMovieDetails(title);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
element = imdb->getIMDbElement("Title");
|
element = imdb->getIMDbElement("Title");
|
||||||
|
Reference in New Issue
Block a user