feat(subtitles): 补字幕第 1 步——上传字幕 / zip,识别语言与季集,配对写入视频同目录,历史与撤销
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
feee481915
commit
ef29bd62ce
22 files changed
+1554
-2
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import type { Kysely } from "kysely";
|
||||
import { execDdl } from "../src/migration-helpers.ts";
|
||||
|
||||
// 补字幕(docs/plan/subtitles.md):每次写入一个字幕文件记一行,撤销时删文件、有备份就还原。
|
||||
// 写入的字幕同时登记为 media_asset(kind = subtitle)+ asset_location(sidecar_of_location_id 指向视频位置)。
|
||||
// biome-ignore lint/suspicious/noExplicitAny: 迁移不依赖应用表类型
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await execDdl(
|
||||
db,
|
||||
`create table if not exists subtitle_write (
|
||||
id uuid primary key default gen_random_uuid(),
|
||||
media_entity_id uuid not null references media_entity (id) on delete cascade,
|
||||
video_location_id uuid references asset_location (id) on delete set null,
|
||||
subtitle_asset_id uuid references media_asset (id) on delete set null,
|
||||
library_root_id uuid not null references library_root (id) on delete cascade,
|
||||
relative_path text not null,
|
||||
language text not null,
|
||||
source text not null check (source in ('upload', 'subhd', 'zimuku')),
|
||||
source_name text not null,
|
||||
source_ref text,
|
||||
backup_path text,
|
||||
actor text,
|
||||
created_at timestamptz not null default now(),
|
||||
undone_at timestamptz
|
||||
);
|
||||
create index if not exists subtitle_write_entity on subtitle_write (media_entity_id, created_at desc);`,
|
||||
);
|
||||
}
|
||||
// biome-ignore lint/suspicious/noExplicitAny: 同上
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await execDdl(db, "drop table if exists subtitle_write;");
|
||||
}
|
||||
@@ -257,6 +257,7 @@ export type SubscriptionSeasonScope = "current_season" | "following_seasons";
|
||||
export type SubscriptionOrigin = "user" | "agent" | "policy" | "import";
|
||||
export type SubscriptionPriority = "immediate" | "tracking" | "new_work" | "upgrade";
|
||||
export type SubscriptionStatus = "active" | "paused" | "pending" | "completed" | "cancelled";
|
||||
export type SubtitleWriteSource = "upload" | "subhd" | "zimuku";
|
||||
export type TaskStatus = "pending" | "running" | "waiting" | "succeeded" | "failed" | "cancelled" | "dead";
|
||||
export type TasksOpLedgerStatus = "started" | "succeeded";
|
||||
export type TitleAliasKind = "original" | "translated" | "short" | "site_title" | "romanized" | "other";
|
||||
@@ -1603,6 +1604,23 @@ export interface SubscriptionHistoryTable {
|
||||
updated_at: GeneratedTimestamptz;
|
||||
}
|
||||
|
||||
export interface SubtitleWriteTable {
|
||||
id: Generated<string>;
|
||||
media_entity_id: string;
|
||||
video_location_id: string | null;
|
||||
subtitle_asset_id: string | null;
|
||||
library_root_id: string;
|
||||
relative_path: string;
|
||||
language: string;
|
||||
source: SubtitleWriteSource;
|
||||
source_name: string;
|
||||
source_ref: string | null;
|
||||
backup_path: string | null;
|
||||
actor: string | null;
|
||||
created_at: GeneratedTimestamptz;
|
||||
undone_at: Timestamptz | null;
|
||||
}
|
||||
|
||||
export interface TaskTable {
|
||||
id: Generated<string>;
|
||||
kind: string;
|
||||
@@ -1781,6 +1799,7 @@ export interface DB {
|
||||
sse_event: SseEventTable;
|
||||
subscription: SubscriptionTable;
|
||||
subscription_history: SubscriptionHistoryTable;
|
||||
subtitle_write: SubtitleWriteTable;
|
||||
task: TaskTable;
|
||||
tasks_fact: TasksFactTable;
|
||||
tasks_op_ledger: TasksOpLedgerTable;
|
||||
@@ -2021,6 +2040,9 @@ export type SubscriptionUpdate = Updateable<SubscriptionTable>;
|
||||
export type SubscriptionHistoryRow = Selectable<SubscriptionHistoryTable>;
|
||||
export type NewSubscriptionHistory = Insertable<SubscriptionHistoryTable>;
|
||||
export type SubscriptionHistoryUpdate = Updateable<SubscriptionHistoryTable>;
|
||||
export type SubtitleWriteRow = Selectable<SubtitleWriteTable>;
|
||||
export type NewSubtitleWrite = Insertable<SubtitleWriteTable>;
|
||||
export type SubtitleWriteUpdate = Updateable<SubtitleWriteTable>;
|
||||
export type TaskRow = Selectable<TaskTable>;
|
||||
export type NewTask = Insertable<TaskTable>;
|
||||
export type TaskUpdate = Updateable<TaskTable>;
|
||||
|
||||
Reference in new issue
Block a user