imdb/tmdb: more unifications; getStars()

Origin commit data
------------------
Branch: ni/coolstream
Commit: cfc25bd53f
Author: vanhofen <vanhofen@gmx.de>
Date: 2021-05-03 (Mon, 03 May 2021)

Origin message was:
------------------
- imdb/tmdb: more unifications; getStars()

------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
vanhofen
2021-05-03 01:00:35 +02:00
parent 54552558ce
commit b57ec6a248
3 changed files with 15 additions and 15 deletions

View File

@@ -1687,21 +1687,7 @@ int CEpgData::showIMDb()
textCount = epgText.size(); textCount = epgText.size();
//rating //rating
imdb_rating = imdb->getIMDbElement("imdbRating"); imdb_stars = imdb->getStars();
std::string value = imdb_rating;
if (imdb_rating == "N/A")
{
value = "0";
imdb_rating = g_Locale->getText(LOCALE_IMDB_DATA_RATING_FAILED);
}
else
imdb_rating += "/10";
size_t pos = value.find_first_of(",.");
if (pos != std::string::npos)
value.replace(pos, 1, ""); // change 8,1 or 8.1 to 81
imdb_stars = atoi(value);
showText(0, sy + toph, imdb->hasPoster()); showText(0, sy + toph, imdb->hasPoster());
return 0; return 0;

View File

@@ -455,6 +455,19 @@ std::string CIMDB::getMovieText()
return movietext; return movietext;
} }
int CIMDB::getStars()
{
std::string imdbRating = "";
if (checkElement("imdbRating"))
imdbRating = getIMDbElement("imdbRating");
if (imdbRating.empty() || imdbRating == "N/A")
return 0;
return (int)(atof(imdbRating.c_str()) * 10);
}
std::string CIMDB::getFilename(CZapitChannel *channel, uint64_t id) std::string CIMDB::getFilename(CZapitChannel *channel, uint64_t id)
{ {
char fname[512]; // UTF-8 char fname[512]; // UTF-8

View File

@@ -65,6 +65,7 @@ class CIMDB
std::string getPoster() { return posterfile; } std::string getPoster() { return posterfile; }
bool hasPoster() { return (access(posterfile.c_str(), F_OK) == 0); } bool hasPoster() { return (access(posterfile.c_str(), F_OK) == 0); }
int getStars();
bool checkElement(std::string element); bool checkElement(std::string element);
//FIXME: what if m[element] doesn't exist? //FIXME: what if m[element] doesn't exist?