aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-11-18 12:59:58 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-18 12:59:58 +0100
commit7f538cf8187ca8107696ec22406aef1d44fe04e3 (patch)
treec5f5014db08dec3b57e214dee5490a37820db080 /src
parentae5462ab104e968fe1ec2865957929e126b0d600 (diff)
Fix crash when going to ctrl+r when first page is youtube video (starting quickmedia with a youtube url), better youtube video description
Diffstat (limited to 'src')
-rw-r--r--src/plugins/ImageBoard.cpp2
-rw-r--r--src/plugins/Youtube.cpp24
2 files changed, 23 insertions, 3 deletions
diff --git a/src/plugins/ImageBoard.cpp b/src/plugins/ImageBoard.cpp
index 3b7850b..b027b9e 100644
--- a/src/plugins/ImageBoard.cpp
+++ b/src/plugins/ImageBoard.cpp
@@ -2,7 +2,7 @@
namespace QuickMedia {
void ImageBoardThreadPage::copy_to_clipboard(const BodyItem *body_item) {
- set_clipboard(body_item->get_description());
+ set_clipboard(body_item->get_title());
}
PluginResult ImageBoardThreadPage::login(const std::string &token, const std::string &pin, std::string &response_msg) {
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index 8dabd2d..8e08062 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -2167,18 +2167,38 @@ namespace QuickMedia {
return result_items;
}
+ static std::string views_separate_with_commas(const std::string &views) {
+ const int num_commas = ((int)views.size() - 1) / 3;
+ std::string result;
+ result.resize(views.size() + num_commas);
+ int result_index = (int)views.size() + num_commas - 1;
+ int inc = 0;
+
+ for(int i = (int)views.size() - 1; i >= 0; --i, ++inc) {
+ if(inc > 0 && inc % 3 == 0) {
+ result[result_index] = ',';
+ --result_index;
+ }
+
+ result[result_index] = views[i];
+ --result_index;
+ }
+
+ return result;
+ }
+
static std::shared_ptr<BodyItem> video_details_to_body_item(const YoutubeVideoDetails &video_details) {
auto body_item = BodyItem::create(video_details.title);
std::string description;
if(!video_details.views.empty()) {
- description = video_details.views + " view" + (video_details.views == "1" ? "" : "s");
+ description = views_separate_with_commas(video_details.views) + " view" + (video_details.views == "1" ? "" : "s");
}
if(!video_details.rating.empty()) {
if(!description.empty())
description += " • ";
- description += "rated " + video_details.rating + "/5";
+ description += "rated " + video_details.rating.substr(0, 4) + "/5";
}
if(!video_details.author.empty()) {