From fdeb82815db468ac7e99e9646f57bed2bf1832de Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 22 Sep 2021 20:10:48 +0200 Subject: Sort anilist recommendations by best match, show episode duration, show titles differently --- src/plugins/AniList.cpp | 25 ++++++++++++++++++------- src/plugins/Manga.cpp | 2 +- src/plugins/MangaCombined.cpp | 12 ++++++------ src/plugins/MyAnimeList.cpp | 8 ++++---- 4 files changed, 29 insertions(+), 18 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/AniList.cpp b/src/plugins/AniList.cpp index 0c7229f..5043eb7 100644 --- a/src/plugins/AniList.cpp +++ b/src/plugins/AniList.cpp @@ -28,6 +28,7 @@ query ($page: Int, $perPage: Int, $search: String) { averageScore episodes chapters + duration genres coverImage { medium @@ -62,6 +63,7 @@ query ($id: Int) { averageScore episodes chapters + duration genres description (asHtml: false) coverImage { @@ -99,6 +101,7 @@ query ($id: Int) { averageScore episodes chapters + duration genres coverImage { medium @@ -117,7 +120,7 @@ query ($id: Int) { static const std::string recommendations_query_graphql = R"END( query ($id: Int, $page: Int, $perPage: Int) { Media (id: $id) { - recommendations (page: $page, perPage: $perPage) { + recommendations (page: $page, perPage: $perPage, sort: RATING_DESC) { nodes { mediaRecommendation { id @@ -137,6 +140,7 @@ query ($id: Int, $page: Int, $perPage: Int) { averageScore episodes chapters + duration genres coverImage { medium @@ -288,6 +292,7 @@ query ($id: Int, $page: Int, $perPage: Int) { const Json::Value &status_json = media_json["status"]; const Json::Value &episodes_json = media_json["episodes"]; const Json::Value &chapters_json = media_json["chapters"]; + const Json::Value &duration_json = media_json["duration"]; const Json::Value &genres_json = media_json["genres"]; const Json::Value &description_json = media_json["description"]; @@ -356,6 +361,12 @@ query ($id: Int, $page: Int, $perPage: Int) { description += "Chapters: " + std::to_string(chapters_json.asInt()); } + if(duration_json.isInt()) { + if(!description.empty()) + description += '\n'; + description += "Episode duration: " + std::to_string(duration_json.asInt()) + " minute" + (duration_json.asInt() == 1 ? "" : "s"); + } + if(status_json.isString()) { if(!description.empty()) description += '\n'; @@ -598,8 +609,8 @@ query ($id: Int, $page: Int, $perPage: Int) { if(it.second.empty()) continue; - auto anime_title_item = BodyItem::create(""); - anime_title_item->set_author("------------------------ " + it.first + " ------------------------"); + auto anime_title_item = BodyItem::create("", false); + anime_title_item->set_author(it.first); result_items.push_back(std::move(anime_title_item)); result_items.insert(result_items.end(), std::move_iterator(it.second.begin()), std::move_iterator(it.second.end())); } @@ -754,15 +765,15 @@ query ($id: Int, $page: Int, $perPage: Int) { } if(!anime_items.empty()) { - auto anime_title_item = BodyItem::create(""); - anime_title_item->set_author("------------------------ Anime ------------------------"); + auto anime_title_item = BodyItem::create("", false); + anime_title_item->set_author("Anime"); result_items.push_back(std::move(anime_title_item)); result_items.insert(result_items.end(), std::move_iterator(anime_items.begin()), std::move_iterator(anime_items.end())); } if(!manga_items.empty()) { - auto manga_title_item = BodyItem::create(""); - manga_title_item->set_author("------------------------ Manga ------------------------"); + auto manga_title_item = BodyItem::create("", false); + manga_title_item->set_author("Manga"); result_items.push_back(std::move(manga_title_item)); result_items.insert(result_items.end(), std::move_iterator(manga_items.begin()), std::move_iterator(manga_items.end())); } diff --git a/src/plugins/Manga.cpp b/src/plugins/Manga.cpp index 1d44bee..5f0aae7 100644 --- a/src/plugins/Manga.cpp +++ b/src/plugins/Manga.cpp @@ -22,7 +22,7 @@ namespace QuickMedia { } std::shared_ptr MangaChaptersPage::get_bookmark_body_item() { - auto body_item = std::make_shared(content_title); + auto body_item = BodyItem::create(content_title); body_item->url = content_url; return body_item; } diff --git a/src/plugins/MangaCombined.cpp b/src/plugins/MangaCombined.cpp index 5440871..c7fdd13 100644 --- a/src/plugins/MangaCombined.cpp +++ b/src/plugins/MangaCombined.cpp @@ -56,8 +56,8 @@ namespace QuickMedia { if(num_finished_plugins == search_threads.size()) { for(auto &f : plugin_finished_state) { if(f.second && !f.second->empty()) { - auto title_item = BodyItem::create(""); - title_item->set_author("------------------------ " + f.first->title + " ------------------------"); + auto title_item = BodyItem::create("", false); + title_item->set_author(f.first->title); result_items.push_back(std::move(title_item)); result_items.insert(result_items.end(), std::move_iterator(f.second->begin()), std::move_iterator(f.second->end())); } @@ -72,14 +72,14 @@ namespace QuickMedia { for(auto &f : plugin_finished_state) { if(f.second) { if(!f.second->empty()) { - auto title_item = BodyItem::create(""); - title_item->set_author("------------------------ " + f.first->title + " ------------------------"); + auto title_item = BodyItem::create("", false); + title_item->set_author(f.first->title); result_items.push_back(std::move(title_item)); result_items.insert(result_items.end(), std::move_iterator(f.second->begin()), std::move_iterator(f.second->end())); } } else { - auto title_item = BodyItem::create(""); - title_item->set_author("------------------------ " + f.first->title + " timed out ------------------------"); + auto title_item = BodyItem::create("", false); + title_item->set_author(f.first->title + " timed out "); result_items.push_back(std::move(title_item)); } } diff --git a/src/plugins/MyAnimeList.cpp b/src/plugins/MyAnimeList.cpp index ceba73a..a4d1d30 100644 --- a/src/plugins/MyAnimeList.cpp +++ b/src/plugins/MyAnimeList.cpp @@ -134,15 +134,15 @@ namespace QuickMedia { } if(!anime_items.empty()) { - auto anime_title_item = BodyItem::create(""); - anime_title_item->set_author("------------------------ Anime ------------------------"); + auto anime_title_item = BodyItem::create("", false); + anime_title_item->set_author("Anime"); result_items.push_back(std::move(anime_title_item)); result_items.insert(result_items.end(), std::move_iterator(anime_items.begin()), std::move_iterator(anime_items.end())); } if(!manga_items.empty()) { - auto manga_title_item = BodyItem::create(""); - manga_title_item->set_author("------------------------ Manga ------------------------"); + auto manga_title_item = BodyItem::create("", false); + manga_title_item->set_author("Manga"); result_items.push_back(std::move(manga_title_item)); result_items.insert(result_items.end(), std::move_iterator(manga_items.begin()), std::move_iterator(manga_items.end())); } -- cgit v1.2.3