mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-04 20:28:35 +02:00
- imdb/tmdb: more unifications; poster handling
Conflicts: src/gui/epgview.cpp src/gui/mdb-tmdb.cpp Signed-off-by: Thilo Graf <dbt@novatux.de>
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 (has_cover)
|
||||||
{
|
{
|
||||||
if (imdb_active)
|
if (imdb_active)
|
||||||
cover = imdb->posterfile;
|
cover = imdb->getPoster();
|
||||||
else if (tmdb_active)
|
else if (tmdb_active)
|
||||||
cover = tmdb->getCover();
|
cover = tmdb->getPoster();
|
||||||
|
|
||||||
g_PicViewer->getSize(cover.c_str(), &cover_width, &cover_height);
|
g_PicViewer->getSize(cover.c_str(), &cover_width, &cover_height);
|
||||||
if (cover_width && cover_height)
|
if (cover_width && cover_height)
|
||||||
@@ -1008,7 +1008,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start
|
|||||||
if (showPos+scrollCount<textCount)
|
if (showPos+scrollCount<textCount)
|
||||||
{
|
{
|
||||||
showPos += scrollCount;
|
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;
|
break;
|
||||||
case CRCInput::RC_up:
|
case CRCInput::RC_up:
|
||||||
@@ -1016,7 +1016,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start
|
|||||||
showPos -= scrollCount;
|
showPos -= scrollCount;
|
||||||
if (showPos < 0)
|
if (showPos < 0)
|
||||||
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;
|
break;
|
||||||
case CRCInput::RC_page_up:
|
case CRCInput::RC_page_up:
|
||||||
@@ -1168,12 +1168,12 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start
|
|||||||
if ((tmdb->getResults() > 0) && (!tmdb->getDescription().empty())) {
|
if ((tmdb->getResults() > 0) && (!tmdb->getDescription().empty())) {
|
||||||
epgText_saved = epgText;
|
epgText_saved = epgText;
|
||||||
epgText.clear();
|
epgText.clear();
|
||||||
tmdb_active = !tmdb_active;
|
tmdb_active = true;
|
||||||
epgTextSwitch = tmdb->getMovieText();
|
epgTextSwitch = tmdb->getMovieText();
|
||||||
processTextToArray(tmdb->getEPGText(), 0, tmdb->hasCover());
|
processTextToArray(tmdb->getEPGText(), 0, tmdb->hasPoster());
|
||||||
textCount = epgText.size();
|
textCount = epgText.size();
|
||||||
stars = tmdb->getStars();
|
stars = tmdb->getStars();
|
||||||
showText(showPos, sy + toph, tmdb_active || (imdb_active && imdb->gotPoster()));
|
showText(showPos, sy + toph, tmdb->hasPoster());
|
||||||
} else {
|
} else {
|
||||||
ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_EPGVIEWER_NODETAILED, CMsgBox::mbrOk , CMsgBox::mbrOk);
|
ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_EPGVIEWER_NODETAILED, CMsgBox::mbrOk , CMsgBox::mbrOk);
|
||||||
}
|
}
|
||||||
@@ -1205,7 +1205,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
|
showTimerEventBar(true, !mp_info && isCurrentEPG(channel_id), mp_info); //show buttons
|
||||||
timeoutEnd = CRCInput::calcTimeoutEnd(timeout);
|
timeoutEnd = CRCInput::calcTimeoutEnd(timeout);
|
||||||
}
|
}
|
||||||
else if (imdb_active && imdb->gotPoster())
|
else if (imdb_active && imdb->hasPoster())
|
||||||
{
|
{
|
||||||
imdb_active = false;
|
imdb_active = false;
|
||||||
CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, LOCALE_IMDB_INFO_SAVE);
|
CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, LOCALE_IMDB_INFO_SAVE);
|
||||||
@@ -1599,7 +1599,7 @@ void CEpgData::showTimerEventBar (bool pshow, bool adzap, bool mp_info)
|
|||||||
|
|
||||||
if (imdb_active)
|
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;
|
EpgButtons[UsedButtons][1].locale = LOCALE_IMDB_INFO_SAVE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1663,7 +1663,7 @@ int CEpgData::showIMDb(bool splash)
|
|||||||
|
|
||||||
//data
|
//data
|
||||||
epgTextSwitch = imdb->getMovieText();
|
epgTextSwitch = imdb->getMovieText();
|
||||||
processTextToArray(imdb->getEPGText(), 0, imdb->gotPoster());
|
processTextToArray(imdb->getEPGText(), 0, imdb->hasPoster());
|
||||||
|
|
||||||
textCount = epgText.size();
|
textCount = epgText.size();
|
||||||
|
|
||||||
@@ -1684,7 +1684,7 @@ int CEpgData::showIMDb(bool splash)
|
|||||||
value.replace(pos, 1, ""); // change 8,1 or 8.1 to 81
|
value.replace(pos, 1, ""); // change 8,1 or 8.1 to 81
|
||||||
imdb_stars = atoi(value);
|
imdb_stars = atoi(value);
|
||||||
|
|
||||||
showText(0, sy + toph, imdb->gotPoster());
|
showText(0, sy + toph, imdb->hasPoster());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -509,8 +509,3 @@ void CIMDB::cleanup()
|
|||||||
if (access(posterfile.c_str(), F_OK) == 0)
|
if (access(posterfile.c_str(), F_OK) == 0)
|
||||||
unlink(posterfile.c_str());
|
unlink(posterfile.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CIMDB::gotPoster()
|
|
||||||
{
|
|
||||||
return (access(posterfile.c_str(), F_OK) == 0);
|
|
||||||
}
|
|
||||||
|
@@ -24,10 +24,24 @@
|
|||||||
#ifndef __imdb__
|
#ifndef __imdb__
|
||||||
#define __imdb__
|
#define __imdb__
|
||||||
|
|
||||||
|
#include <system/helpers.h>
|
||||||
#include <zapit/zapit.h>
|
#include <zapit/zapit.h>
|
||||||
|
|
||||||
class CIMDB
|
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:
|
public:
|
||||||
CIMDB();
|
CIMDB();
|
||||||
~CIMDB();
|
~CIMDB();
|
||||||
@@ -47,26 +61,12 @@ class CIMDB
|
|||||||
std::string getEPGText();
|
std::string getEPGText();
|
||||||
std::string getMovieText();
|
std::string getMovieText();
|
||||||
|
|
||||||
bool gotPoster();
|
std::string getPoster() { return posterfile;}
|
||||||
|
bool hasPoster() { return (access(posterfile.c_str(), F_OK) == 0); }
|
||||||
|
|
||||||
bool checkIMDbElement(std::string element);
|
bool checkIMDbElement(std::string element);
|
||||||
//FIXME: what if m[element] doesn't exist?
|
//FIXME: what if m[element] doesn't exist?
|
||||||
std::string getIMDbElement(std::string element) { return m[element]; };
|
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
|
#endif
|
||||||
|
@@ -57,6 +57,7 @@ CTMDB::CTMDB()
|
|||||||
#else
|
#else
|
||||||
key = g_settings.tmdb_api_key;
|
key = g_settings.tmdb_api_key;
|
||||||
#endif
|
#endif
|
||||||
|
posterfile = "/tmp/tmdb.jpg";
|
||||||
hintbox = NULL;
|
hintbox = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,9 +175,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());
|
//printf("test: %s (%s)\n",elements[i].get("character","").asString().c_str(),elements[i].get("name","").asString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
unlink(TMDB_COVER);
|
unlink(posterfile.c_str());
|
||||||
if (hasCover())
|
if (hasPoster())
|
||||||
getBigCover(TMDB_COVER);
|
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);
|
//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;
|
return true;
|
||||||
@@ -230,8 +231,8 @@ std::string CTMDB::getMovieText()
|
|||||||
|
|
||||||
void CTMDB::cleanup()
|
void CTMDB::cleanup()
|
||||||
{
|
{
|
||||||
if (access(TMDB_COVER, F_OK) == 0)
|
if (access(posterfile.c_str(), F_OK) == 0)
|
||||||
unlink(TMDB_COVER);
|
unlink(posterfile.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTMDB::selectResult(Json::Value elements, int results, int &use_result)
|
void CTMDB::selectResult(Json::Value elements, int results, int &use_result)
|
||||||
|
@@ -25,8 +25,6 @@
|
|||||||
#include <system/helpers-json.h>
|
#include <system/helpers-json.h>
|
||||||
#include <gui/widget/hintbox.h>
|
#include <gui/widget/hintbox.h>
|
||||||
|
|
||||||
#define TMDB_COVER "/tmp/tmdb.jpg"
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
std::string epgtitle;
|
std::string epgtitle;
|
||||||
std::string poster_path;
|
std::string poster_path;
|
||||||
@@ -55,6 +53,7 @@ class CTMDB
|
|||||||
bool GetMovieDetails(std::string lang, bool second = false);
|
bool GetMovieDetails(std::string lang, bool second = false);
|
||||||
bool GetData(std::string url, Json::Value *root);
|
bool GetData(std::string url, Json::Value *root);
|
||||||
void selectResult(Json::Value elements, int results, int &used_result);
|
void selectResult(Json::Value elements, int results, int &used_result);
|
||||||
|
std::string posterfile;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CTMDB();
|
CTMDB();
|
||||||
@@ -70,10 +69,10 @@ class CTMDB
|
|||||||
std::string getDescription() { return minfo.overview;}
|
std::string getDescription() { return minfo.overview;}
|
||||||
std::string getVote() { return minfo.vote_average;}
|
std::string getVote() { return minfo.vote_average;}
|
||||||
std::string getCast() { return minfo.cast;}
|
std::string getCast() { return minfo.cast;}
|
||||||
std::string getCover() { return TMDB_COVER;}
|
std::string getPoster() { return posterfile;}
|
||||||
bool hasCover() { return !minfo.poster_path.empty();}
|
bool hasPoster() { return !minfo.poster_path.empty();}
|
||||||
bool getBigCover(std::string cover) { return downloadUrl("http://image.tmdb.org/t/p/w342" + minfo.poster_path, cover);}
|
bool getBigPoster(std::string poster) { return downloadUrl("http://image.tmdb.org/t/p/w342" + minfo.poster_path, poster);}
|
||||||
bool getSmallCover(std::string cover) { return downloadUrl("http://image.tmdb.org/t/p/w185" + minfo.poster_path, cover);}
|
bool getSmallPoster(std::string poster) { return downloadUrl("http://image.tmdb.org/t/p/w185" + minfo.poster_path, poster);}
|
||||||
int getResults() { return minfo.result;}
|
int getResults() { return minfo.result;}
|
||||||
int getStars() { return (int) (atof(minfo.vote_average.c_str())+0.5);}
|
int getStars() { return (int) (atof(minfo.vote_average.c_str())+0.5);}
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
@@ -2161,10 +2161,10 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg)
|
|||||||
if (tmdb)
|
if (tmdb)
|
||||||
{
|
{
|
||||||
tmdb->setTitle(m_movieSelectionHandler->epgTitle);
|
tmdb->setTitle(m_movieSelectionHandler->epgTitle);
|
||||||
if ((tmdb->getResults() > 0) && (tmdb->hasCover()))
|
if ((tmdb->getResults() > 0) && (tmdb->hasPoster()))
|
||||||
{
|
{
|
||||||
if (!cover_file.empty())
|
if (!cover_file.empty())
|
||||||
if (tmdb->getSmallCover(cover_file))
|
if (tmdb->getSmallPoster(cover_file))
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
tmdb->cleanup();
|
tmdb->cleanup();
|
||||||
|
Reference in New Issue
Block a user