aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-09-18 17:57:55 +0200
committerdec05eba <dec05eba@protonmail.com>2020-09-18 17:57:55 +0200
commitd10fca5ec99de7f1e9b5cc857f5cc629a6ee0126 (patch)
treea6986a06d682dd32d171e0e02afdccf6a745311e /src/plugins
parent12c59fddcf1201536c3bee8db4e0d6ac8964fde6 (diff)
Add torrent description
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Fourchan.cpp8
-rw-r--r--src/plugins/NyaaSi.cpp16
2 files changed, 18 insertions, 6 deletions
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<BodyItem>("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;