From d10fca5ec99de7f1e9b5cc857f5cc629a6ee0126 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 18 Sep 2020 17:57:55 +0200 Subject: Add torrent description --- src/plugins/NyaaSi.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/plugins/NyaaSi.cpp') 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