From b52f03307655b7448b0ebbc8f5efd25fe5113e5f Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 13 May 2018 21:33:53 +0200 Subject: [PATCH] imdb: Fix an issue on changing of imdb key during runtime. Global instance allows to set the api key from settings on first created instance of the imdb object only, so changes on settings had no effect during runtime and restart of neutrinon was required to apply ne keys. This should fix this. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/d76ce988452c0c393755c620f33c0bf09ef4d4f3 Author: Thilo Graf Date: 2018-05-13 (Sun, 13 May 2018) --- src/gui/imdb.cpp | 11 ++++++++--- src/gui/imdb.h | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/gui/imdb.cpp b/src/gui/imdb.cpp index 67ee8a490..79e9c6a37 100644 --- a/src/gui/imdb.cpp +++ b/src/gui/imdb.cpp @@ -47,8 +47,6 @@ CIMDB::CIMDB() 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="; - omdb_apikey += g_settings.omdb_api_key; posterfile = "/tmp/imdb.jpg"; acc = 0; @@ -67,6 +65,13 @@ CIMDB* CIMDB::getInstance() return imdb; } +inline std::string CIMDB::getApiKey() +{ + std::string ret = "&apikey="; + ret += g_settings.omdb_api_key; + return ret; +} + std::string CIMDB::utf82url(std::string s) { std::stringstream ss; @@ -310,7 +315,7 @@ int CIMDB::getIMDb(const std::string& epgTitle) if(((imdb_id.find(search_error)) != std::string::npos)) return ret; - std::string url = imdb_url + imdb_id + omdb_apikey; + std::string url = imdb_url + imdb_id + getApiKey(); if (httpTool.downloadFile(url, imdb_outfile.c_str())) { diff --git a/src/gui/imdb.h b/src/gui/imdb.h index 29825c0f4..4c4df3d21 100644 --- a/src/gui/imdb.h +++ b/src/gui/imdb.h @@ -57,13 +57,15 @@ class CIMDB private: int acc; 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); std::map m; + std::string getApiKey(); + void initMap(std::map& my); };