Compare commits
2 Commits
421bbcd6a0
...
9259f7c198
Author | SHA1 | Date |
---|---|---|
|
9259f7c198 | |
|
8de4af2972 |
|
@ -92,7 +92,9 @@ void from_json(const nlohmann::json& j, Illust& illust) {
|
|||
bool full_data = j.contains("illust_details");
|
||||
const nlohmann::json& author_details = j.at("author_details");
|
||||
const nlohmann::json& illust_details = full_data ? j.at("illust_details") : j;
|
||||
const nlohmann::json& images_metadata = illust_details.at("illust_images");
|
||||
std::optional<nlohmann::json> images_metadata = illust_details.contains("illust_images")
|
||||
? std::optional(illust_details["illust_images"])
|
||||
: std::nullopt;
|
||||
|
||||
author_details.at("user_account").get_to(illust.username);
|
||||
author_details.at("user_name").get_to(illust.user_display_name);
|
||||
|
@ -118,10 +120,10 @@ void from_json(const nlohmann::json& j, Illust& illust) {
|
|||
illust.images.reserve(manga_a.size());
|
||||
|
||||
for (size_t i = 0; i < manga_a.size(); i++) {
|
||||
illust.images.push_back(get_illust_images(manga_a[i], images_metadata.at(i)));
|
||||
illust.images.push_back(get_illust_images(manga_a[i], images_metadata ? std::optional(images_metadata->at(i)) : std::nullopt));
|
||||
}
|
||||
} else {
|
||||
illust.images = {get_illust_images(illust_details, images_metadata.at(0))};
|
||||
illust.images = {get_illust_images(illust_details, images_metadata ? std::optional(images_metadata->at(0)) : std::nullopt)};
|
||||
}
|
||||
illust.page_count = to_ull(illust_details.at("page_count").get_ref<const nlohmann::json::string_t&>());
|
||||
}
|
||||
|
|
|
@ -125,17 +125,25 @@ static inline std::vector<blankie::html::Node> parse_description_line(const http
|
|||
std::smatch sm;
|
||||
|
||||
while (std::regex_search(str, sm, blankie::murl::full_url_regex)) {
|
||||
if (sm.prefix().length()) {
|
||||
nodes.push_back(sm.prefix());
|
||||
std::string prefix = sm.prefix();
|
||||
std::string url_str = sm.str(0);
|
||||
std::string suffix = sm.suffix();
|
||||
|
||||
if (prefix.ends_with('(') && url_str.ends_with(')')) {
|
||||
url_str.pop_back();
|
||||
suffix.insert(0, 1, ')');
|
||||
}
|
||||
if (!prefix.empty()) {
|
||||
nodes.push_back(std::move(prefix));
|
||||
}
|
||||
|
||||
blankie::murl::Url url(sm.str(0));
|
||||
std::string url_str = url.is_host_equal("pixiv.net") || url.is_host_equal("www.pixiv.net")
|
||||
blankie::murl::Url url(std::move(url_str));
|
||||
url_str = url.is_host_equal("pixiv.net") || url.is_host_equal("www.pixiv.net")
|
||||
? proxy_pixiv_url(req, config, std::move(url))
|
||||
: url.to_string();
|
||||
nodes.push_back(Element("a", {{"href", url_str}}, {url_str}));
|
||||
|
||||
str = sm.suffix();
|
||||
str = std::move(suffix);
|
||||
}
|
||||
if (!str.empty()) {
|
||||
nodes.push_back(std::move(str));
|
||||
|
|
Loading…
Reference in New Issue