tmdb: Use osd language for search & display data

This commit is contained in:
M. Liebmann
2016-03-04 13:57:31 +01:00
parent 53ef02ad2f
commit 11cdccac52
2 changed files with 8 additions and 5 deletions

View File

@@ -73,7 +73,10 @@ cTmdb::cTmdb(std::string epgtitle)
key = g_settings.tmdb_api_key; key = g_settings.tmdb_api_key;
#endif #endif
GetMovieDetails(); std::string lang = Lang2ISO639_1(g_settings.language);
GetMovieDetails(lang);
if ((minfo.result < 1 || minfo.overview.empty()) && lang != "en")
GetMovieDetails("en");
} }
cTmdb::~cTmdb() cTmdb::~cTmdb()
@@ -192,10 +195,10 @@ bool cTmdb::DownloadUrl(std::string url, std::string file, CURL *_curl_handle)
return true; return true;
} }
bool cTmdb::GetMovieDetails() bool cTmdb::GetMovieDetails(std::string lang)
{ {
printf("[TMDB]: %s\n",__func__); printf("[TMDB]: %s\n",__func__);
std::string url = "http://api.themoviedb.org/3/search/multi?api_key="+key+"&language=de&query=" + encodeUrl(minfo.epgtitle); std::string url = "http://api.themoviedb.org/3/search/multi?api_key="+key+"&language="+lang+"&query=" + encodeUrl(minfo.epgtitle);
std::string answer; std::string answer;
if (!getUrl(url, answer)) if (!getUrl(url, answer))
return false; return false;
@@ -218,7 +221,7 @@ bool cTmdb::GetMovieDetails()
minfo.id = elements[0].get("id",-1).asInt(); minfo.id = elements[0].get("id",-1).asInt();
minfo.media_type = elements[0].get("media_type","").asString(); minfo.media_type = elements[0].get("media_type","").asString();
if (minfo.id > -1) { if (minfo.id > -1) {
url = "http://api.themoviedb.org/3/"+minfo.media_type+"/"+to_string(minfo.id)+"?api_key="+key+"&language=de&append_to_response=credits"; url = "http://api.themoviedb.org/3/"+minfo.media_type+"/"+to_string(minfo.id)+"?api_key="+key+"&language="+lang+"&append_to_response=credits";
answer.clear(); answer.clear();
if (!getUrl(url, answer)) if (!getUrl(url, answer))
return false; return false;

View File

@@ -61,7 +61,7 @@ class cTmdb
std::string key; // tmdb api key std::string key; // tmdb api key
bool getUrl(std::string &url, std::string &answer, CURL *_curl_handle = NULL); bool getUrl(std::string &url, std::string &answer, CURL *_curl_handle = NULL);
bool DownloadUrl(std::string url, std::string file, CURL *_curl_handle = NULL); bool DownloadUrl(std::string url, std::string file, CURL *_curl_handle = NULL);
bool GetMovieDetails(); bool GetMovieDetails(std::string lang);
public: public:
cTmdb(std::string epgtitle); cTmdb(std::string epgtitle);