refactor(pixiv): keep the artwork type as the API's string

TypeModel's Illust and Manga variants existed only so serde would accept
those values -- both call sites ask a single question (is this ugoira?), so
the field is a String and the check is a comparison. Same for a type the API
adds later: it no longer fails the whole parse.
This commit is contained in:
2026-09-21 17:19:26 +08:00
parent 7dd0e8f2d6
commit 7a61077d80
3 changed files with 8 additions and 15 deletions
+2 -2
View File
@@ -4,7 +4,7 @@
//! `app-api.pixiv.net`, deserialized with the kept `model.rs` types.
use super::interface::Illustration;
use super::model::{IllustrationModel, TypeModel, UgoiraMetadataModel};
use super::model::{IllustrationModel, UgoiraMetadataModel};
use crate::media::Media;
use crate::site::FetchError;
use std::env;
@@ -139,7 +139,7 @@ impl PixivAPI {
pub async fn fetch(&self, illust_id: u64) -> Result<Illustration, FetchError> {
let model = self.illust_detail(illust_id).await?;
let mut illustration = Illustration::from_model(&model);
if matches!(&model.r#type, TypeModel::Ugoira) {
if model.r#type == "ugoira" {
// Real ugoira support: download the frame zip and encode an MP4.
// Without ffmpeg the post stays unsupported (empty media, like
// Python) — but a *failed* download/encode is reported instead: