- imdb/tmdb: more unifications; part 2

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
svenhoefer
2021-04-08 17:31:07 +02:00
committed by Thilo Graf
parent f6299d4f81
commit 6b02d097b2
4 changed files with 27 additions and 36 deletions

View File

@@ -28,35 +28,18 @@
#include <fstream>
#include <iostream>
#include <unistd.h>
#include <global.h>
#include <driver/screen_max.h>
#include <system/httptool.h>
#include <system/helpers.h>
#include <system/helpers-json.h>
#include <eitd/sectionsd.h>
#include <unistd.h>
#include <json/json.h>
#include "mdb-imdb.h"
CIMDB::CIMDB()
{
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";
posterfile = "/tmp/imdb.jpg";
acc = 0;
}
CIMDB::~CIMDB()
{
cleanup();
}
CIMDB* CIMDB::getInstance()
{
static CIMDB* imdb = NULL;
@@ -65,11 +48,22 @@ CIMDB* CIMDB::getInstance()
return imdb;
}
inline std::string CIMDB::getApiKey()
CIMDB::CIMDB()
{
std::string ret = "&apikey=";
ret += g_settings.omdb_api_key;
return ret;
key = g_settings.omdb_api_key;
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&apikey=" + key + "&i=";
imdb_outfile = "/tmp/imdb.json";
posterfile = "/tmp/imdb.jpg";
acc = 0;
}
CIMDB::~CIMDB()
{
cleanup();
}
std::string CIMDB::utf82url(std::string s)
@@ -315,7 +309,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 + getApiKey();
std::string url = imdb_url + imdb_id;
if (httpTool.downloadFile(url, imdb_outfile.c_str()))
{

View File

@@ -56,6 +56,7 @@ class CIMDB
private:
int acc;
std::string imdb_url;
std::string key; // omdb api key
std::string googleIMDb(std::string s);
std::string utf82url(std::string s);

View File

@@ -24,26 +24,22 @@
#include <config.h>
#endif
#include <fstream>
#include <set>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <fstream>
#include <set>
#include <string>
#include <neutrino.h>
#include "system/settings.h"
#include "system/set_threadname.h"
#include <system/settings.h>
#include <system/set_threadname.h>
#include <driver/screen_max.h>
#include <global.h>
#include "mdb-tmdb.h"
CTMDB* CTMDB::getInstance()

View File

@@ -21,9 +21,9 @@
#define __TMDB__
#include <string>
#include "system/helpers.h"
#include <system/helpers.h>
#include <system/helpers-json.h>
#include "gui/widget/hintbox.h"
#include <gui/widget/hintbox.h>
#define TMDB_COVER "/tmp/tmdb.jpg"