aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Mangadex.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/Mangadex.cpp')
-rw-r--r--src/plugins/Mangadex.cpp15
1 files changed, 9 insertions, 6 deletions
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();