From 760d903fe7c7c56a6408accff0daa47c2e743eed Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 19 Jan 2023 23:47:37 +0100 Subject: Lazy fetch local anime page --- src/QuickMedia.cpp | 2 +- src/plugins/LocalAnime.cpp | 5 +++++ src/plugins/NyaaSi.cpp | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 447b863..433cc77 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -1279,7 +1279,7 @@ namespace QuickMedia { exit(1); } - auto search_page = std::make_unique(this, get_anime_in_directory(get_config().local_anime.directory)); + auto search_page = std::make_unique(this); tabs.push_back(Tab{create_body(false, true), std::move(search_page), create_search_bar("Search...", SEARCH_DELAY_FILTER)}); start_tab_index = 0; diff --git a/src/plugins/LocalAnime.cpp b/src/plugins/LocalAnime.cpp index 6337adf..14329cc 100644 --- a/src/plugins/LocalAnime.cpp +++ b/src/plugins/LocalAnime.cpp @@ -336,6 +336,11 @@ namespace QuickMedia { } PluginResult LocalAnimeSearchPage::lazy_fetch(BodyItems &result_items) { + if(fetch_home_page) { + fetch_home_page = false; + anime_items = get_anime_in_directory(get_config().local_anime.directory); + } + std::unordered_map watch_progress = get_watch_progress_for_plugin("local-anime"); const time_t time_now = time(nullptr); diff --git a/src/plugins/NyaaSi.cpp b/src/plugins/NyaaSi.cpp index 739032b..d0bc616 100644 --- a/src/plugins/NyaaSi.cpp +++ b/src/plugins/NyaaSi.cpp @@ -463,6 +463,7 @@ namespace QuickMedia { result_items.push_back(std::move(body_item)); } + html_unescape_sequences(title); result_items.front()->set_title(title); result = quickmedia_html_find_nodes_xpath(&html_search, "//div[id='torrent-description']", @@ -513,7 +514,9 @@ namespace QuickMedia { QuickMediaStringView href = quickmedia_html_node_get_attribute_value(node->node, "href"); QuickMediaStringView text = quickmedia_html_node_get_text(node); if(href.data && text.data && href.size >= 6 && memcmp(href.data, "/user/", 6) == 0) { - auto body_item = BodyItem::create(std::string(text.data, text.size)); + std::string title(text.data, text.size); + html_unescape_sequences(title); + auto body_item = BodyItem::create(std::move(title)); //body_item->url = "https://nyaa.si/" + std::string(href); item_data->push_back(std::move(body_item)); } -- cgit v1.2.3