From 976bb352e7f0893c97ade2a31cb6a47f266be243 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Mon, 3 May 2021 01:00:35 +0200 Subject: [PATCH] - imdb/tmdb: more unifications; getStars() Signed-off-by: Thilo Graf --- src/gui/epgview.cpp | 16 +--------------- src/gui/mdb-imdb.cpp | 13 +++++++++++++ src/gui/mdb-imdb.h | 1 + 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index eb212c11d..c71083087 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -1658,21 +1658,7 @@ int CEpgData::showIMDb() textCount = epgText.size(); //rating - imdb_rating = imdb->getIMDbElement("imdbRating"); - - 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); + imdb_stars = imdb->getStars(); showText(0, sy + toph, imdb->hasPoster()); return 0; diff --git a/src/gui/mdb-imdb.cpp b/src/gui/mdb-imdb.cpp index 3cc4421dd..ebda175a2 100644 --- a/src/gui/mdb-imdb.cpp +++ b/src/gui/mdb-imdb.cpp @@ -455,6 +455,19 @@ std::string CIMDB::getMovieText() 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) { char fname[512]; // UTF-8 diff --git a/src/gui/mdb-imdb.h b/src/gui/mdb-imdb.h index 99f6b4cbb..b67c8afc4 100644 --- a/src/gui/mdb-imdb.h +++ b/src/gui/mdb-imdb.h @@ -65,6 +65,7 @@ class CIMDB std::string getPoster() { return posterfile; } bool hasPoster() { return (access(posterfile.c_str(), F_OK) == 0); } + int getStars(); bool checkElement(std::string element); //FIXME: what if m[element] doesn't exist?