use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, utoipa::ToSchema)] pub struct SubtitleResponse { pub id: String, pub media_id: String, pub language: Option, pub format: String, pub is_embedded: bool, pub track_index: Option, pub offset_ms: i64, pub created_at: DateTime, } impl From for SubtitleResponse { fn from(s: pinakes_core::subtitles::Subtitle) -> Self { Self { id: s.id.to_string(), media_id: s.media_id.0.to_string(), language: s.language, format: s.format.to_string(), is_embedded: s.is_embedded, track_index: s.track_index, offset_ms: s.offset_ms, created_at: s.created_at, } } } #[derive(Debug, Deserialize, utoipa::ToSchema)] pub struct AddSubtitleRequest { pub language: Option, pub format: String, pub file_path: Option, pub is_embedded: Option, pub track_index: Option, pub offset_ms: Option, } #[derive(Debug, Deserialize, utoipa::ToSchema)] pub struct UpdateSubtitleOffsetRequest { pub offset_ms: i64, } /// Information about an embedded subtitle track available for extraction. #[derive(Debug, Serialize, utoipa::ToSchema)] pub struct SubtitleTrackInfoResponse { pub index: u32, pub language: Option, pub format: String, pub title: Option, } impl From for SubtitleTrackInfoResponse { fn from(t: pinakes_core::subtitles::SubtitleTrackInfo) -> Self { Self { index: t.index, language: t.language, format: t.format.to_string(), title: t.title, } } } /// Response for listing subtitles on a media item. #[derive(Debug, Serialize, utoipa::ToSchema)] pub struct SubtitleListResponse { pub subtitles: Vec, pub available_tracks: Vec, }