diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/Youtube.cpp | 15 |
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)); } } |