pinakes-server: add utoipa annotations; manage embedded subtitle data

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I30d4b23f09113628dea245404b0a31bd6a6a6964
This commit is contained in:
raf 2026-03-21 02:16:07 +03:00
commit 67b8322705
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF

View file

@ -1,14 +1,14 @@
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize)]
#[derive(Debug, Serialize, utoipa::ToSchema)]
pub struct SubtitleResponse {
pub id: String,
pub media_id: String,
pub language: Option<String>,
pub format: String,
pub is_embedded: bool,
pub track_index: Option<usize>,
pub track_index: Option<u32>,
pub offset_ms: i64,
pub created_at: DateTime<Utc>,
}
@ -28,17 +28,46 @@ impl From<pinakes_core::subtitles::Subtitle> for SubtitleResponse {
}
}
#[derive(Debug, Deserialize)]
#[derive(Debug, Deserialize, utoipa::ToSchema)]
pub struct AddSubtitleRequest {
pub language: Option<String>,
pub format: String,
pub file_path: Option<String>,
pub is_embedded: Option<bool>,
pub track_index: Option<usize>,
pub track_index: Option<u32>,
pub offset_ms: Option<i64>,
}
#[derive(Debug, Deserialize)]
#[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<String>,
pub format: String,
pub title: Option<String>,
}
impl From<pinakes_core::subtitles::SubtitleTrackInfo>
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<SubtitleResponse>,
pub available_tracks: Vec<SubtitleTrackInfoResponse>,
}