diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index 242475db6..14a51fb1a 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -1171,11 +1171,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start epgText_saved = epgText; epgText.clear(); tmdb_active = !tmdb_active; - - epgTextSwitch = tmdb->getDescription(); - if (!tmdb->getCast().empty()) - epgTextSwitch += "\n\n"+(std::string)g_Locale->getText(LOCALE_EPGEXTENDED_ACTORS)+":\n"+ tmdb->getCast()+"\n"; - + epgTextSwitch = tmdb->CreateMovieText(); processTextToArray(tmdb->CreateEPGText(), 0, tmdb->hasCover()); textCount = epgText.size(); stars = tmdb->getStars(); @@ -1668,39 +1664,8 @@ int CEpgData::showIMDb(bool splash) epgText.clear(); //data - std::string txt; - txt.clear(); - imdb->getIMDbData(txt); - processTextToArray(" ", 0, imdb->gotPoster()); // empty line to get space for the rating stars - // create mp_movie_info->epgInfo2 - if (imdb->checkIMDbElement("Plot")) - { - epgTextSwitch = imdb->getIMDbElement("Plot") + "\n"; - if (imdb->checkIMDbElement("Title")) - { - epgTextSwitch += "\n"; - epgTextSwitch += g_Locale->getString(LOCALE_IMDB_DATA_TITLE) + ": "; - epgTextSwitch += imdb->getIMDbElement("Title"); - } - if (imdb->checkIMDbElement("Country")) - { - epgTextSwitch += "\n"; - epgTextSwitch += g_Locale->getString(LOCALE_IMDB_DATA_RELEASED) + ": "; - epgTextSwitch += imdb->getIMDbElement("Country"); - if (imdb->checkIMDbElement("Released")) - { - epgTextSwitch += ", " + imdb->getIMDbElement("Released"); - } - } - if (imdb->checkIMDbElement("Actors")) - { - epgTextSwitch += "\n"; - epgTextSwitch += g_Locale->getString(LOCALE_IMDB_DATA_ACTORS) + ": "; - epgTextSwitch += imdb->getIMDbElement("Actors"); - } - } - - processTextToArray(txt, 0, imdb->gotPoster()); + epgTextSwitch = imdb->CreateMovieText(); + processTextToArray(imdb->CreateEPGText(), 0, imdb->gotPoster()); textCount = epgText.size(); diff --git a/src/gui/imdb.cpp b/src/gui/imdb.cpp index 579a217ff..a38602214 100644 --- a/src/gui/imdb.cpp +++ b/src/gui/imdb.cpp @@ -364,46 +364,80 @@ bool CIMDB::checkIMDbElement(std::string element) return true; } -void CIMDB::getIMDbData(std::string& txt) +std::string CIMDB::CreateEPGText() { if (m["imdbID"].empty() || m["Response"] != "True") - { - txt = g_Locale->getText(LOCALE_IMDB_DATA_FAILED); - return; - } + return g_Locale->getText(LOCALE_IMDB_DATA_FAILED); - txt += g_Locale->getString(LOCALE_IMDB_DATA_VOTES) + ": " + m["imdbVotes"] + "\n"; + std::string epgtext(""); + + epgtext += g_Locale->getString(LOCALE_IMDB_DATA_VOTES) + ": " + m["imdbVotes"] + "\n"; if (checkIMDbElement("Metascore")) - txt += g_Locale->getString(LOCALE_IMDB_DATA_METASCORE) + ": " + m["Metascore"] + "/100\n"; - txt += g_Locale->getString(LOCALE_IMDB_DATA_TITLE) + ": " + m["Title"] + "\n"; + epgtext += g_Locale->getString(LOCALE_IMDB_DATA_METASCORE) + ": " + m["Metascore"] + "/100\n"; + epgtext += "\n"; + epgtext += g_Locale->getString(LOCALE_IMDB_DATA_TITLE) + ": " + m["Title"] + "\n"; if (checkIMDbElement("Released")) - txt += g_Locale->getString(LOCALE_IMDB_DATA_RELEASED) + ": " + m["Country"] + ", " + m["Released"] + "\n"; + epgtext += g_Locale->getString(LOCALE_IMDB_DATA_RELEASED) + ": " + m["Country"] + ", " + m["Released"] + "\n"; if (checkIMDbElement("Runtime")) - txt += g_Locale->getString(LOCALE_IMDB_DATA_RUNTIME) + ": " + m["Runtime"] + "\n"; + epgtext += g_Locale->getString(LOCALE_IMDB_DATA_RUNTIME) + ": " + m["Runtime"] + "\n"; if (checkIMDbElement("Genre")) - txt += g_Locale->getString(LOCALE_IMDB_DATA_GENRE) + ": " + m["Genre"] + "\n"; + epgtext += g_Locale->getString(LOCALE_IMDB_DATA_GENRE) + ": " + m["Genre"] + "\n"; if (checkIMDbElement("Awards")) - txt += g_Locale->getString(LOCALE_IMDB_DATA_AWARDS) + ": " + m["Awards"] + "\n"; + epgtext += g_Locale->getString(LOCALE_IMDB_DATA_AWARDS) + ": " + m["Awards"] + "\n"; if (checkIMDbElement("Director")) - txt += g_Locale->getString(LOCALE_IMDB_DATA_DIRECTOR) + ": " + m["Director"] + "\n"; + epgtext += g_Locale->getString(LOCALE_IMDB_DATA_DIRECTOR) + ": " + m["Director"] + "\n"; if (checkIMDbElement("Writer")) - txt += g_Locale->getString(LOCALE_IMDB_DATA_WRITER) + ": " + m["Writer"] + "\n"; + epgtext += g_Locale->getString(LOCALE_IMDB_DATA_WRITER) + ": " + m["Writer"] + "\n"; if (checkIMDbElement("Production")) - txt += g_Locale->getString(LOCALE_IMDB_DATA_PRODUCTION) + ": " + m["Production"] + "\n"; + epgtext += g_Locale->getString(LOCALE_IMDB_DATA_PRODUCTION) + ": " + m["Production"] + "\n"; if (checkIMDbElement("Website")) - txt += g_Locale->getString(LOCALE_IMDB_DATA_WEBSITE) + ": " + m["Website"] + "\n"; + epgtext += g_Locale->getString(LOCALE_IMDB_DATA_WEBSITE) + ": " + m["Website"] + "\n"; if (checkIMDbElement("BoxOffice")) - txt += g_Locale->getString(LOCALE_IMDB_DATA_BOXOFFICE) + ": " + m["BoxOffice"] + "\n"; + epgtext += g_Locale->getString(LOCALE_IMDB_DATA_BOXOFFICE) + ": " + m["BoxOffice"] + "\n"; if (checkIMDbElement("Actors")) { - txt += "\n"; - txt += g_Locale->getString(LOCALE_IMDB_DATA_ACTORS) + ": " + m["Actors"] + "\n"; + epgtext += "\n"; + epgtext += g_Locale->getString(LOCALE_IMDB_DATA_ACTORS) + ": " + m["Actors"] + "\n"; } if (checkIMDbElement("Plot")) { - txt += "\n"; - txt += g_Locale->getString(LOCALE_IMDB_DATA_PLOT) + ": " + m["Plot"]; + epgtext += "\n"; + epgtext += g_Locale->getString(LOCALE_IMDB_DATA_PLOT) + ": " + m["Plot"]; } + + return epgtext; +} + +std::string CIMDB::CreateMovieText() +{ + std::string movietext(""); + + if (checkIMDbElement("Plot")) + { + movietext = m["Plot"] + "\n"; + if (checkIMDbElement("Title")) + { + movietext += "\n"; + movietext += g_Locale->getString(LOCALE_IMDB_DATA_TITLE) + ": "; + movietext += m["Title"]; + } + if (checkIMDbElement("Country")) + { + movietext += "\n"; + movietext += g_Locale->getString(LOCALE_IMDB_DATA_RELEASED) + ": "; + movietext += m["Country"]; + if (checkIMDbElement("Released")) + movietext += ", " + m["Released"]; + } + if (checkIMDbElement("Actors")) + { + movietext += "\n"; + movietext += g_Locale->getString(LOCALE_IMDB_DATA_ACTORS) + ": "; + movietext += m["Actors"]; + } + } + + return movietext; } std::string CIMDB::getFilename(CZapitChannel * channel, uint64_t id) @@ -484,5 +518,5 @@ void CIMDB::cleanup() bool CIMDB::gotPoster() { - return (access(posterfile.c_str(), F_OK) == 0); + return (access(posterfile.c_str(), F_OK) == 0); } diff --git a/src/gui/imdb.h b/src/gui/imdb.h index 4c4df3d21..9c421f882 100644 --- a/src/gui/imdb.h +++ b/src/gui/imdb.h @@ -24,8 +24,6 @@ #ifndef __imdb__ #define __imdb__ - - #include class CIMDB @@ -46,7 +44,8 @@ class CIMDB void StringReplace(std::string &str, const std::string search, const std::string rstr); void cleanup(); - void getIMDbData(std::string& txt); + std::string CreateEPGText(); + std::string CreateMovieText(); bool gotPoster(); diff --git a/src/gui/tmdb.cpp b/src/gui/tmdb.cpp index e800572ef..5620c4f40 100644 --- a/src/gui/tmdb.cpp +++ b/src/gui/tmdb.cpp @@ -191,25 +191,45 @@ bool cTmdb::GetMovieDetails(std::string lang, bool second) std::string cTmdb::CreateEPGText() { - std::string epgtext; - epgtext += "Vote: "+minfo.vote_average.substr(0,3)+"/10 Votecount: "+to_string(minfo.vote_count)+"\n"; + std::string epgtext(""); + + epgtext += "Vote: " + minfo.vote_average.substr(0,3) + "/10 Votecount: " + to_string(minfo.vote_count) + "\n"; epgtext += "\n"; - epgtext += minfo.overview+"\n"; + epgtext += minfo.overview + "\n"; epgtext += "\n"; if (minfo.media_type == "tv") - epgtext += (std::string)g_Locale->getText(LOCALE_EPGVIEWER_LENGTH)+": "+minfo.runtimes+"\n"; + epgtext += g_Locale->getString(LOCALE_EPGVIEWER_LENGTH) + ": " + minfo.runtimes + "\n"; else - epgtext += (std::string)g_Locale->getText(LOCALE_EPGVIEWER_LENGTH)+": "+to_string(minfo.runtime)+"\n"; - epgtext += (std::string)g_Locale->getText(LOCALE_EPGVIEWER_GENRE)+": "+minfo.genres+"\n"; - epgtext += (std::string)g_Locale->getText(LOCALE_EPGEXTENDED_ORIGINAL_TITLE) +" : "+ minfo.original_title+"\n"; - epgtext += (std::string)g_Locale->getText(LOCALE_EPGEXTENDED_YEAR_OF_PRODUCTION)+" : "+ minfo.release_date.substr(0,4) +"\n"; + epgtext += g_Locale->getString(LOCALE_EPGVIEWER_LENGTH) + ": " + to_string(minfo.runtime) + "\n"; + epgtext += g_Locale->getString(LOCALE_EPGVIEWER_GENRE) + ": " + minfo.genres + "\n"; + epgtext += g_Locale->getString(LOCALE_EPGEXTENDED_ORIGINAL_TITLE) + ": " + minfo.original_title + "\n"; + epgtext += g_Locale->getString(LOCALE_EPGEXTENDED_YEAR_OF_PRODUCTION) + ": " + minfo.release_date.substr(0,4) + "\n"; if (minfo.media_type == "tv") - epgtext += "Seasons/Episodes: "+to_string(minfo.seasons)+"/"+to_string(minfo.episodes)+"\n"; + epgtext += "Seasons/Episodes: " + to_string(minfo.seasons) + "/" + to_string(minfo.episodes) + "\n"; if (!minfo.cast.empty()) - epgtext += (std::string)g_Locale->getText(LOCALE_EPGEXTENDED_ACTORS)+":\n"+ minfo.cast+"\n"; + epgtext += g_Locale->getString(LOCALE_EPGEXTENDED_ACTORS) + ":\n" + minfo.cast + "\n"; + return epgtext; } +std::string cTmdb::CreateMovieText() +{ + std::string movietext(""); + + if (!minfo.overview.empty()) + { + movietext = minfo.overview + "\n"; + if (!minfo.cast.empty()) + { + movietext += "\n"; + movietext += g_Locale->getString(LOCALE_EPGEXTENDED_ACTORS) + ":\n"; + movietext += minfo.cast; + } + } + + return movietext; +} + void cTmdb::cleanup() { if (access(TMDB_COVER, F_OK) == 0) diff --git a/src/gui/tmdb.h b/src/gui/tmdb.h index 177ae6818..4d37f5bd8 100644 --- a/src/gui/tmdb.h +++ b/src/gui/tmdb.h @@ -62,6 +62,7 @@ class cTmdb static cTmdb* getInstance(); void setTitle(std::string epgtitle); std::string CreateEPGText(); + std::string CreateMovieText(); std::string getTitle() { return minfo.epgtitle;} std::string getOrgTitle() { return minfo.original_title;} @@ -69,7 +70,7 @@ 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;} + 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);}