From 7f8ef9f591ce85cfac49b71b5ff2bc8293e0d57c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 2 Oct 2021 03:53:39 +0200 Subject: Mangadex: fix oneshots (without chapter name) not being listed in chapters page --- src/plugins/Mangadex.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/plugins/Mangadex.cpp') diff --git a/src/plugins/Mangadex.cpp b/src/plugins/Mangadex.cpp index a232d65..e57c6cd 100644 --- a/src/plugins/Mangadex.cpp +++ b/src/plugins/Mangadex.cpp @@ -191,7 +191,8 @@ namespace QuickMedia { if(!data_list_json.isArray()) return PluginResult::ERR; - const char *prev_chapter = nullptr; + std::string prev_chapter; + std::string chapter; for(const Json::Value &data_json : data_list_json) { if(!data_json.isObject()) continue; @@ -209,18 +210,20 @@ namespace QuickMedia { continue; const Json::Value &chapter_json = attributes_json["chapter"]; - if(!chapter_json.isString()) - continue; + if(chapter_json.isString()) + chapter = chapter_json.asString(); + else + chapter = "0"; - if(prev_chapter && strcmp(prev_chapter, chapter_json.asCString()) == 0) + if(strcmp(prev_chapter.c_str(), chapter.c_str()) == 0) continue; const Json::Value &hash_json = attributes_json["hash"]; if(!hash_json.isString()) continue; - prev_chapter = chapter_json.asCString(); - std::string title = "Ch. " + chapter_json.asString(); + std::string title = "Ch. " + chapter; + prev_chapter = std::move(chapter); const Json::Value &title_json = attributes_json["title"]; if(title_json.isString() && title_json.asCString()[0] != '\0') title += " - " + title_json.asString(); -- cgit v1.2.3