mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 17:46:06 +00:00
feat(player): let editors upload subtitles for a version
Subtitle tracks hang off a version rather than off a video, because re-editing a cut shifts every cue. The file always lands in our own S3-compatible storage whatever hosts the video, so a Bunny-hosted cut and an R2 one take the same path: both already play through our own video element, so a track element is all it takes. Uploads are normalised before they are stored. Whatever arrives, SRT or WebVTT, is parsed into cues and re-serialised as a canonical WebVTT file, and anything we did not understand is dropped rather than passed through. That is what makes it safe to serve a user-supplied text file from our own origin. Files saved out of Windows editors are decoded as windows-1254 or windows-1252 when they are not valid UTF-8, rather than refused. A YouTube version cannot carry an uploaded track, so the same CC menu drives YouTube's own captions through the iframe module API. The embed hides YouTube's controls, so until now those captions were unreachable even when the video had them. Uploading and deleting take the editor permission rather than the commenter one: a subtitle is part of the delivered cut, not a comment attachment.
This commit is contained in:
@@ -42,6 +42,8 @@ model User {
|
||||
comments Comment[]
|
||||
uploadedVideoAssets VideoAsset[] @relation("VideoAssetUploadedBy")
|
||||
billedVideoAssets VideoAsset[] @relation("VideoAssetBilledTo")
|
||||
uploadedVideoSubtitles VideoSubtitle[] @relation("VideoSubtitleUploadedBy")
|
||||
billedVideoSubtitles VideoSubtitle[] @relation("VideoSubtitleBilledTo")
|
||||
projectMemberships ProjectMember[]
|
||||
notificationSetting NotificationSetting?
|
||||
watchProgress WatchProgress[]
|
||||
@@ -383,6 +385,7 @@ model VideoVersion {
|
||||
comments Comment[]
|
||||
watchProgress WatchProgress[]
|
||||
approvalRequests ApprovalRequest[]
|
||||
subtitles VideoSubtitle[]
|
||||
|
||||
@@unique([videoParentId, versionNumber])
|
||||
@@index([videoParentId])
|
||||
@@ -418,6 +421,34 @@ model VideoAsset {
|
||||
@@map("video_assets")
|
||||
}
|
||||
|
||||
/// A subtitle track for one cut. Timings belong to a version rather than to the
|
||||
/// video: re-editing shifts every cue, so a track attached to the parent would be
|
||||
/// wrong for every version but the one it was written against.
|
||||
model VideoSubtitle {
|
||||
id String @id @default(cuid())
|
||||
versionId String
|
||||
version VideoVersion @relation(fields: [versionId], references: [id], onDelete: Cascade)
|
||||
/// BCP-47 tag, lowercased primary subtag, e.g. `tr`, `en-US`.
|
||||
language String
|
||||
label String
|
||||
/// Always an /api/upload/subtitle/<uuid>.vtt path. The file itself lives in
|
||||
/// S3-compatible storage whatever the video's own provider is, so a Bunny-hosted
|
||||
/// video and an R2-hosted one take the same path through the player.
|
||||
sourceUrl String @unique
|
||||
sizeBytes BigInt @default(0) @map("size_bytes")
|
||||
billedUserId String
|
||||
billedUser User @relation("VideoSubtitleBilledTo", fields: [billedUserId], references: [id], onDelete: Cascade)
|
||||
uploadedByUserId String?
|
||||
uploadedByUser User? @relation("VideoSubtitleUploadedBy", fields: [uploadedByUserId], references: [id], onDelete: SetNull)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([versionId, language])
|
||||
@@index([versionId])
|
||||
@@index([billedUserId])
|
||||
@@map("video_subtitles")
|
||||
}
|
||||
|
||||
model Comment {
|
||||
id String @id @default(cuid())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user