Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I30d4b23f09113628dea245404b0a31bd6a6a6964
73 lines
2 KiB
Rust
73 lines
2 KiB
Rust
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<String>,
|
|
pub format: String,
|
|
pub is_embedded: bool,
|
|
pub track_index: Option<u32>,
|
|
pub offset_ms: i64,
|
|
pub created_at: DateTime<Utc>,
|
|
}
|
|
|
|
impl From<pinakes_core::subtitles::Subtitle> 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<String>,
|
|
pub format: String,
|
|
pub file_path: Option<String>,
|
|
pub is_embedded: Option<bool>,
|
|
pub track_index: Option<u32>,
|
|
pub offset_ms: Option<i64>,
|
|
}
|
|
|
|
#[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>,
|
|
}
|