diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/ImageBoard.cpp | 2 | ||||
-rw-r--r-- | src/plugins/Youtube.cpp | 24 |
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()) { |