- Add runtime field to Movie model and display formatted duration (e.g., 2h 22min) on movie cards - Add bulk "Refresh OMDb" button in admin panel for selected movies - Add runtime field to movie edit modal in admin panel - Implement first-time setup flow: show admin creation form on login page when no admin exists - Block registration page until initial setup is complete Co-Authored-By: Claude Opus 4.5 <[email protected]>
51 lines
2.5 KiB
JavaScript
51 lines
2.5 KiB
JavaScript
const mongoose = require("mongoose");
|
|
|
|
const movieSchema = new mongoose.Schema({
|
|
imdb_id: { type: String, required: true },
|
|
title: { type: String, required: false },
|
|
description: { type: String, required: false },
|
|
rating: { type: String, required: false },
|
|
runtime: { type: String, required: false },
|
|
poster: { type: String, required: false },
|
|
cam: { type: Boolean, required: false, default: false },
|
|
// Oscar pool year / edition (used to segment movies + stats)
|
|
year: { type: Number, required: false, index: true },
|
|
category: { type: String, required: true },
|
|
// Legacy "one field" player source.
|
|
// Kept for backwards-compat. New UI prefers video_src / embed_src.
|
|
vod_link: { type: String, required: false },
|
|
|
|
// Player configuration (optional; used by player.html)
|
|
player_mode: { type: String, required: false, enum: ["auto", "video", "embed"], default: "auto" },
|
|
video_src: { type: String, required: false }, // direct video file URL or HLS (.m3u8)
|
|
embed_src: { type: String, required: false }, // URL or iframe code
|
|
// Server-hosted file (relative path under VIDEO_FILES_DIR, default public/video)
|
|
// If set, the backend can stream it via /api/video/:movieId (Range/seek supported).
|
|
video_file: { type: String, required: false },
|
|
// Optional low-quality server file (relative path under VIDEO_FILES_DIR, default public/video)
|
|
// Served when the player requests ?quality=low on /api/video/:movieId.
|
|
video_file_low: { type: String, required: false },
|
|
// Optional subtitles (server-hosted .vtt, streamed via /api/subtitles/:movieId/:subtitleId)
|
|
subtitles: [{
|
|
file: { type: String, required: true },
|
|
lang: { type: String, required: false },
|
|
label: { type: String, required: false },
|
|
default: { type: Boolean, required: false, default: false },
|
|
}],
|
|
// Legacy single-subtitle fields (kept for backward compatibility)
|
|
subtitle_file: { type: String, required: false },
|
|
subtitle_lang: { type: String, required: false },
|
|
subtitle_label: { type: String, required: false },
|
|
subtitle_default: { type: Boolean, required: false, default: false },
|
|
watchedBy: [{ type: mongoose.Schema.Types.ObjectId, ref: 'User' }]
|
|
}, { timestamps: true });
|
|
|
|
// Common read patterns:
|
|
// - list movies for a year, sorted by title
|
|
// - check "last update" per year (sort by updatedAt)
|
|
movieSchema.index({ year: 1, title: 1 });
|
|
movieSchema.index({ year: 1, updatedAt: -1 });
|
|
movieSchema.index({ year: 1, imdb_id: 1 });
|
|
|
|
module.exports = mongoose.model("Movie", movieSchema);
|