From d10fca5ec99de7f1e9b5cc857f5cc629a6ee0126 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 18 Sep 2020 17:57:55 +0200 Subject: Add torrent description --- README.md | 2 +- depends/html-search | 2 +- src/QuickMedia.cpp | 4 ++-- src/plugins/Fourchan.cpp | 8 ++------ src/plugins/NyaaSi.cpp | 16 ++++++++++++++++ 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b97b323..0578f8f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # QuickMedia Native clients of websites with fast access to what you want to see, **with TOR support**. See [old video demo with manga](https://lbry.tv/quickmedia_manga-2019-08-05_21.20.46/7).\ -Currently supported websites: `youtube`, `manganelo`, `mangatown`, `mangadex`, `4chan` and _others_.\ +Currently supported websites: `youtube`, `nyaa.si`, `manganelo`, `mangatown`, `mangadex`, `4chan` and _others_.\ **Note:** Manganelo doesn't work when used with TOR.\ **Note:** Posting comments on 4chan doesn't work when used with TOR. However browsing works.\ **Note:** TOR system service needs to be running (`systemctl start tor.service`).\ diff --git a/depends/html-search b/depends/html-search index ea043d4..4e5de20 160000 --- a/depends/html-search +++ b/depends/html-search @@ -1 +1 @@ -Subproject commit ea043d4979f8d60a7ebd8239ccb272ae3ac70fc1 +Subproject commit 4e5de201c070352837d22f3700b3ea47d9ed3043 diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 01a82c6..417d4ea 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -2313,7 +2313,7 @@ namespace QuickMedia { search_bar->onTextUpdateCallback = [this, &update_search_text](const std::string &text) { if(current_plugin->content_list_search_is_filter()) { body->filter_search_fuzzy(text); - body->clamp_selection(); + body->select_first_item(); } else { update_search_text = text; } @@ -2367,7 +2367,7 @@ namespace QuickMedia { if(search_running && search_future.valid() && search_future.wait_for(std::chrono::seconds(0)) == std::future_status::ready) { if(update_search_text.empty()) { body->items = search_future.get(); - body->clamp_selection(); + body->select_first_item(); } else { search_future.get(); } diff --git a/src/plugins/Fourchan.cpp b/src/plugins/Fourchan.cpp index 5932144..4f87049 100644 --- a/src/plugins/Fourchan.cpp +++ b/src/plugins/Fourchan.cpp @@ -205,12 +205,8 @@ namespace QuickMedia { static void extract_comment_pieces(const char *html_source, size_t size, CommentPieceCallback callback) { TidyDoc doc = tidyCreate(); - TidyIterator it_opt = tidyGetOptionList(doc); - while (it_opt) { - TidyOption opt = tidyGetNextOption(doc, &it_opt); - if (tidyOptGetType(opt) == TidyBoolean) - tidyOptSetBool(doc, tidyOptGetId(opt), no); - } + tidyOptSetBool(doc, TidyShowWarnings, no); + tidyOptSetBool(doc, TidyUseCustomTags, yes); tidyOptSetInt(doc, TidyWrapLen, 0); if(tidyParseString(doc, html_source) < 0) { CommentPiece comment_piece; diff --git a/src/plugins/NyaaSi.cpp b/src/plugins/NyaaSi.cpp index 18dd53a..0d43810 100644 --- a/src/plugins/NyaaSi.cpp +++ b/src/plugins/NyaaSi.cpp @@ -162,6 +162,7 @@ namespace QuickMedia { // torrent_item->url = "https://nyaa.si/download/" + id + ".torrent"; auto torrent_item = std::make_unique("Download magnet"); std::string magnet_url; + std::string description; std::string website_data; if(download_to_string(url, website_data, {}, use_tor, true) != DownloadResult::OK) @@ -194,6 +195,21 @@ namespace QuickMedia { goto cleanup; } + result = quickmedia_html_find_nodes_xpath(&html_search, "//div[id='torrent-description']", + [](QuickMediaHtmlNode *node, void *userdata) { + std::string *description = (std::string*)userdata; + const char *text = quickmedia_html_node_get_text(node); + if(description->empty() && text) { + *description = strip(text); + } + }, &description); + + if(result != 0) + goto cleanup; + + if(!description.empty()) + result_items.front()->set_description("Description:\n" + description); + result = quickmedia_html_find_nodes_xpath(&html_search, "//div[class='container']//a", [](QuickMediaHtmlNode *node, void *userdata) { std::string *magnet_url = (std::string*)userdata; -- cgit v1.2.3