aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-10-04 15:42:14 +0200
committerdec05eba <dec05eba@protonmail.com>2023-10-04 15:42:14 +0200
commit9031927b15cc487693dc14f9398c7fdba54cfe07 (patch)
tree342b31cfbc1cd1e802671bccaa991664d0efb4aa
parentb32e4f18a26aaeb28f66b17102d070908c804a23 (diff)
Anilist better studios/producers formatting
-rw-r--r--src/plugins/AniList.cpp28
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));
}
}