mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-09-26 23:52:05 +00:00
`Fetched.title` carried whatever text the platform had — a tweet's body,
a bilibili dynamic's body, a pixiv artwork's title — which was enough
while x/twitter (no title at all) set the shape. The platforms actually
disagree: pixiv has a title *and* a description, bilibili has an opus
headline *and* a body. Posts now carry both:
- `title`: the platform's title (a pixiv artwork title, a bilibili opus
headline or video card title), empty on text-only platforms;
- `content`: the body (tweet / bsky / misskey text, bilibili dynamic
body, and pixiv's description — fetched for the first time here and
flattened from the app API's HTML to plain text).
`{content}` joins the caption-format placeholders, so a custom
`/set_format` can include a pixiv description. The built-in captions keep
producing byte-identical output: `compose_text` joins the two fields the
same way the single field already was, and bilibili's forward marker
(`//@author:`) now lands in `content` behind the head line's `title`.
`CachedPost.content` is `#[serde(default)]`, so link-cache entries and
queued task payloads written before the split still parse, their text
living in `title`.
84 lines
2.0 KiB
Rust
84 lines
2.0 KiB
Rust
// Model set for the native pixiv app-API client (app-api.pixiv.net).
|
|
|
|
use serde::Deserialize;
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
pub struct IllustrationModel {
|
|
pub id: u64,
|
|
pub title: String,
|
|
/// The artwork's description as the app API returns it — HTML in most
|
|
/// works (`<br />`, `<a href>`, sometimes `<p>`), empty for many.
|
|
#[serde(default)]
|
|
pub caption: String,
|
|
pub r#type: TypeModel,
|
|
pub image_urls: ImageUrlsModel,
|
|
pub user: UserInfoModel,
|
|
pub tags: Vec<IllustrationTagModel>,
|
|
pub page_count: u8,
|
|
pub sanity_level: u8,
|
|
/// 0 = undefined (unlabeled), 1 = not AI, 2 = AI-generated.
|
|
pub illust_ai_type: i32,
|
|
pub meta_single_page: MetaSinglePageModel,
|
|
pub meta_pages: Vec<MetaPageModel>,
|
|
}
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
pub enum TypeModel {
|
|
#[serde(rename = "illust")]
|
|
Illust,
|
|
#[serde(rename = "manga")]
|
|
Manga,
|
|
#[serde(rename = "ugoira")]
|
|
Ugoira,
|
|
}
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
pub struct UserInfoModel {
|
|
pub id: u64,
|
|
pub name: String,
|
|
}
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
pub struct ImageUrlsModel {
|
|
pub medium: String,
|
|
pub large: String,
|
|
#[serde(default)]
|
|
pub original: Option<String>,
|
|
}
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
pub struct IllustrationTagModel {
|
|
pub name: String,
|
|
}
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
pub struct MetaSinglePageModel {
|
|
#[serde(default)]
|
|
pub original_image_url: Option<String>,
|
|
}
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
pub struct MetaPageModel {
|
|
pub image_urls: ImageUrlsModel,
|
|
}
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
pub struct UgoiraMetadataModel {
|
|
/// Older API shape (`zip_url`); newer responses use `zip_urls.medium`.
|
|
#[serde(default)]
|
|
pub zip_url: Option<String>,
|
|
#[serde(default)]
|
|
pub zip_urls: Option<UgoiraZipUrlsModel>,
|
|
pub frames: Vec<UgoiraFrameModel>,
|
|
}
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
pub struct UgoiraZipUrlsModel {
|
|
pub medium: String,
|
|
}
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
pub struct UgoiraFrameModel {
|
|
pub delay: u32,
|
|
}
|