diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index 219487888..8ea5b648f 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -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) @@ -1008,7 +1008,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start if (showPos+scrollCountgotPoster()), false); + showText(showPos, sy + toph, (tmdb_active && tmdb->hasPoster()) || (imdb_active && imdb->hasPoster()), false); } break; 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; 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: @@ -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())) { epgText_saved = epgText; epgText.clear(); - tmdb_active = !tmdb_active; + tmdb_active = true; epgTextSwitch = tmdb->getMovieText(); - processTextToArray(tmdb->getEPGText(), 0, tmdb->hasCover()); + processTextToArray(tmdb->getEPGText(), 0, tmdb->hasPoster()); textCount = epgText.size(); stars = tmdb->getStars(); - showText(showPos, sy + toph, tmdb_active || (imdb_active && imdb->gotPoster())); + showText(showPos, sy + toph, tmdb->hasPoster()); } else { 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 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); @@ -1599,7 +1599,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 @@ -1663,7 +1663,7 @@ int CEpgData::showIMDb(bool splash) //data epgTextSwitch = imdb->getMovieText(); - processTextToArray(imdb->getEPGText(), 0, imdb->gotPoster()); + processTextToArray(imdb->getEPGText(), 0, imdb->hasPoster()); textCount = epgText.size(); @@ -1684,7 +1684,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; } diff --git a/src/gui/mdb-imdb.cpp b/src/gui/mdb-imdb.cpp index fc2df2c48..20797f4f0 100644 --- a/src/gui/mdb-imdb.cpp +++ b/src/gui/mdb-imdb.cpp @@ -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); -} diff --git a/src/gui/mdb-imdb.h b/src/gui/mdb-imdb.h index 4e95c46ad..0067ed7bd 100644 --- a/src/gui/mdb-imdb.h +++ b/src/gui/mdb-imdb.h @@ -24,10 +24,24 @@ #ifndef __imdb__ #define __imdb__ +#include #include 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 m; + + void initMap(std::map& my); + public: CIMDB(); ~CIMDB(); @@ -47,26 +61,12 @@ class CIMDB std::string getEPGText(); 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); //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 m; - - std::string getApiKey(); - - void initMap(std::map& my); }; #endif diff --git a/src/gui/mdb-tmdb.cpp b/src/gui/mdb-tmdb.cpp index b710c0cb7..19ce51267 100644 --- a/src/gui/mdb-tmdb.cpp +++ b/src/gui/mdb-tmdb.cpp @@ -57,6 +57,7 @@ CTMDB::CTMDB() #else key = g_settings.tmdb_api_key; #endif + posterfile = "/tmp/tmdb.jpg"; 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()); } - 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; @@ -230,8 +231,8 @@ std::string CTMDB::getMovieText() 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) diff --git a/src/gui/mdb-tmdb.h b/src/gui/mdb-tmdb.h index 660d37df7..e33bcdda2 100644 --- a/src/gui/mdb-tmdb.h +++ b/src/gui/mdb-tmdb.h @@ -25,8 +25,6 @@ #include #include -#define TMDB_COVER "/tmp/tmdb.jpg" - typedef struct { std::string epgtitle; std::string poster_path; @@ -55,6 +53,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(); @@ -70,10 +69,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())+0.5);} void cleanup(); diff --git a/src/gui/moviebrowser/mb.cpp b/src/gui/moviebrowser/mb.cpp index b8738a7dc..7325bd410 100644 --- a/src/gui/moviebrowser/mb.cpp +++ b/src/gui/moviebrowser/mb.cpp @@ -2161,10 +2161,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();