aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-12-02 02:51:03 +0100
committerdec05eba <dec05eba@protonmail.com>2021-12-02 02:51:03 +0100
commit40693c88eba9d4bb86688b5b59c91308828830c1 (patch)
tree18e67e0af1d251f6c59a8808d1179ab55155e9ff /src
parent899669eda8441fb6bbfde8da3cc78ee1fff5212e (diff)
Youtube: better rating ratio for videos with rating disabled
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Youtube.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index 3d10a4c..8ffaebf 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -2290,20 +2290,17 @@ namespace QuickMedia {
if(!description.empty())
description += " • ";
- fprintf(stderr, "like/dislike ratio: %s\n", video_details.rating.c_str());
+ double average_rating = atof(video_details.rating.c_str());
+ // Minimum rating for a video is 1.0, even if a video only has dislikes
+ average_rating -= 1.0;
+ if(average_rating < 0.00000001)
+ average_rating = 0.00000001;
if(num_likes == -1) {
- description += "rated " + video_details.rating.substr(0, 4) + "/5";
+ description += "rated " + std::to_string(average_rating / 4.0 * 5.0).substr(0, 4) + "/5.0";
} else {
- double average_rating = atof(video_details.rating.c_str());
- // Minimum rating for a video is 1.0, even if a video only has dislikes
- average_rating -= 1.0;
- if(average_rating < 0.00000001)
- average_rating = 0.00000001;
-
const int64_t num_ratings = num_likes * (4.0 / average_rating);
const int64_t num_dislikes = (num_ratings - num_likes);
-
description += "👍 " + number_separate_thousand_commas(std::to_string(num_likes)) + " 👎 " + number_separate_thousand_commas(std::to_string(num_dislikes));
}
}