diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/AniList.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/plugins/AniList.cpp b/src/plugins/AniList.cpp index 50b1a86..fb23ab6 100644 --- a/src/plugins/AniList.cpp +++ b/src/plugins/AniList.cpp @@ -290,7 +290,17 @@ query ($id: Int, $page: Int, $perPage: Int) { return {0, 0}; } - static void get_studios_and_producers(const Json::Value &nodes_json, std::string &studios, std::string &producers) { + static std::string string_vector_comma_separate(const std::vector<std::string> &vec) { + std::string result; + for(const std::string &item : vec) { + if(!result.empty()) + result += ", "; + result += item; + } + return result; + } + + static void get_studios_and_producers(const Json::Value &nodes_json, std::vector<std::string> &studios, std::vector<std::string> &producers) { if(!nodes_json.isArray()) return; @@ -304,13 +314,9 @@ query ($id: Int, $page: Int, $perPage: Int) { continue; if(is_animation_studio_json.asBool()) { - if(!studios.empty()) - studios += "\n"; - studios += name_json.asString(); + studios.push_back(name_json.asString()); } else { - if(!producers.empty()) - producers += "\n"; - producers += name_json.asString(); + producers.push_back(name_json.asString()); } } } @@ -419,22 +425,22 @@ query ($id: Int, $page: Int, $perPage: Int) { } if(studios_json.isObject()) { - std::string studios; - std::string producers; + std::vector<std::string> studios; + std::vector<std::string> producers; get_studios_and_producers(studios_json["nodes"], studios, producers); if(!studios.empty()) { if(!description.empty()) description += "\n\n"; description += "Studios:\n"; - description.append(studios); + description.append(string_vector_comma_separate(studios)); } if(!producers.empty()) { if(!description.empty()) description += "\n\n"; description += "Producers:\n"; - description.append(producers); + description.append(string_vector_comma_separate(producers)); } } |