diff --git a/src/gui/tmdb.cpp b/src/gui/tmdb.cpp index 2dc19a45d..0f7096e67 100644 --- a/src/gui/tmdb.cpp +++ b/src/gui/tmdb.cpp @@ -49,10 +49,6 @@ #endif #define URL_TIMEOUT 60 -#define API_KEY_1 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -#define API_KEY_2 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -#define API_KEY_3 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -#define API_KEY_4 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" #define TMDB_COVER "/tmp/tmdb.jpg" cTmdb::cTmdb(std::string epgtitle) @@ -71,6 +67,11 @@ cTmdb::cTmdb(std::string epgtitle) sx = getScreenStartX(ox); sy = getScreenStartY(oy + buttonheight); /* button box is handled separately (why?) */ +#ifdef TMDB_API_KEY + key = TMDB_API_KEY; +#else + key = g_settings.tmdb_api_key; +#endif GetMovieDetails(); } @@ -190,18 +191,11 @@ bool cTmdb::DownloadUrl(std::string url, std::string file, CURL *_curl_handle) } return true; } -std::string cTmdb::random_API_KEY() -{ - std::string keys[] = {API_KEY_1,API_KEY_2,API_KEY_3,API_KEY_4}; - int i = rand() % (sizeof(keys) / sizeof(keys[0])); - return keys[i]; -} - bool cTmdb::GetMovieDetails() { printf("[TMDB]: %s\n",__func__); - std::string url = "http://api.themoviedb.org/3/search/multi?api_key="+random_API_KEY()+"&language=de&query=" + encodeUrl(minfo.epgtitle); + std::string url = "http://api.themoviedb.org/3/search/multi?api_key="+key+"&language=de&query=" + encodeUrl(minfo.epgtitle); std::string answer; if (!getUrl(url, answer)) return false; @@ -224,7 +218,7 @@ bool cTmdb::GetMovieDetails() minfo.id = elements[0].get("id",-1).asInt(); minfo.media_type = elements[0].get("media_type","").asString(); if (minfo.id > -1) { - url = "http://api.themoviedb.org/3/"+minfo.media_type+"/"+to_string(minfo.id)+"?api_key="+random_API_KEY()+"&language=de&append_to_response=credits"; + url = "http://api.themoviedb.org/3/"+minfo.media_type+"/"+to_string(minfo.id)+"?api_key="+key+"&language=de&append_to_response=credits"; answer.clear(); if (!getUrl(url, answer)) return false; diff --git a/src/gui/tmdb.h b/src/gui/tmdb.h index 2e5e82a03..fc7d84198 100644 --- a/src/gui/tmdb.h +++ b/src/gui/tmdb.h @@ -58,7 +58,7 @@ class cTmdb static size_t CurlWriteToString(void *ptr, size_t size, size_t nmemb, void *data); std::string encodeUrl(std::string txt); std::string decodeUrl(std::string url); - std::string random_API_KEY(); + std::string key; // tmdb api key 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 GetMovieDetails(); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 9c9a54919..451f340e2 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -802,6 +802,7 @@ int CNeutrinoApp::loadSetup(const char * fname) //Movie-Player g_settings.movieplayer_repeat_on = configfile.getInt32("movieplayer_repeat_on", CMoviePlayerGui::REPEAT_OFF); g_settings.youtube_dev_id = configfile.getString("youtube_dev_id","XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); + g_settings.tmdb_api_key = configfile.getString("tmdb_api_key","XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); //Filebrowser g_settings.filebrowser_showrights = configfile.getInt32("filebrowser_showrights", 1); @@ -1303,6 +1304,7 @@ void CNeutrinoApp::saveSetup(const char * fname) //Movie-Player configfile.setInt32( "movieplayer_repeat_on", g_settings.movieplayer_repeat_on ); configfile.setString( "youtube_dev_id", g_settings.youtube_dev_id ); + configfile.setString( "tmdb_api_key", g_settings.tmdb_api_key ); //Filebrowser configfile.setInt32("filebrowser_showrights", g_settings.filebrowser_showrights); diff --git a/src/system/settings.h b/src/system/settings.h index a6cc0b6c8..f31688213 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -720,6 +720,7 @@ struct SNeutrinoSettings //movieplayer int movieplayer_repeat_on; std::string youtube_dev_id; + std::string tmdb_api_key; //zapit setup std::string StartChannelTV;