mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 07:51:11 +02:00
imdb/tmdb: more unifications; poster handling
Origin commit data
------------------
Branch: ni/coolstream
Commit: b9aea3ae5d
Author: vanhofen <vanhofen@gmx.de>
Date: 2021-04-08 (Thu, 08 Apr 2021)
Origin message was:
------------------
- imdb/tmdb: more unifications; poster handling
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -254,9 +254,9 @@ void CEpgData::showText(int startPos, int ypos, bool has_cover, bool fullClear)
|
||||
if (has_cover)
|
||||
{
|
||||
if (imdb_active)
|
||||
cover = imdb->posterfile;
|
||||
cover = imdb->getPoster();
|
||||
else if (tmdb_active)
|
||||
cover = tmdb->getCover();
|
||||
cover = tmdb->getPoster();
|
||||
|
||||
g_PicViewer->getSize(cover.c_str(), &cover_width, &cover_height);
|
||||
if (cover_width && cover_height)
|
||||
@@ -1037,7 +1037,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start
|
||||
if (showPos+scrollCount<textCount)
|
||||
{
|
||||
showPos += scrollCount;
|
||||
showText(showPos, sy + toph, tmdb_active || (imdb_active && imdb->gotPoster()), false);
|
||||
showText(showPos, sy + toph, (tmdb_active && tmdb->hasPoster()) || (imdb_active && imdb->hasPoster()), false);
|
||||
}
|
||||
break;
|
||||
case CRCInput::RC_up:
|
||||
@@ -1045,7 +1045,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start
|
||||
showPos -= scrollCount;
|
||||
if (showPos < 0)
|
||||
showPos = 0;
|
||||
showText(showPos, sy + toph, tmdb_active || (imdb_active && imdb->gotPoster()), false);
|
||||
showText(showPos, sy + toph, (tmdb_active && tmdb->hasPoster()) || (imdb_active && imdb->hasPoster()), false);
|
||||
}
|
||||
break;
|
||||
case CRCInput::RC_page_up:
|
||||
@@ -1199,10 +1199,10 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start
|
||||
epgText.clear();
|
||||
tmdb_active = true;
|
||||
epgTextSwitch = tmdb->CreateMovieText();
|
||||
processTextToArray(tmdb->CreateEPGText(), 0, tmdb->hasCover());
|
||||
processTextToArray(tmdb->CreateEPGText(), 0, tmdb->hasPoster());
|
||||
textCount = epgText.size();
|
||||
tmdb_stars = tmdb->getStars();
|
||||
showText(showPos, sy + toph, tmdb_active);
|
||||
showText(showPos, sy + toph, tmdb->hasPoster());
|
||||
} else {
|
||||
ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_EPGVIEWER_NODETAILED, CMsgBox::mbrOk , CMsgBox::mbrOk);
|
||||
}
|
||||
@@ -1234,7 +1234,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start
|
||||
showTimerEventBar(true, !mp_info && isCurrentEPG(channel_id), mp_info); //show buttons
|
||||
timeoutEnd = CRCInput::calcTimeoutEnd(timeout);
|
||||
}
|
||||
else if (imdb_active && imdb->gotPoster())
|
||||
else if (imdb_active && imdb->hasPoster())
|
||||
{
|
||||
imdb_active = false;
|
||||
CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, LOCALE_IMDB_INFO_SAVE);
|
||||
@@ -1628,7 +1628,7 @@ void CEpgData::showTimerEventBar (bool pshow, bool adzap, bool mp_info)
|
||||
|
||||
if (imdb_active)
|
||||
{
|
||||
EpgButtons[UsedButtons][1].button = (imdb->gotPoster()) ? NEUTRINO_ICON_BUTTON_GREEN : NEUTRINO_ICON_BUTTON_DUMMY_SMALL;
|
||||
EpgButtons[UsedButtons][1].button = (imdb->hasPoster()) ? NEUTRINO_ICON_BUTTON_GREEN : NEUTRINO_ICON_BUTTON_DUMMY_SMALL;
|
||||
EpgButtons[UsedButtons][1].locale = LOCALE_IMDB_INFO_SAVE;
|
||||
}
|
||||
else
|
||||
@@ -1692,7 +1692,7 @@ int CEpgData::showIMDb(bool splash)
|
||||
|
||||
//data
|
||||
epgTextSwitch = imdb->CreateMovieText();
|
||||
processTextToArray(imdb->CreateEPGText(), 0, imdb->gotPoster());
|
||||
processTextToArray(imdb->CreateEPGText(), 0, imdb->hasPoster());
|
||||
|
||||
textCount = epgText.size();
|
||||
|
||||
@@ -1713,7 +1713,7 @@ int CEpgData::showIMDb(bool splash)
|
||||
value.replace(pos, 1, ""); // change 8,1 or 8.1 to 81
|
||||
imdb_stars = atoi(value);
|
||||
|
||||
showText(0, sy + toph, imdb->gotPoster());
|
||||
showText(0, sy + toph, imdb->hasPoster());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -509,8 +509,3 @@ void CIMDB::cleanup()
|
||||
if (access(posterfile.c_str(), F_OK) == 0)
|
||||
unlink(posterfile.c_str());
|
||||
}
|
||||
|
||||
bool CIMDB::gotPoster()
|
||||
{
|
||||
return (access(posterfile.c_str(), F_OK) == 0);
|
||||
}
|
||||
|
@@ -24,10 +24,24 @@
|
||||
#ifndef __imdb__
|
||||
#define __imdb__
|
||||
|
||||
#include <system/helpers.h>
|
||||
#include <zapit/zapit.h>
|
||||
|
||||
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);
|
||||
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<std::string, std::string> m;
|
||||
|
||||
void initMap(std::map<std::string, std::string>& my);
|
||||
|
||||
public:
|
||||
CIMDB();
|
||||
~CIMDB();
|
||||
@@ -47,26 +61,12 @@ class CIMDB
|
||||
std::string CreateEPGText();
|
||||
std::string CreateMovieText();
|
||||
|
||||
bool gotPoster();
|
||||
std::string getPoster() { return posterfile;}
|
||||
bool hasPoster() { return (access(posterfile.c_str(), F_OK) == 0); }
|
||||
|
||||
bool checkIMDbElement(std::string element);
|
||||
//FIXME: what if m[element] doesn't exist?
|
||||
std::string getIMDbElement(std::string element) { return m[element]; };
|
||||
|
||||
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);
|
||||
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<std::string, std::string> m;
|
||||
|
||||
std::string getApiKey();
|
||||
|
||||
void initMap(std::map<std::string, std::string>& my);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -53,6 +53,7 @@ CTMDB* CTMDB::getInstance()
|
||||
CTMDB::CTMDB()
|
||||
{
|
||||
key = g_settings.tmdb_api_key;
|
||||
posterfile = "/tmp/tmdb.jpg";
|
||||
hintbox = NULL;
|
||||
}
|
||||
|
||||
@@ -170,9 +171,9 @@ bool CTMDB::GetMovieDetails(std::string lang, bool second)
|
||||
//printf("test: %s (%s)\n",elements[i].get("character","").asString().c_str(),elements[i].get("name","").asString().c_str());
|
||||
}
|
||||
|
||||
unlink(TMDB_COVER);
|
||||
if (hasCover())
|
||||
getBigCover(TMDB_COVER);
|
||||
unlink(posterfile.c_str());
|
||||
if (hasPoster())
|
||||
getBigPoster(posterfile.c_str());
|
||||
//printf("[TMDB]: %s (%s) %s\n %s\n %d\n",minfo.epgtitle.c_str(),minfo.original_title.c_str(),minfo.release_date.c_str(),minfo.overview.c_str(),minfo.found);
|
||||
|
||||
return true;
|
||||
@@ -226,8 +227,8 @@ std::string CTMDB::CreateMovieText()
|
||||
|
||||
void CTMDB::cleanup()
|
||||
{
|
||||
if (access(TMDB_COVER, F_OK) == 0)
|
||||
unlink(TMDB_COVER);
|
||||
if (access(posterfile.c_str(), F_OK) == 0)
|
||||
unlink(posterfile.c_str());
|
||||
}
|
||||
|
||||
void CTMDB::selectResult(Json::Value elements, int results, int &use_result)
|
||||
|
@@ -27,8 +27,6 @@
|
||||
#include <system/helpers-json.h>
|
||||
#include <gui/widget/hintbox.h>
|
||||
|
||||
#define TMDB_COVER "/tmp/tmdb.jpg"
|
||||
|
||||
typedef struct {
|
||||
std::string epgtitle;
|
||||
std::string poster_path;
|
||||
@@ -57,6 +55,7 @@ class CTMDB
|
||||
bool GetMovieDetails(std::string lang, bool second = false);
|
||||
bool GetData(std::string url, Json::Value *root);
|
||||
void selectResult(Json::Value elements, int results, int &used_result);
|
||||
std::string posterfile;
|
||||
|
||||
public:
|
||||
CTMDB();
|
||||
@@ -72,10 +71,10 @@ class CTMDB
|
||||
std::string getDescription() { return minfo.overview;}
|
||||
std::string getVote() { return minfo.vote_average;}
|
||||
std::string getCast() { return minfo.cast;}
|
||||
std::string getCover() { return TMDB_COVER;}
|
||||
bool hasCover() { return !minfo.poster_path.empty();}
|
||||
bool getBigCover(std::string cover) { return downloadUrl("http://image.tmdb.org/t/p/w342" + minfo.poster_path, cover);}
|
||||
bool getSmallCover(std::string cover) { return downloadUrl("http://image.tmdb.org/t/p/w185" + minfo.poster_path, cover);}
|
||||
std::string getPoster() { return posterfile;}
|
||||
bool hasPoster() { return !minfo.poster_path.empty();}
|
||||
bool getBigPoster(std::string poster) { return downloadUrl("http://image.tmdb.org/t/p/w342" + minfo.poster_path, poster);}
|
||||
bool getSmallPoster(std::string poster) { return downloadUrl("http://image.tmdb.org/t/p/w185" + minfo.poster_path, poster);}
|
||||
int getResults() { return minfo.result;}
|
||||
int getStars() { return (int) (atof(minfo.vote_average.c_str())*10);}
|
||||
void cleanup();
|
||||
|
@@ -2175,10 +2175,10 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg)
|
||||
if (tmdb)
|
||||
{
|
||||
tmdb->setTitle(m_movieSelectionHandler->epgTitle);
|
||||
if ((tmdb->getResults() > 0) && (tmdb->hasCover()))
|
||||
if ((tmdb->getResults() > 0) && (tmdb->hasPoster()))
|
||||
{
|
||||
if (!cover_file.empty())
|
||||
if (tmdb->getSmallCover(cover_file))
|
||||
if (tmdb->getSmallPoster(cover_file))
|
||||
refresh();
|
||||
}
|
||||
tmdb->cleanup();
|
||||
|
Reference in New Issue
Block a user