Skip to main content

tango_core/entities/
chapter.rs

1use sea_orm::entity::prelude::*;
2use serde::{Deserialize, Serialize};
3
4/// One chapter of one video, as yt-dlp reported it.
5///
6/// `chapter_index` is the position in the video after the chapters are sorted by
7/// start time and renumbered, so it is contiguous from zero and the primary key
8/// `(video_id, chapter_index)` is stable for a given payload. A re-fetch is a
9/// replacement, not a merge: YouTube can re-cut a video's chapters, and stale
10/// rows from the old list would otherwise linger.
11#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
12#[sea_orm(table_name = "video_chapters")]
13pub struct Model {
14    #[sea_orm(primary_key, auto_increment = false)]
15    pub video_id: String,
16    #[sea_orm(primary_key, auto_increment = false)]
17    pub chapter_index: i32,
18    pub start_ms: i32,
19    pub end_ms: i32,
20    pub title: String,
21    pub updated_at: DateTimeWithTimeZone,
22}
23
24#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
25pub enum Relation {}
26
27impl ActiveModelBehavior for ActiveModel {}