aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/QuickMedia.cpp6
-rw-r--r--src/plugins/Matrix.cpp3
-rw-r--r--src/plugins/Youtube.cpp17
3 files changed, 11 insertions, 15 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 456bdc6..54308a4 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1019,7 +1019,9 @@ namespace QuickMedia {
};
// Returns relative time as a string (approximation)
- static std::string timestamp_to_relative_time_str(time_t seconds) {
+ static std::string seconds_to_relative_time_str(time_t seconds) {
+ seconds = std::max(0L, seconds);
+
time_t minutes = seconds / 60;
time_t hours = minutes / 60;
time_t days = hours / 24;
@@ -1068,7 +1070,7 @@ namespace QuickMedia {
auto body_item = BodyItem::create(std::move(title_str));
body_item->url = "https://www.youtube.com/watch?v=" + video_id_str;
body_item->thumbnail_url = "https://img.youtube.com/vi/" + video_id_str + "/hqdefault.jpg";
- body_item->set_description("Watched " + timestamp_to_relative_time_str(std::max(0l, time_now - timestamp.asInt64())));
+ body_item->set_description("Watched " + seconds_to_relative_time_str(time_now - timestamp.asInt64()));
body_item->thumbnail_size = sf::Vector2i(175, 131);
body_items.push_back(std::move(body_item));
}
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 4a414da..6af5e6e 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -3742,7 +3742,8 @@ namespace QuickMedia {
if(num_joined_members_json.IsInt()) {
if(!description.empty())
description += '\n';
- description += ("👤" + std::to_string(num_joined_members_json.GetInt()) + " users");
+ const int num_joined_numbers = num_joined_members_json.GetInt();
+ description += ("👤" + std::to_string(num_joined_numbers) + " user" + (num_joined_numbers == 1 ? "" : "s"));
}
room_body_item->set_description(std::move(description));
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index 9e07400..4c4372e 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -1230,7 +1230,9 @@ namespace QuickMedia {
}
// Returns relative time as a string (approximation)
- static std::string timestamp_to_relative_time_str(time_t seconds) {
+ static std::string seconds_to_relative_time_str(time_t seconds) {
+ seconds = std::max(0L, seconds);
+
time_t minutes = seconds / 60;
time_t hours = minutes / 60;
time_t days = hours / 24;
@@ -1322,22 +1324,13 @@ namespace QuickMedia {
time.tm_hour = hour;
time.tm_min = minute;
time.tm_sec = second;
- time_t unixtime = mktime(&time);
-
- struct tm entry_time;
- localtime_r(&unixtime, &entry_time);
- time_t unixtime_local = mktime(&entry_time);
- subscription_data_list.back().subscription_entry.published = unixtime_local;
+ subscription_data_list.back().subscription_entry.published = timegm(&time);
}
}, &subscription_data_list);
html_parser_parse(&html_parser);
html_parser_deinit(&html_parser);
- /*std::sort(subscription_data_list.begin(), subscription_data_list.end(), [](const SubscriptionData &sub_data1, const SubscriptionData &sub_data2) {
- return sub_data1.subscription_entry.published > sub_data2.subscription_entry.published;
- });*/
-
std::vector<YoutubeSubscriptionTaskResult> results;
for(SubscriptionData &subscription_data : subscription_data_list) {
if(subscription_data.subscription_entry.title.empty() || subscription_data.subscription_entry.video_id.empty() || subscription_data.subscription_entry.published == 0)
@@ -1345,7 +1338,7 @@ namespace QuickMedia {
html_unescape_sequences(subscription_data.subscription_entry.title);
auto body_item = BodyItem::create(std::move(subscription_data.subscription_entry.title));
- body_item->set_description("Uploaded " + timestamp_to_relative_time_str(time_now - subscription_data.subscription_entry.published));
+ body_item->set_description("Uploaded " + seconds_to_relative_time_str(time_now - subscription_data.subscription_entry.published));
body_item->set_description_color(sf::Color(179, 179, 179));
body_item->url = "https://www.youtube.com/watch?v=" + subscription_data.subscription_entry.video_id;
body_item->thumbnail_url = "https://img.youtube.com/vi/" + subscription_data.subscription_entry.video_id + "/hqdefault.jpg";