aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/NyaaSi.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/plugins/NyaaSi.cpp b/src/plugins/NyaaSi.cpp
index 1cdfc5f..f6724b2 100644
--- a/src/plugins/NyaaSi.cpp
+++ b/src/plugins/NyaaSi.cpp
@@ -237,6 +237,7 @@ namespace QuickMedia {
PluginResult NyaaSi::get_content_details(const std::string&, const std::string &url, BodyItems &result_items) {
size_t comments_start_index;
+ std::string title;
auto torrent_item = BodyItem::create("Download magnet");
std::string magnet_url;
@@ -251,13 +252,32 @@ namespace QuickMedia {
if(result != 0)
goto cleanup;
+ result = quickmedia_html_find_nodes_xpath(&html_search, "//h3[class='panel-title']",
+ [](QuickMediaHtmlNode *node, void *userdata) {
+ std::string *title = (std::string*)userdata;
+ const char *text = quickmedia_html_node_get_text(node);
+ if(title->empty() && text) {
+ *title = text;
+ }
+ }, &title);
+
+ if(result != 0)
+ goto cleanup;
+
+ if(title.empty()) {
+ fprintf(stderr, "Error: nyaa.si: failed to get title\n");
+ result = -1;
+ goto cleanup;
+ }
+
result = quickmedia_html_find_nodes_xpath(&html_search, "//div[class='panel-body']//a",
[](QuickMediaHtmlNode *node, void *userdata) {
auto *item_data = (BodyItems*)userdata;
const char *href = quickmedia_html_node_get_attribute_value(node, "href");
const char *text = quickmedia_html_node_get_text(node);
if(item_data->empty() && href && text && strncmp(href, "/user/", 6) == 0) {
- auto body_item = BodyItem::create("Submitter: " + strip(text));
+ auto body_item = BodyItem::create("");
+ body_item->set_description("Submitter: " + strip(text));
body_item->url = "https://nyaa.si/" + std::string(href);
item_data->push_back(std::move(body_item));
}
@@ -272,6 +292,8 @@ namespace QuickMedia {
goto cleanup;
}
+ result_items.front()->set_title(strip(title));
+
result = quickmedia_html_find_nodes_xpath(&html_search, "//div[id='torrent-description']",
[](QuickMediaHtmlNode *node, void *userdata) {
std::string *description = (std::string*)userdata;
@@ -285,7 +307,7 @@ namespace QuickMedia {
goto cleanup;
if(!description.empty())
- result_items.front()->set_description("Description:\n" + description);
+ result_items.front()->set_description(result_items.front()->get_description() + "\nDescription:\n" + description);
result = quickmedia_html_find_nodes_xpath(&html_search, "//div[class='container']//a",
[](QuickMediaHtmlNode *node, void *userdata) {