Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c6023cc52 | ||
|
|
67c828838d | ||
|
|
cd2c135c65 | ||
|
|
f88dfdae44 | ||
|
|
6d4c3e185a | ||
|
|
834e02e76b | ||
|
|
c74e54bc2a | ||
|
|
72600cbc5d | ||
|
|
a9e4eea856 | ||
|
|
eb3a12f6cb |
No files matched your search
@@ -12,6 +12,7 @@ environment.ts
|
||||
circular-dependencies.png
|
||||
.agents/skills
|
||||
auto_puller.py
|
||||
/brain
|
||||
|
||||
# Compiled output
|
||||
.angular
|
||||
|
||||
@@ -11,33 +11,6 @@ You can get project context from the following files:
|
||||
|
||||
## Mandatory Task Completion Rule
|
||||
|
||||
#### Update the `changes.md` file after completing any task requested by the user.
|
||||
|
||||
After completing ANY task requested by the user, you MUST update the file `changes.md`.
|
||||
Append a new section at the end of `changes.md` using this exact format:
|
||||
|
||||
```md
|
||||
### Milestone XXX
|
||||
|
||||
#### Backend Changes
|
||||
|
||||
- <change 1>
|
||||
- <change 2>
|
||||
- <change 3>
|
||||
|
||||
#### Frontend Changes
|
||||
```
|
||||
|
||||
#### Rules
|
||||
|
||||
- Always ask the user if this is a new milestone or if you should continue appending to the current milestone.
|
||||
- Replace `XXX` with the task number provided by the user (example: `025`).
|
||||
- The bullet list must include all important modifications made.
|
||||
- Do NOT overwrite previous entries: always APPEND.
|
||||
- If `changes.md` does not exist, create it.
|
||||
- If no task number is provided, use the next available number based on the last entry in the file.
|
||||
- Always ensure formatting matches exactly (heading + code block + bullets).
|
||||
|
||||
### Documentation (Skip the legacy docs, we're using obsidian docs-vault now)
|
||||
|
||||
Update the `/backend/docs` and `/react_frontend/docs` folders with any relevant documentation changes related to the task you completed. This includes API documentation, architectural diagrams, or any other relevant docs.
|
||||
|
||||
@@ -19,6 +19,8 @@ const Credit = require('../models/Credit');
|
||||
const WatchBuddy = require('../models/WatchBuddy');
|
||||
const EntrySeenBuddy = require('../models/EntrySeenBuddy');
|
||||
const EpisodeSeenBuddy = require('../models/EpisodeSeenBuddy');
|
||||
const Video = require('../models/Video');
|
||||
const VideoEntry = require('../models/VideoEntry');
|
||||
|
||||
// ? one to one
|
||||
// A hasOne B = A > B
|
||||
@@ -289,3 +291,20 @@ WatchBuddy.belongsToMany(EpisodeSeen, {
|
||||
otherKey: 'episode_seen_id',
|
||||
as: 'episodeSeens',
|
||||
});
|
||||
|
||||
// * VIDEO & ENTRY - MANY TO MANY (discovery videos)
|
||||
Video.belongsToMany(Entry, {
|
||||
through: VideoEntry,
|
||||
foreignKey: 'video_id',
|
||||
otherKey: 'entry_id',
|
||||
onDelete: 'CASCADE',
|
||||
as: 'entries',
|
||||
});
|
||||
|
||||
Entry.belongsToMany(Video, {
|
||||
through: VideoEntry,
|
||||
foreignKey: 'entry_id',
|
||||
otherKey: 'video_id',
|
||||
onDelete: 'CASCADE',
|
||||
as: 'videos',
|
||||
});
|
||||
@@ -0,0 +1,280 @@
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
|
||||
const sequelize = require("../config/database");
|
||||
const Video = require("../models/Video");
|
||||
const VideoEntry = require("../models/VideoEntry");
|
||||
const Entry = require("../models/Entry");
|
||||
|
||||
const configService = require("../services/configService.js");
|
||||
const asyncWrapper = require("../utils/asyncWrapper");
|
||||
const videoThumbnailService = require("../services/videoThumbnailService");
|
||||
|
||||
const ALLOWED_EXTENSIONS = ["mp4", "webm", "mov", "m4v", "mkv", "avi"];
|
||||
|
||||
function parseEntryIds(raw) {
|
||||
if (raw === undefined || raw === null || raw === "") return [];
|
||||
let parsed;
|
||||
try {
|
||||
parsed = typeof raw === "string" ? JSON.parse(raw) : raw;
|
||||
} catch (err) {
|
||||
return null; // signal invalid input to the caller
|
||||
}
|
||||
if (!Array.isArray(parsed)) return null;
|
||||
const ids = [...new Set(parsed.map(Number))].filter(
|
||||
(n) => Number.isInteger(n) && n > 0,
|
||||
);
|
||||
return ids;
|
||||
}
|
||||
|
||||
function getVideosDir() {
|
||||
const dataPath = configService.getSettings().userDataPath;
|
||||
return path.join(dataPath, "videos");
|
||||
}
|
||||
|
||||
async function removeFileQuietly(filePath) {
|
||||
try {
|
||||
await fs.promises.unlink(filePath);
|
||||
} catch (err) {
|
||||
// file already gone — nothing to clean up
|
||||
}
|
||||
}
|
||||
|
||||
class VideoController {
|
||||
constructor() {
|
||||
if (!VideoController.instance) {
|
||||
VideoController.instance = this;
|
||||
}
|
||||
return VideoController.instance;
|
||||
}
|
||||
|
||||
// * GET /discovery-videos?page=1&limit=24
|
||||
getVideos = asyncWrapper(async (req, res) => {
|
||||
const page = Math.max(parseInt(req.query.page, 10) || 1, 1);
|
||||
const limit = Math.min(
|
||||
Math.max(parseInt(req.query.limit, 10) || 24, 1),
|
||||
100,
|
||||
);
|
||||
|
||||
const { count, rows } = await Video.findAndCountAll({
|
||||
limit,
|
||||
offset: (page - 1) * limit,
|
||||
order: [["createdAt", "DESC"]],
|
||||
distinct: true,
|
||||
include: [
|
||||
{
|
||||
model: Entry,
|
||||
as: "entries",
|
||||
attributes: ["id", "title", "poster_path", "is_tvseries"],
|
||||
through: { attributes: [] },
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
res.status(200).json({
|
||||
videos: rows,
|
||||
page,
|
||||
limit,
|
||||
total: count,
|
||||
totalPages: Math.ceil(count / limit),
|
||||
});
|
||||
});
|
||||
|
||||
// * POST /discovery-videos (multipart: videos[], description, entryIds)
|
||||
uploadVideos = asyncWrapper(async (req, res) => {
|
||||
const files = req.files;
|
||||
if (!files || files.length === 0) {
|
||||
return res.status(400).json({ message: "No files uploaded" });
|
||||
}
|
||||
|
||||
const entryIds = parseEntryIds(req.body.entryIds);
|
||||
if (entryIds === null) {
|
||||
await Promise.all(
|
||||
files.map((file) =>
|
||||
removeFileQuietly(path.join(getVideosDir(), file.filename)),
|
||||
),
|
||||
);
|
||||
return res.status(400).json({ message: "entryIds must be a JSON array" });
|
||||
}
|
||||
|
||||
const invalidFile = files.find((file) => {
|
||||
const ext = file.originalname.split(".").pop().toLowerCase();
|
||||
return !ALLOWED_EXTENSIONS.includes(ext);
|
||||
});
|
||||
if (invalidFile) {
|
||||
await Promise.all(
|
||||
files.map((file) =>
|
||||
removeFileQuietly(path.join(getVideosDir(), file.filename)),
|
||||
),
|
||||
);
|
||||
return res.status(400).json({
|
||||
message: `Unsupported file type. Allowed: ${ALLOWED_EXTENSIONS.join(", ")}`,
|
||||
});
|
||||
}
|
||||
|
||||
const description =
|
||||
typeof req.body.description === "string" ? req.body.description : "";
|
||||
|
||||
const createdVideos = [];
|
||||
for (const file of files) {
|
||||
const title =
|
||||
file.originalname.replace(/\.[^.]+$/, "").trim() || "Untitled video";
|
||||
|
||||
const video = await Video.create({
|
||||
title,
|
||||
description,
|
||||
filename: file.filename,
|
||||
original_name: file.originalname,
|
||||
mime_type: file.mimetype,
|
||||
size: file.size,
|
||||
});
|
||||
|
||||
if (entryIds.length > 0) {
|
||||
await VideoEntry.bulkCreate(
|
||||
entryIds.map((entryId) => ({
|
||||
video_id: video.id,
|
||||
entry_id: entryId,
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
createdVideos.push(video);
|
||||
}
|
||||
|
||||
return res.status(200).json(createdVideos);
|
||||
});
|
||||
|
||||
// * PUT /discovery-videos/:id (title, description, entryIds)
|
||||
updateVideo = asyncWrapper(async (req, res) => {
|
||||
const video = await Video.findByPk(req.params.id);
|
||||
if (!video) {
|
||||
return res.status(404).json({ message: "Video not found" });
|
||||
}
|
||||
|
||||
const { title, description, entryIds } = req.body;
|
||||
|
||||
if (title !== undefined && typeof title === "string") {
|
||||
video.title = title.trim() || video.title;
|
||||
}
|
||||
if (description !== undefined && typeof description === "string") {
|
||||
video.description = description;
|
||||
}
|
||||
|
||||
let parsedEntryIds;
|
||||
if (entryIds !== undefined) {
|
||||
parsedEntryIds = parseEntryIds(entryIds);
|
||||
if (parsedEntryIds === null) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ message: "entryIds must be a JSON array" });
|
||||
}
|
||||
}
|
||||
|
||||
await sequelize.transaction(async (t) => {
|
||||
await video.save({ transaction: t });
|
||||
if (parsedEntryIds !== undefined) {
|
||||
await VideoEntry.destroy({
|
||||
where: { video_id: video.id },
|
||||
transaction: t,
|
||||
});
|
||||
if (parsedEntryIds.length > 0) {
|
||||
await VideoEntry.bulkCreate(
|
||||
parsedEntryIds.map((entryId) => ({
|
||||
video_id: video.id,
|
||||
entry_id: entryId,
|
||||
})),
|
||||
{ transaction: t },
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const updated = await Video.findByPk(video.id, {
|
||||
include: [
|
||||
{
|
||||
model: Entry,
|
||||
as: "entries",
|
||||
attributes: ["id", "title", "poster_path", "is_tvseries"],
|
||||
through: { attributes: [] },
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
return res.status(200).json(updated);
|
||||
});
|
||||
|
||||
// * DELETE /discovery-videos/:id
|
||||
deleteVideo = asyncWrapper(async (req, res) => {
|
||||
const video = await Video.findByPk(req.params.id);
|
||||
if (!video) {
|
||||
return res.status(404).json({ message: "Video not found" });
|
||||
}
|
||||
|
||||
await VideoEntry.destroy({ where: { video_id: video.id } });
|
||||
await video.destroy();
|
||||
|
||||
// Remove the video file and its thumbnail. The thumbnail filename is
|
||||
// derived from the video filename, so delete it even if the DB row
|
||||
// never had thumbnail_path set (e.g. a failed update).
|
||||
await removeFileQuietly(path.join(getVideosDir(), video.filename));
|
||||
const thumbnailNames = new Set([
|
||||
`${video.filename.split(".")[0]}.jpg`,
|
||||
...(video.thumbnail_path ? [video.thumbnail_path] : []),
|
||||
]);
|
||||
for (const name of thumbnailNames) {
|
||||
await removeFileQuietly(path.join(getVideosDir(), "thumbnails", name));
|
||||
}
|
||||
|
||||
return res.status(200).json({ message: "Video deleted" });
|
||||
});
|
||||
|
||||
// * GET /discovery-videos/:id/thumbnail
|
||||
// Serves the thumbnail image. If none exists yet, generates it on
|
||||
// demand (deduped + concurrency-limited inside the service) and
|
||||
// serves it in the same response.
|
||||
getThumbnail = asyncWrapper(async (req, res) => {
|
||||
const video = await Video.findByPk(req.params.id);
|
||||
if (!video) {
|
||||
return res.status(404).json({ message: "Video not found" });
|
||||
}
|
||||
|
||||
const thumbDir = path.join(getVideosDir(), "thumbnails");
|
||||
const thumbName =
|
||||
video.thumbnail_path || `${video.filename.split(".")[0]}.jpg`;
|
||||
let filePath = path.join(thumbDir, thumbName);
|
||||
|
||||
if (!fs.existsSync(filePath)) {
|
||||
const generated = await videoThumbnailService.ensureThumbnail(video);
|
||||
if (generated) {
|
||||
filePath = path.join(thumbDir, generated);
|
||||
}
|
||||
}
|
||||
|
||||
if (!fs.existsSync(filePath)) {
|
||||
return res.status(404).json({ message: "Thumbnail not available" });
|
||||
}
|
||||
|
||||
res.sendFile(filePath, (err) => {
|
||||
if (err && !res.headersSent) {
|
||||
res.status(404).json({ message: "Thumbnail not available" });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// * GET /discovery-videos/:id/stream (supports HTTP Range via res.sendFile)
|
||||
streamVideo = asyncWrapper(async (req, res) => {
|
||||
const video = await Video.findByPk(req.params.id);
|
||||
if (!video) {
|
||||
return res.status(404).json({ message: "Video not found" });
|
||||
}
|
||||
|
||||
const filePath = path.join(getVideosDir(), video.filename);
|
||||
res.sendFile(filePath, (err) => {
|
||||
if (err && !res.headersSent) {
|
||||
res.status(404).json({ message: "Video file not found" });
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = new VideoController();
|
||||
@@ -0,0 +1,23 @@
|
||||
const { DataTypes } = require("sequelize");
|
||||
const sequelize = require("../config/database");
|
||||
|
||||
const Video = sequelize.define("video", {
|
||||
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
||||
|
||||
title: { type: DataTypes.STRING(500) },
|
||||
description: { type: DataTypes.TEXT, allowNull: true },
|
||||
|
||||
filename: { type: DataTypes.STRING(200) },
|
||||
original_name: { type: DataTypes.STRING(500), field: "original_name" },
|
||||
mime_type: { type: DataTypes.STRING(100), field: "mime_type" },
|
||||
size: { type: DataTypes.BIGINT },
|
||||
|
||||
duration: { type: DataTypes.INTEGER, allowNull: true },
|
||||
thumbnail_path: {
|
||||
type: DataTypes.STRING(200),
|
||||
field: "thumbnail_path",
|
||||
allowNull: true,
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = Video;
|
||||
@@ -0,0 +1,17 @@
|
||||
const { DataTypes } = require("sequelize");
|
||||
const sequelize = require("../config/database");
|
||||
|
||||
// Junction table linking discovery videos to library entries (many-to-many)
|
||||
const VideoEntry = sequelize.define(
|
||||
"VideoEntry",
|
||||
{
|
||||
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
||||
video_id: { type: DataTypes.INTEGER },
|
||||
entry_id: { type: DataTypes.INTEGER },
|
||||
},
|
||||
{
|
||||
tableName: "video_entries",
|
||||
},
|
||||
);
|
||||
|
||||
module.exports = VideoEntry;
|
||||
@@ -30,6 +30,7 @@
|
||||
"body-parser": "^1.20.3",
|
||||
"dotenv": "^16.4.7",
|
||||
"express": "^4.21.2",
|
||||
"ffmpeg-static": "^5.3.0",
|
||||
"jsonwebtoken": "^9.0.3",
|
||||
"multer": "^1.4.5-lts.1",
|
||||
"mysql2": "^3.12.0",
|
||||
|
||||
Generated
+204
-2
@@ -20,6 +20,12 @@ importers:
|
||||
express:
|
||||
specifier: ^4.21.2
|
||||
version: 4.21.2
|
||||
ffmpeg-static:
|
||||
specifier: ^5.3.0
|
||||
version: 5.3.0
|
||||
jsonwebtoken:
|
||||
specifier: ^9.0.3
|
||||
version: 9.0.3
|
||||
multer:
|
||||
specifier: ^1.4.5-lts.1
|
||||
version: 1.4.5-lts.1
|
||||
@@ -34,7 +40,7 @@ importers:
|
||||
version: 0.1.4
|
||||
sequelize:
|
||||
specifier: ^6.37.5
|
||||
version: 6.37.5(mysql2@3.12.0)
|
||||
version: 6.37.5(mysql2@3.12.0)(supports-color@5.5.0)
|
||||
sharp:
|
||||
specifier: ^0.33.5
|
||||
version: 0.33.5
|
||||
@@ -44,6 +50,10 @@ importers:
|
||||
|
||||
packages:
|
||||
|
||||
'@derhuerst/http-basic@8.2.4':
|
||||
resolution: {integrity: sha512-F9rL9k9Xjf5blCz8HsJRO4diy111cayL2vkY2XE4r4t3n0yPXVYy3KD3nJ1qbrSn9743UWSXH4IwuCa/HWlGFw==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
|
||||
'@emnapi/runtime@1.3.1':
|
||||
resolution: {integrity: sha512-kEBmG8KyqtxJZv+ygbEim+KCGtIq1fC22Ms3S4ziXmYKm8uyoLX0MHONVKwp+9opg390VaKRNt4a7A9NwmpNhw==}
|
||||
|
||||
@@ -73,67 +83,79 @@ packages:
|
||||
resolution: {integrity: sha512-9B+taZ8DlyyqzZQnoeIvDVR/2F4EbMepXMc/NdVbkzsJbzkUjhXv/70GQJ7tdLA4YJgNP25zukcxpX2/SueNrA==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@img/sharp-libvips-linux-arm@1.0.5':
|
||||
resolution: {integrity: sha512-gvcC4ACAOPRNATg/ov8/MnbxFDJqf/pDePbBnuBDcjsI8PssmjoKMAz4LtLaVi+OnSb5FK/yIOamqDwGmXW32g==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@img/sharp-libvips-linux-s390x@1.0.4':
|
||||
resolution: {integrity: sha512-u7Wz6ntiSSgGSGcjZ55im6uvTrOxSIS8/dgoVMoiGE9I6JAfU50yH5BoDlYA1tcuGS7g/QNtetJnxA6QEsCVTA==}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@img/sharp-libvips-linux-x64@1.0.4':
|
||||
resolution: {integrity: sha512-MmWmQ3iPFZr0Iev+BAgVMb3ZyC4KeFc3jFxnNbEPas60e1cIfevbtuyf9nDGIzOaW9PdnDciJm+wFFaTlj5xYw==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@img/sharp-libvips-linuxmusl-arm64@1.0.4':
|
||||
resolution: {integrity: sha512-9Ti+BbTYDcsbp4wfYib8Ctm1ilkugkA/uscUn6UXK1ldpC1JjiXbLfFZtRlBhjPZ5o1NCLiDbg8fhUPKStHoTA==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@img/sharp-libvips-linuxmusl-x64@1.0.4':
|
||||
resolution: {integrity: sha512-viYN1KX9m+/hGkJtvYYp+CCLgnJXwiQB39damAO7WMdKWlIhmYTfHjwSbQeUK/20vY154mwezd9HflVFM1wVSw==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@img/sharp-linux-arm64@0.33.5':
|
||||
resolution: {integrity: sha512-JMVv+AMRyGOHtO1RFBiJy/MBsgz0x4AWrT6QoEVVTyh1E39TrCUpTRI7mx9VksGX4awWASxqCYLCV4wBZHAYxA==}
|
||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@img/sharp-linux-arm@0.33.5':
|
||||
resolution: {integrity: sha512-JTS1eldqZbJxjvKaAkxhZmBqPRGmxgu+qFKSInv8moZ2AmT5Yib3EQ1c6gp493HvrvV8QgdOXdyaIBrhvFhBMQ==}
|
||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@img/sharp-linux-s390x@0.33.5':
|
||||
resolution: {integrity: sha512-y/5PCd+mP4CA/sPDKl2961b+C9d+vPAveS33s6Z3zfASk2j5upL6fXVPZi7ztePZ5CuH+1kW8JtvxgbuXHRa4Q==}
|
||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@img/sharp-linux-x64@0.33.5':
|
||||
resolution: {integrity: sha512-opC+Ok5pRNAzuvq1AG0ar+1owsu842/Ab+4qvU879ippJBHvyY5n2mxF1izXqkPYlGuP/M556uh53jRLJmzTWA==}
|
||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@img/sharp-linuxmusl-arm64@0.33.5':
|
||||
resolution: {integrity: sha512-XrHMZwGQGvJg2V/oRSUfSAfjfPxO+4DkiRh6p2AFjLQztWUuY/o8Mq0eMQVIY7HJ1CDQUJlxGGZRw1a5bqmd1g==}
|
||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@img/sharp-linuxmusl-x64@0.33.5':
|
||||
resolution: {integrity: sha512-WT+d/cgqKkkKySYmqoZ8y3pxx7lx9vVejxW/W4DOFMYVSkErR+w7mf2u8m/y4+xHe7yY9DAXQMWQhpnMuFfScw==}
|
||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@img/sharp-wasm32@0.33.5':
|
||||
resolution: {integrity: sha512-ykUW4LVGaMcU9lu9thv85CbRMAwfeadCJHRsg2GmeRa/cJxsVY9Rbd57JcMxBkKHag5U/x7TSBpScF4U8ElVzg==}
|
||||
@@ -158,6 +180,9 @@ packages:
|
||||
'@types/ms@2.1.0':
|
||||
resolution: {integrity: sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==}
|
||||
|
||||
'@types/node@10.17.60':
|
||||
resolution: {integrity: sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==}
|
||||
|
||||
'@types/node@22.10.10':
|
||||
resolution: {integrity: sha512-X47y/mPNzxviAGY5TcYPtYL8JsY3kAq2n8fMmKoRCxq/c4v4pyGNCzM2R6+M5/umG4ZfHuT+sgqDYqWc9rJ6ww==}
|
||||
|
||||
@@ -168,6 +193,10 @@ packages:
|
||||
resolution: {integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
agent-base@6.0.2:
|
||||
resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==}
|
||||
engines: {node: '>= 6.0.0'}
|
||||
|
||||
anymatch@3.1.3:
|
||||
resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==}
|
||||
engines: {node: '>= 8'}
|
||||
@@ -206,6 +235,9 @@ packages:
|
||||
resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
buffer-equal-constant-time@1.0.1:
|
||||
resolution: {integrity: sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==}
|
||||
|
||||
buffer-from@1.1.2:
|
||||
resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==}
|
||||
|
||||
@@ -225,6 +257,9 @@ packages:
|
||||
resolution: {integrity: sha512-YTd+6wGlNlPxSuri7Y6X8tY2dmm12UMH66RpKMhiX6rsk5wXXnYgbUcOt8kiS31/AjfoTOvCsE+w8nZQLQnzHA==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
caseless@0.12.0:
|
||||
resolution: {integrity: sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==}
|
||||
|
||||
chokidar@3.6.0:
|
||||
resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==}
|
||||
engines: {node: '>= 8.10.0'}
|
||||
@@ -254,6 +289,10 @@ packages:
|
||||
resolution: {integrity: sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==}
|
||||
engines: {'0': node >= 0.8}
|
||||
|
||||
concat-stream@2.0.0:
|
||||
resolution: {integrity: sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==}
|
||||
engines: {'0': node >= 6.0}
|
||||
|
||||
content-disposition@0.5.4:
|
||||
resolution: {integrity: sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==}
|
||||
engines: {node: '>= 0.6'}
|
||||
@@ -315,11 +354,15 @@ packages:
|
||||
|
||||
dottie@2.0.6:
|
||||
resolution: {integrity: sha512-iGCHkfUc5kFekGiqhe8B/mdaurD+lakO9txNnTvKtA6PISrw86LgqHvRzWYPyoE2Ph5aMIrCw9/uko6XHTKCwA==}
|
||||
deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
|
||||
|
||||
dunder-proto@1.0.1:
|
||||
resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
ecdsa-sig-formatter@1.0.11:
|
||||
resolution: {integrity: sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==}
|
||||
|
||||
ee-first@1.1.1:
|
||||
resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==}
|
||||
|
||||
@@ -331,6 +374,10 @@ packages:
|
||||
resolution: {integrity: sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
env-paths@2.2.1:
|
||||
resolution: {integrity: sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
es-define-property@1.0.1:
|
||||
resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@@ -354,6 +401,10 @@ packages:
|
||||
resolution: {integrity: sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==}
|
||||
engines: {node: '>= 0.10.0'}
|
||||
|
||||
ffmpeg-static@5.3.0:
|
||||
resolution: {integrity: sha512-H+K6sW6TiIX6VGend0KQwthe+kaceeH/luE8dIZyOP35ik7ahYojDuqlTV1bOrtEwl01sy2HFNGQfi5IDJvotg==}
|
||||
engines: {node: '>=16'}
|
||||
|
||||
fill-range@7.1.1:
|
||||
resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==}
|
||||
engines: {node: '>=8'}
|
||||
@@ -426,6 +477,13 @@ packages:
|
||||
resolution: {integrity: sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
http-response-object@3.0.2:
|
||||
resolution: {integrity: sha512-bqX0XTF6fnXSQcEJ2Iuyr75yVakyjIDCqroJQ/aHfSdlM743Cwqoi2nDYMzLGWUcuTWGWy8AAvOKXTfiv6q9RA==}
|
||||
|
||||
https-proxy-agent@5.0.1:
|
||||
resolution: {integrity: sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==}
|
||||
engines: {node: '>= 6'}
|
||||
|
||||
iconv-lite@0.4.24:
|
||||
resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@@ -473,6 +531,37 @@ packages:
|
||||
isarray@1.0.0:
|
||||
resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==}
|
||||
|
||||
jsonwebtoken@9.0.3:
|
||||
resolution: {integrity: sha512-MT/xP0CrubFRNLNKvxJ2BYfy53Zkm++5bX9dtuPbqAeQpTVe0MQTFhao8+Cp//EmJp244xt6Drw/GVEGCUj40g==}
|
||||
engines: {node: '>=12', npm: '>=6'}
|
||||
|
||||
jwa@2.0.1:
|
||||
resolution: {integrity: sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==}
|
||||
|
||||
jws@4.0.1:
|
||||
resolution: {integrity: sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA==}
|
||||
|
||||
lodash.includes@4.3.0:
|
||||
resolution: {integrity: sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==}
|
||||
|
||||
lodash.isboolean@3.0.3:
|
||||
resolution: {integrity: sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==}
|
||||
|
||||
lodash.isinteger@4.0.4:
|
||||
resolution: {integrity: sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==}
|
||||
|
||||
lodash.isnumber@3.0.3:
|
||||
resolution: {integrity: sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==}
|
||||
|
||||
lodash.isplainobject@4.0.6:
|
||||
resolution: {integrity: sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==}
|
||||
|
||||
lodash.isstring@4.0.1:
|
||||
resolution: {integrity: sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==}
|
||||
|
||||
lodash.once@4.1.1:
|
||||
resolution: {integrity: sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==}
|
||||
|
||||
lodash@4.17.21:
|
||||
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
|
||||
|
||||
@@ -540,6 +629,7 @@ packages:
|
||||
multer@1.4.5-lts.1:
|
||||
resolution: {integrity: sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==}
|
||||
engines: {node: '>= 6.0.0'}
|
||||
deprecated: Multer 1.x is impacted by a number of vulnerabilities, which have been patched in 2.x. You should upgrade to the latest 2.x version.
|
||||
|
||||
mysql2@3.12.0:
|
||||
resolution: {integrity: sha512-C8fWhVysZoH63tJbX8d10IAoYCyXy4fdRFz2Ihrt9jtPILYynFEKUUzpp1U7qxzDc3tMbotvaBH+sl6bFnGZiw==}
|
||||
@@ -577,6 +667,9 @@ packages:
|
||||
optional@0.1.4:
|
||||
resolution: {integrity: sha512-gtvrrCfkE08wKcgXaVwQVgwEQ8vel2dc5DDBn9RLQZ3YtmtkBss6A2HY6BnJH4N/4Ku97Ri/SF8sNWE2225WJw==}
|
||||
|
||||
parse-cache-control@1.0.1:
|
||||
resolution: {integrity: sha512-60zvsJReQPX5/QP0Kzfd/VrpjScIQ7SHBW6bFCYfEP+fp0Eppr1SHhIO5nd1PjZtvclzSzES9D/p5nFJurwfWg==}
|
||||
|
||||
parseurl@1.3.3:
|
||||
resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==}
|
||||
engines: {node: '>= 0.8'}
|
||||
@@ -594,6 +687,10 @@ packages:
|
||||
process-nextick-args@2.0.1:
|
||||
resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==}
|
||||
|
||||
progress@2.0.3:
|
||||
resolution: {integrity: sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==}
|
||||
engines: {node: '>=0.4.0'}
|
||||
|
||||
proxy-addr@2.0.7:
|
||||
resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==}
|
||||
engines: {node: '>= 0.10'}
|
||||
@@ -619,6 +716,10 @@ packages:
|
||||
readable-stream@2.3.8:
|
||||
resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==}
|
||||
|
||||
readable-stream@3.6.2:
|
||||
resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==}
|
||||
engines: {node: '>= 6'}
|
||||
|
||||
readdirp@3.6.0:
|
||||
resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==}
|
||||
engines: {node: '>=8.10.0'}
|
||||
@@ -785,6 +886,7 @@ packages:
|
||||
|
||||
uuid@8.3.2:
|
||||
resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==}
|
||||
deprecated: uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).
|
||||
hasBin: true
|
||||
|
||||
validator@13.12.0:
|
||||
@@ -804,6 +906,13 @@ packages:
|
||||
|
||||
snapshots:
|
||||
|
||||
'@derhuerst/http-basic@8.2.4':
|
||||
dependencies:
|
||||
caseless: 0.12.0
|
||||
concat-stream: 2.0.0
|
||||
http-response-object: 3.0.2
|
||||
parse-cache-control: 1.0.1
|
||||
|
||||
'@emnapi/runtime@1.3.1':
|
||||
dependencies:
|
||||
tslib: 2.8.1
|
||||
@@ -890,6 +999,8 @@ snapshots:
|
||||
|
||||
'@types/ms@2.1.0': {}
|
||||
|
||||
'@types/node@10.17.60': {}
|
||||
|
||||
'@types/node@22.10.10':
|
||||
dependencies:
|
||||
undici-types: 6.20.0
|
||||
@@ -901,6 +1012,12 @@ snapshots:
|
||||
mime-types: 2.1.35
|
||||
negotiator: 0.6.3
|
||||
|
||||
agent-base@6.0.2:
|
||||
dependencies:
|
||||
debug: 4.4.0(supports-color@5.5.0)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
anymatch@3.1.3:
|
||||
dependencies:
|
||||
normalize-path: 3.0.0
|
||||
@@ -952,6 +1069,8 @@ snapshots:
|
||||
dependencies:
|
||||
fill-range: 7.1.1
|
||||
|
||||
buffer-equal-constant-time@1.0.1: {}
|
||||
|
||||
buffer-from@1.1.2: {}
|
||||
|
||||
busboy@1.6.0:
|
||||
@@ -970,6 +1089,8 @@ snapshots:
|
||||
call-bind-apply-helpers: 1.0.1
|
||||
get-intrinsic: 1.2.7
|
||||
|
||||
caseless@0.12.0: {}
|
||||
|
||||
chokidar@3.6.0:
|
||||
dependencies:
|
||||
anymatch: 3.1.3
|
||||
@@ -1011,6 +1132,13 @@ snapshots:
|
||||
readable-stream: 2.3.8
|
||||
typedarray: 0.0.6
|
||||
|
||||
concat-stream@2.0.0:
|
||||
dependencies:
|
||||
buffer-from: 1.1.2
|
||||
inherits: 2.0.4
|
||||
readable-stream: 3.6.2
|
||||
typedarray: 0.0.6
|
||||
|
||||
content-disposition@0.5.4:
|
||||
dependencies:
|
||||
safe-buffer: 5.2.1
|
||||
@@ -1053,12 +1181,18 @@ snapshots:
|
||||
es-errors: 1.3.0
|
||||
gopd: 1.2.0
|
||||
|
||||
ecdsa-sig-formatter@1.0.11:
|
||||
dependencies:
|
||||
safe-buffer: 5.2.1
|
||||
|
||||
ee-first@1.1.1: {}
|
||||
|
||||
encodeurl@1.0.2: {}
|
||||
|
||||
encodeurl@2.0.0: {}
|
||||
|
||||
env-paths@2.2.1: {}
|
||||
|
||||
es-define-property@1.0.1: {}
|
||||
|
||||
es-errors@1.3.0: {}
|
||||
@@ -1107,6 +1241,15 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
ffmpeg-static@5.3.0:
|
||||
dependencies:
|
||||
'@derhuerst/http-basic': 8.2.4
|
||||
env-paths: 2.2.1
|
||||
https-proxy-agent: 5.0.1
|
||||
progress: 2.0.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
fill-range@7.1.1:
|
||||
dependencies:
|
||||
to-regex-range: 5.0.1
|
||||
@@ -1184,6 +1327,17 @@ snapshots:
|
||||
statuses: 2.0.1
|
||||
toidentifier: 1.0.1
|
||||
|
||||
http-response-object@3.0.2:
|
||||
dependencies:
|
||||
'@types/node': 10.17.60
|
||||
|
||||
https-proxy-agent@5.0.1:
|
||||
dependencies:
|
||||
agent-base: 6.0.2
|
||||
debug: 4.4.0(supports-color@5.5.0)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
iconv-lite@0.4.24:
|
||||
dependencies:
|
||||
safer-buffer: 2.1.2
|
||||
@@ -1218,6 +1372,44 @@ snapshots:
|
||||
|
||||
isarray@1.0.0: {}
|
||||
|
||||
jsonwebtoken@9.0.3:
|
||||
dependencies:
|
||||
jws: 4.0.1
|
||||
lodash.includes: 4.3.0
|
||||
lodash.isboolean: 3.0.3
|
||||
lodash.isinteger: 4.0.4
|
||||
lodash.isnumber: 3.0.3
|
||||
lodash.isplainobject: 4.0.6
|
||||
lodash.isstring: 4.0.1
|
||||
lodash.once: 4.1.1
|
||||
ms: 2.1.3
|
||||
semver: 7.6.3
|
||||
|
||||
jwa@2.0.1:
|
||||
dependencies:
|
||||
buffer-equal-constant-time: 1.0.1
|
||||
ecdsa-sig-formatter: 1.0.11
|
||||
safe-buffer: 5.2.1
|
||||
|
||||
jws@4.0.1:
|
||||
dependencies:
|
||||
jwa: 2.0.1
|
||||
safe-buffer: 5.2.1
|
||||
|
||||
lodash.includes@4.3.0: {}
|
||||
|
||||
lodash.isboolean@3.0.3: {}
|
||||
|
||||
lodash.isinteger@4.0.4: {}
|
||||
|
||||
lodash.isnumber@3.0.3: {}
|
||||
|
||||
lodash.isplainobject@4.0.6: {}
|
||||
|
||||
lodash.isstring@4.0.1: {}
|
||||
|
||||
lodash.once@4.1.1: {}
|
||||
|
||||
lodash@4.17.21: {}
|
||||
|
||||
long@5.2.4: {}
|
||||
@@ -1315,6 +1507,8 @@ snapshots:
|
||||
|
||||
optional@0.1.4: {}
|
||||
|
||||
parse-cache-control@1.0.1: {}
|
||||
|
||||
parseurl@1.3.3: {}
|
||||
|
||||
path-to-regexp@0.1.12: {}
|
||||
@@ -1325,6 +1519,8 @@ snapshots:
|
||||
|
||||
process-nextick-args@2.0.1: {}
|
||||
|
||||
progress@2.0.3: {}
|
||||
|
||||
proxy-addr@2.0.7:
|
||||
dependencies:
|
||||
forwarded: 0.2.0
|
||||
@@ -1357,6 +1553,12 @@ snapshots:
|
||||
string_decoder: 1.1.1
|
||||
util-deprecate: 1.0.2
|
||||
|
||||
readable-stream@3.6.2:
|
||||
dependencies:
|
||||
inherits: 2.0.4
|
||||
string_decoder: 1.1.1
|
||||
util-deprecate: 1.0.2
|
||||
|
||||
readdirp@3.6.0:
|
||||
dependencies:
|
||||
picomatch: 2.3.1
|
||||
@@ -1393,7 +1595,7 @@ snapshots:
|
||||
|
||||
sequelize-pool@7.1.0: {}
|
||||
|
||||
sequelize@6.37.5(mysql2@3.12.0):
|
||||
sequelize@6.37.5(mysql2@3.12.0)(supports-color@5.5.0):
|
||||
dependencies:
|
||||
'@types/debug': 4.1.12
|
||||
'@types/validator': 13.12.2
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
allowBuilds:
|
||||
ffmpeg-static: true
|
||||
sharp: false
|
||||
@@ -16,6 +16,7 @@ const aiQueryRouter = require("./ai-query.routes");
|
||||
const authRouter = require("./auth.routes");
|
||||
const watchBuddyRouter = require("./watch-buddy.routes");
|
||||
const homepageIntegrationRouter = require("./homepage-integration.routes");
|
||||
const videoRouter = require("./video.routes");
|
||||
|
||||
const router = express.Router();
|
||||
router.use("/auth", authRouter);
|
||||
@@ -37,5 +38,6 @@ router.use("/ping", pingRouter);
|
||||
router.use("/people", peopleRouter);
|
||||
router.use("/ai-query", aiQueryRouter);
|
||||
router.use("/homepage-integration", homepageIntegrationRouter);
|
||||
router.use("/discovery-videos", videoRouter);
|
||||
|
||||
module.exports = router;
|
||||
@@ -0,0 +1,17 @@
|
||||
const express = require("express");
|
||||
const videoRouter = express.Router();
|
||||
|
||||
const videoController = require("../controllers/videoController.js");
|
||||
const { videosUpload } = require("../services/mutlerStorageLocations");
|
||||
|
||||
const upload = videosUpload.array("videos", 10);
|
||||
|
||||
// ! /discovery-videos
|
||||
videoRouter.get("/", videoController.getVideos);
|
||||
videoRouter.post("/", upload, videoController.uploadVideos);
|
||||
videoRouter.put("/:id", videoController.updateVideo);
|
||||
videoRouter.delete("/:id", videoController.deleteVideo);
|
||||
videoRouter.get("/:id/thumbnail", videoController.getThumbnail);
|
||||
videoRouter.get("/:id/stream", videoController.streamVideo);
|
||||
|
||||
module.exports = videoRouter;
|
||||
@@ -120,6 +120,7 @@ class ConfigService {
|
||||
"peoples",
|
||||
"profiles",
|
||||
);
|
||||
const videosDir = path.join(dataPath, "videos");
|
||||
|
||||
fs.mkdirSync(posterDir, { recursive: true });
|
||||
fs.mkdirSync(backdropDir, { recursive: true });
|
||||
@@ -129,6 +130,7 @@ class ConfigService {
|
||||
fs.mkdirSync(seasonsPostersDir, { recursive: true });
|
||||
fs.mkdirSync(episodesStillsDir, { recursive: true });
|
||||
fs.mkdirSync(peopleProfilesDir, { recursive: true });
|
||||
fs.mkdirSync(videosDir, { recursive: true });
|
||||
}
|
||||
|
||||
getTmdbApiUrl() {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const multer = require("multer");
|
||||
const fs = require("fs");
|
||||
const { v4: uuidv4 } = require("uuid");
|
||||
const path = require("path");
|
||||
const configService = require("./configService");
|
||||
@@ -57,8 +58,27 @@ const peoplePicturesUpload = multer({
|
||||
}),
|
||||
});
|
||||
|
||||
// ? discovery videos
|
||||
const videosUpload = multer({
|
||||
storage: multer.diskStorage({
|
||||
destination: function (req, file, cb) {
|
||||
const dataPath = configService.getSettings().userDataPath;
|
||||
const videosDir = path.join(dataPath, "videos");
|
||||
// ensure the folder exists even if createMediaFolders() was never called
|
||||
fs.mkdirSync(videosDir, { recursive: true });
|
||||
cb(null, videosDir);
|
||||
},
|
||||
filename: function (req, file, cb) {
|
||||
const uniqueFilename = uuidv4();
|
||||
const extension = file.originalname.split(".").pop();
|
||||
cb(null, `${uniqueFilename}.${extension}`);
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
entryPicturesUpload,
|
||||
collectionPicturesUpload,
|
||||
peoplePicturesUpload,
|
||||
videosUpload,
|
||||
};
|
||||
@@ -0,0 +1,151 @@
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const { execFile } = require("child_process");
|
||||
|
||||
const configService = require("./configService");
|
||||
const Video = require("../models/Video");
|
||||
|
||||
const { logToFile } = require("./logService");
|
||||
|
||||
// Limit concurrent ffmpeg jobs so a page full of missing thumbnails
|
||||
// doesn't start one heavy process per image request at once.
|
||||
const MAX_CONCURRENT_JOBS = 2;
|
||||
let activeJobs = 0;
|
||||
const jobQueue = [];
|
||||
|
||||
function resolveFfmpeg() {
|
||||
try {
|
||||
const bin = require("ffmpeg-static");
|
||||
if (bin && fs.existsSync(bin)) return bin;
|
||||
} catch {
|
||||
// ffmpeg-static not installed
|
||||
}
|
||||
return "ffmpeg"; // fall back to a system-wide ffmpeg on PATH
|
||||
}
|
||||
|
||||
function extractFrame(ffmpeg, inputPath, outputPath, seek) {
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile(
|
||||
ffmpeg,
|
||||
[
|
||||
"-y",
|
||||
"-ss",
|
||||
seek,
|
||||
"-i",
|
||||
inputPath,
|
||||
"-frames:v",
|
||||
"1",
|
||||
"-vf",
|
||||
"scale=640:-2",
|
||||
"-q:v",
|
||||
"3",
|
||||
outputPath,
|
||||
],
|
||||
{ timeout: 60000, windowsHide: true },
|
||||
(err) => (err ? reject(err) : resolve()),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function runLimited(job) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const run = async () => {
|
||||
try {
|
||||
resolve(await job());
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
} finally {
|
||||
activeJobs -= 1;
|
||||
const next = jobQueue.shift();
|
||||
if (next) {
|
||||
activeJobs += 1;
|
||||
next();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (activeJobs < MAX_CONCURRENT_JOBS) {
|
||||
activeJobs += 1;
|
||||
run();
|
||||
} else {
|
||||
jobQueue.push(run);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a thumbnail for a video: extracts a frame at 1s (falls back
|
||||
* to frame 0 for very short videos) and stores `{uuid}.jpg` in
|
||||
* data/videos/thumbnails/.
|
||||
*
|
||||
* Returns the thumbnail filename on success, or null on failure.
|
||||
* Never throws — a missing thumbnail must not break requests.
|
||||
*/
|
||||
async function generateThumbnail(video) {
|
||||
try {
|
||||
// Re-check against the DB — the thumbnail may have been generated
|
||||
// since this video instance was loaded.
|
||||
const fresh = await Video.findByPk(video.id);
|
||||
if (!fresh) return null;
|
||||
|
||||
const dataPath = configService.getSettings().userDataPath;
|
||||
const videosDir = path.join(dataPath, "videos");
|
||||
const thumbDir = path.join(videosDir, "thumbnails");
|
||||
|
||||
const inputPath = path.join(videosDir, fresh.filename);
|
||||
if (!fs.existsSync(inputPath)) return null;
|
||||
|
||||
const thumbName = `${fresh.filename.split(".")[0]}.jpg`;
|
||||
const outputPath = path.join(thumbDir, thumbName);
|
||||
|
||||
// Already generated → just make sure the DB knows about it
|
||||
if (fs.existsSync(outputPath)) {
|
||||
if (!fresh.thumbnail_path) {
|
||||
await fresh.update({ thumbnail_path: thumbName });
|
||||
}
|
||||
return thumbName;
|
||||
}
|
||||
|
||||
fs.mkdirSync(thumbDir, { recursive: true });
|
||||
|
||||
const ffmpeg = resolveFfmpeg();
|
||||
try {
|
||||
await extractFrame(ffmpeg, inputPath, outputPath, "1");
|
||||
} catch {
|
||||
// very short videos — grab the first frame instead
|
||||
await extractFrame(ffmpeg, inputPath, outputPath, "0");
|
||||
}
|
||||
|
||||
if (!fs.existsSync(outputPath)) return null;
|
||||
|
||||
await fresh.update({ thumbnail_path: thumbName });
|
||||
logToFile(`Video Thumbnail | Generated for video ${fresh.id}`);
|
||||
return thumbName;
|
||||
} catch (err) {
|
||||
logToFile(`Video Thumbnail | Error for video ${video.id}`);
|
||||
logToFile(err);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const inFlight = new Map(); // videoId -> Promise<string | null>
|
||||
|
||||
/**
|
||||
* On-demand thumbnail generation.
|
||||
* - Per-video dedup: concurrent requests for the same video share one job.
|
||||
* - Global concurrency limit (MAX_CONCURRENT_JOBS ffmpeg processes).
|
||||
* Called only from the thumbnail endpoint, i.e. when a client actually
|
||||
* requests a thumbnail that doesn't exist yet.
|
||||
*/
|
||||
function ensureThumbnail(video) {
|
||||
if (inFlight.has(video.id)) return inFlight.get(video.id);
|
||||
|
||||
const tracked = runLimited(() => generateThumbnail(video));
|
||||
const shared = tracked.finally(() => {
|
||||
inFlight.delete(video.id);
|
||||
});
|
||||
inFlight.set(video.id, shared);
|
||||
return shared;
|
||||
}
|
||||
|
||||
module.exports = { ensureThumbnail, generateThumbnail };
|
||||
@@ -170,6 +170,23 @@ See [[Media System]] for details.
|
||||
|
||||
---
|
||||
|
||||
## Discovery Videos
|
||||
|
||||
> [!info] File: `routes/video.routes.js` → `controllers/videoController.js`
|
||||
|
||||
See [[Discovery Videos]] for details.
|
||||
|
||||
| Method | Path | Description |
|
||||
|---|---|---|
|
||||
| `GET` | `/discovery-videos?page=&limit=` | Paginated list (includes linked entries) |
|
||||
| `POST` | `/discovery-videos` | Multipart upload: `videos[]` (≤ 10), `description`, `entryIds` (JSON array) |
|
||||
| `PUT` | `/discovery-videos/:id` | Update title / description / entry links |
|
||||
| `DELETE` | `/discovery-videos/:id` | Delete record + files from disk |
|
||||
| `GET` | `/discovery-videos/:id/thumbnail` | Thumbnail image — generated on demand when missing |
|
||||
| `GET` | `/discovery-videos/:id/stream` | Video stream with HTTP Range support (`?token=` auth) |
|
||||
|
||||
---
|
||||
|
||||
## People
|
||||
|
||||
> [!info] File: `routes/people.routes.js` → `controllers/peopleController.js`
|
||||
|
||||
@@ -37,10 +37,10 @@ backend/
|
||||
│ ├── relations.js All model associations → [[Database#Relationships]]
|
||||
│ ├── dataInitializer.js Genre seeding (27 TMDB genres)
|
||||
│ └── sequelizeHooks.js UserCollectionEntry hooks (order management)
|
||||
├── controllers/ Route handlers (14 controllers)
|
||||
├── controllers/ Route handlers (15 controllers)
|
||||
├── services/ Business logic (16 services) → [[Services]]
|
||||
├── models/ Sequelize models (17 models) → [[Models]]
|
||||
├── routes/ Express routers (14 route files) → [[API Reference]]
|
||||
├── models/ Sequelize models (19 models) → [[Models]]
|
||||
├── routes/ Express routers (15 route files) → [[API Reference]]
|
||||
├── errors/ Custom error classes → [[Error Handling]]
|
||||
├── middleware/
|
||||
│ └── errorHandler.js Central error catching
|
||||
@@ -96,3 +96,4 @@ See [[Media System]] for the complete download → optimize → serve flow.
|
||||
- [[Error Handling]] — Error classes and middleware
|
||||
- [[TMDB Integration]] — External API
|
||||
- [[Media System]] — Image handling
|
||||
- [[Discovery Videos]] — Video upload/stream API
|
||||
@@ -68,13 +68,27 @@ See [[Statistics]] for data details.
|
||||
| `CollectionEditDialog` | `dialogs/CollectionEditDialog.tsx` | Create/edit collection |
|
||||
| `MarkSeasonWatchedDialog` | `dialogs/MarkSeasonWatchedDialog.tsx` | Mark season as watched — single date or scatter mode |
|
||||
|
||||
## Discovery Video Components
|
||||
|
||||
> [!info] Folder: `components/discovery-videos/`
|
||||
|
||||
See [[Discovery Videos]].
|
||||
|
||||
| Component | File | Description |
|
||||
|---|---|---|
|
||||
| `VideoCard` | `discovery-videos/VideoCard.tsx` | Card with lazy thumbnail (`loading="lazy"`, on-demand generation) + play overlay, linked-entry chips, edit/delete actions |
|
||||
| `VideoPlayerDialog` | `discovery-videos/VideoPlayerDialog.tsx` | Playback dialog — autoplay, ↑/↓ (and ←/→) prev/next navigation, linked-entry chips, inline edit |
|
||||
| `AddVideoDialog` | `discovery-videos/AddVideoDialog.tsx` | Upload (create) and edit modes — dropzone + description + entry multi-select |
|
||||
| `VideoDropzone` | `discovery-videos/VideoDropzone.tsx` | Native HTML5 drag & drop zone (no dependency) |
|
||||
| `EntryMultiSelect` | `discovery-videos/EntryMultiSelect.tsx` | Search-first library entry picker (debounced 250 ms) reading from [[Stores\|library store]] |
|
||||
|
||||
## Skeletons
|
||||
|
||||
> [!info] File: `components/skeletons/PageSkeletons.tsx`
|
||||
|
||||
14 named skeleton exports used as `<Suspense>` fallbacks for lazy-loaded pages:
|
||||
15 named skeleton exports used as `<Suspense>` fallbacks for lazy-loaded pages:
|
||||
|
||||
`HomeSkeleton`, `LibrarySkeleton`, `WatchlistSkeleton`, `DashboardSkeleton`, `CollectionsSkeleton`, `CollectionDetailsSkeleton`, `MediaSkeleton`, `CalendarSkeleton`, `EntryDetailsSkeleton`, `SeasonSkeleton`, `EpisodeSkeleton`, `PeopleSkeleton`, `PersonDetailsSkeleton`, `SettingsSkeleton`
|
||||
`HomeSkeleton`, `LibrarySkeleton`, `WatchlistSkeleton`, `DashboardSkeleton`, `CollectionsSkeleton`, `CollectionDetailsSkeleton`, `MediaSkeleton`, `CalendarSkeleton`, `EntryDetailsSkeleton`, `SeasonSkeleton`, `EpisodeSkeleton`, `PeopleSkeleton`, `PersonDetailsSkeleton`, `SettingsSkeleton`, `DiscoveryVideosSkeleton`
|
||||
|
||||
## Command Palette
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ erDiagram
|
||||
Entry }o--o{ Genre : tagged
|
||||
Entry }o--o{ Network : airs-on
|
||||
Entry }o--o{ Collection : belongs-to
|
||||
Entry }o--o{ Video : links-to
|
||||
|
||||
Season ||--o{ Episode : contains
|
||||
Episode ||--o{ EpisodeSeen : has
|
||||
@@ -63,6 +64,7 @@ Defined in `backend/config/relations.js`:
|
||||
| Credit | Entry | `belongsTo` | — | — |
|
||||
| People | Credit | `hasMany` (as 'roles') | — | — |
|
||||
| Media | * | Polymorphic scopes | `mediaable` + `mediaableId` | — |
|
||||
| Video | Entry | `belongsToMany` | VideoEntry | CASCADE |
|
||||
|
||||
### Polymorphic Media Scopes
|
||||
|
||||
@@ -101,6 +103,8 @@ See [[Models]] for detailed field definitions of every model.
|
||||
| [[Models#Genre\|Genre]] | Genres (seeded from TMDB) | No |
|
||||
| [[Models#Network\|Network]] | TV networks | No |
|
||||
| [[Models#Franchise\|Franchise]] | Franchise grouping (unused) | No |
|
||||
| [[Models#Video\|Video]] | Discovery videos | Yes |
|
||||
| [[Models#VideoEntry\|VideoEntry]] | Video ↔ Entry join | Yes |
|
||||
|
||||
## Important Files
|
||||
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
---
|
||||
title: Discovery Videos
|
||||
tags:
|
||||
- feature
|
||||
- frontend
|
||||
- backend
|
||||
- videos
|
||||
aliases:
|
||||
- Videos
|
||||
- Saved Videos
|
||||
- Video Vault
|
||||
---
|
||||
|
||||
# Discovery Videos
|
||||
|
||||
Personal video vault page — upload local videos (recommendations, anything worth watching later), add a description, and link them to one or more [[Library]] entries.
|
||||
|
||||
**Route:** `/discovery-videos` (sidebar label: "Discover")
|
||||
|
||||
> [!note] Naming
|
||||
> This page is distinct from [[Pages#DiscoverPage|DiscoverPage]], which is the TMDB browse page at `/discover/:category`.
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
**Responsibilities:**
|
||||
|
||||
- Upload video files via drag & drop (up to 10 at once)
|
||||
- Store a description per upload
|
||||
- Link videos to one or many library entries (M:N)
|
||||
- Display all saved videos in a lazy-loaded grid with inline playback
|
||||
- Edit / delete videos (deletion also removes the file from disk)
|
||||
|
||||
**Key Flows:**
|
||||
|
||||
1. **Upload:** `AddVideoDialog` → drop files → description + entry multi-select → `POST /discovery-videos` (multipart) → files stored to `data/videos/` with UUID names
|
||||
2. **Browse:** `DiscoveryVideosPage` → `GET /discovery-videos?page=&limit=` (24/page) → infinite scroll via IntersectionObserver
|
||||
3. **Play:** clicking a card opens `VideoPlayerDialog` — the video plays in the dialog; ↑/↓ (and ←/→ when the player isn't focused) navigate to the previous/next video. Streamed via `GET /discovery-videos/:id/stream` with HTTP Range support
|
||||
4. **Thumbnails (on demand):** cards always request `GET /discovery-videos/:id/thumbnail`; when no thumbnail exists yet, the endpoint generates it (ffmpeg frame at 1s) and serves it in the same response — nothing is generated eagerly or at startup
|
||||
|
||||
**Entry linking UX:** the picker in `AddVideoDialog` lists entries only once the user starts typing (debounced 250 ms) — the full library is never rendered at once.
|
||||
|
||||
---
|
||||
|
||||
## Lazy Loading & Performance
|
||||
|
||||
| Layer | Mechanism |
|
||||
|---|---|
|
||||
| Route | `React.lazy()` + `<Suspense>` with `DiscoveryVideosSkeleton` |
|
||||
| Data | Paginated API + `useInfiniteQuery` + IntersectionObserver sentinel (`rootMargin: "400px"`) — only metadata travels, never video bytes |
|
||||
| Thumbnails | `<img loading="lazy">` requesting the thumbnail endpoint — generated **on demand** on first request (no eager/startup generation), deduped + limited to 2 concurrent ffmpeg jobs |
|
||||
| Media | Video plays only inside the player dialog — nothing is fetched until the user opens it; `res.sendFile` → native `Accept-Ranges`/`206` support → browser pulls only the segments it needs on seek/play |
|
||||
|
||||
---
|
||||
|
||||
## Data Model
|
||||
|
||||
See [[Models#Video]] and [[Models#VideoEntry]] for field details, [[Database#Relationships]] for the relations.
|
||||
|
||||
```
|
||||
videos (id, title, description, filename, original_name, mime_type, size, ...)
|
||||
└── video_entries (video_id, entry_id) ── entries
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## API
|
||||
|
||||
| Method | Path | Description |
|
||||
|---|---|---|
|
||||
| `GET` | `/discovery-videos?page=&limit=` | Paginated list (includes linked entries) |
|
||||
| `POST` | `/discovery-videos` | Multipart upload: `videos[]` (≤ 10), `description`, `entryIds` (JSON array) |
|
||||
| `PUT` | `/discovery-videos/:id` | Update title / description / entry links |
|
||||
| `DELETE` | `/discovery-videos/:id` | Delete record + files from disk |
|
||||
| `GET` | `/discovery-videos/:id/stream` | Video stream with HTTP Range support |
|
||||
| `GET` | `/discovery-videos/:id/thumbnail` | Thumbnail image — generated on demand when missing (served in the same response) |
|
||||
|
||||
**Auth:** stream URLs append `?token=<authToken>` (the `<video>` tag cannot send `Authorization` headers). See [[API Reference]].
|
||||
|
||||
**Allowed extensions:** `mp4, webm, mov, m4v, mkv, avi`. Note: `mkv`/`avi` may not play in browsers — mp4 (H.264) is recommended.
|
||||
|
||||
---
|
||||
|
||||
## Important Files
|
||||
|
||||
**Backend**
|
||||
|
||||
- `backend/models/Video.js` — video record model
|
||||
- `backend/models/VideoEntry.js` — junction model (video ↔ entry)
|
||||
- `backend/controllers/videoController.js` — list/upload/update/delete/stream/thumbnail
|
||||
- `backend/routes/video.routes.js` — mounted at `/api/v1/discovery-videos`
|
||||
- `backend/services/mutlerStorageLocations.js` — `videosUpload` multer config
|
||||
- `backend/services/videoThumbnailService.js` — on-demand ffmpeg thumbnail generation (deduped, concurrency-limited)
|
||||
|
||||
**Frontend**
|
||||
|
||||
- `react_frontend/src/pages/DiscoveryVideosPage.tsx` — page (grid + infinite scroll + player state)
|
||||
- `react_frontend/src/components/discovery-videos/VideoCard.tsx` — thumbnail card with play overlay
|
||||
- `react_frontend/src/components/discovery-videos/VideoPlayerDialog.tsx` — playback dialog with ↑/↓ navigation
|
||||
- `react_frontend/src/components/discovery-videos/AddVideoDialog.tsx` — create/edit dialog
|
||||
- `react_frontend/src/components/discovery-videos/VideoDropzone.tsx` — native drag & drop
|
||||
- `react_frontend/src/components/discovery-videos/EntryMultiSelect.tsx` — library entry picker (reads from [[Stores|library store]])
|
||||
- `react_frontend/src/api/discoveryVideos.ts` — API module
|
||||
- `react_frontend/src/hooks/useDiscoveryVideos.ts` — query/mutations
|
||||
|
||||
---
|
||||
|
||||
## Known Limitations
|
||||
|
||||
- Thumbnails are generated on demand (first request, ffmpeg frame at 1s) — the first load of a thumbnail takes a moment; `ffmpeg-static` must ship in the packaged build (see `backend/pnpm-workspace.yaml` build approval)
|
||||
- No transcoding — unsupported codecs will fail in the browser player
|
||||
- No per-video watch state ("already watched") yet
|
||||
- Multi-file uploads share one description + entry set (editable per video afterwards)
|
||||
|
||||
## See Also
|
||||
|
||||
- [[Routing]] — route table
|
||||
- [[Pages]] — page reference
|
||||
- [[Models]] — Sequelize models
|
||||
- [[Database]] — relationships
|
||||
- [[API Reference]] — endpoint reference
|
||||
@@ -103,7 +103,7 @@ The entire entry library is loaded into a Zustand `Map<number, Entry>` on startu
|
||||
|
||||
### Lazy Page Loading
|
||||
|
||||
All 17 pages use `React.lazy()` with custom skeleton fallbacks via `<Suspense>`. See [[Routing]].
|
||||
All 18 pages use `React.lazy()` with custom skeleton fallbacks via `<Suspense>`. See [[Routing]].
|
||||
|
||||
### Form Pattern
|
||||
|
||||
@@ -119,7 +119,7 @@ All mutation success/error feedback via Sonner toasts.
|
||||
|
||||
## See Also
|
||||
|
||||
- [[Routing]] — All 17 routes
|
||||
- [[Routing]] — All 18 routes
|
||||
- [[Pages]] — Every page component
|
||||
- [[Components]] — UI components by category
|
||||
- [[Hooks]] — Custom hooks
|
||||
@@ -127,3 +127,4 @@ All mutation success/error feedback via Sonner toasts.
|
||||
- [[API Clients]] — Backend communication
|
||||
- [[Types]] — TypeScript types
|
||||
- [[Navigation]] — Breadcrumbs
|
||||
- [[Discovery Videos]] — Personal video vault feature
|
||||
@@ -127,6 +127,19 @@ See [[Statistics]].
|
||||
|---|---|---|
|
||||
| `useEpisodesByMonth(start, end)` | Query | Episodes airing in date range (for [[Calendar]]) |
|
||||
|
||||
## useDiscoveryVideos
|
||||
|
||||
> [!info] File: `hooks/useDiscoveryVideos.ts`
|
||||
|
||||
See [[Discovery Videos]].
|
||||
|
||||
| Hook | Type | Description |
|
||||
|---|---|---|
|
||||
| `useDiscoveryVideos()` | Infinite Query | Paginated video list (24/page) |
|
||||
| `useUploadVideos()` | Mutation | `POST /discovery-videos` (multipart, upload progress) |
|
||||
| `useUpdateVideo()` | Mutation | `PUT /discovery-videos/:id` |
|
||||
| `useDeleteVideo()` | Mutation | `DELETE /discovery-videos/:id` |
|
||||
|
||||
## useDebounce
|
||||
|
||||
> [!info] File: `hooks/useDebounce.ts`
|
||||
|
||||
@@ -57,6 +57,7 @@ aliases:
|
||||
- [[Watch Tracking]] — EntrySeen, EpisodeSeen, accuracy system
|
||||
- [[Streaming]] — In-app streaming system with 4 providers (8 servers)
|
||||
- [[Calendar]] — Upcoming episodes view
|
||||
- [[Discovery Videos]] — Personal video vault (upload + link to library entries)
|
||||
- [[Statistics]] — Dashboard charts and data
|
||||
- [[People]] — Cast, crew, filmography
|
||||
- [[Settings Page]] — App settings and maintenance cleanup
|
||||
|
||||
@@ -360,3 +360,39 @@ Join table: Entry ↔ Network. Composite PK: `(network_id, entry_id)`. Has `orde
|
||||
| `user_rating` | FLOAT |
|
||||
|
||||
**No timestamps. Currently unused — reserved for future franchise grouping.**
|
||||
|
||||
---
|
||||
|
||||
## Video
|
||||
|
||||
> [!info] File: `backend/models/Video.js`
|
||||
|
||||
Personal video record for the [[Discovery Videos]] page.
|
||||
|
||||
| Field | Type | Notes |
|
||||
|---|---|---|
|
||||
| `id` | INTEGER PK AUTO | |
|
||||
| `title` | STRING(500) | Derived from filename on upload, editable |
|
||||
| `description` | TEXT | User description |
|
||||
| `filename` | STRING(200) | UUID filename in `data/videos/` |
|
||||
| `original_name` | STRING(500) | Original upload name |
|
||||
| `mime_type` | STRING(100) | |
|
||||
| `size` | BIGINT | Bytes |
|
||||
| `duration` | INTEGER | Nullable — reserved for ffmpeg probing |
|
||||
| `thumbnail_path` | STRING(200) | Nullable — reserved for thumbnails |
|
||||
|
||||
**Has:** Entries (M:N via [[#VideoEntry]])
|
||||
|
||||
---
|
||||
|
||||
## VideoEntry
|
||||
|
||||
> [!info] File: `backend/models/VideoEntry.js`
|
||||
|
||||
Join table: Video ↔ Entry (M:N). Table name `video_entries`. FK `ON DELETE CASCADE` on both sides.
|
||||
|
||||
| Field | Type | Notes |
|
||||
|---|---|---|
|
||||
| `id` | INTEGER PK AUTO | |
|
||||
| `video_id` | INTEGER FK | → Video |
|
||||
| `entry_id` | INTEGER FK | → Entry |
|
||||
@@ -36,6 +36,17 @@ TMDB browse by category: popular, trending, top-rated, upcoming. Uses `useTmdb`
|
||||
|
||||
Route: `/discover/:category` where category = `popular-movies`, `trending-movies`, `popular-tv`, etc.
|
||||
|
||||
## DiscoveryVideosPage
|
||||
|
||||
Personal video vault — upload, link, and watch saved videos. See [[Discovery Videos]].
|
||||
|
||||
Route: `/discovery-videos`.
|
||||
|
||||
- Infinite-scroll grid of video cards (24/page)
|
||||
- "Add media" button → `AddVideoDialog` (drag & drop upload)
|
||||
- Cards render `<video preload="none">` — lazy playback, zero bytes until Play
|
||||
- Linked entry chips navigate to `/entry/:id`
|
||||
|
||||
## WatchlistPage
|
||||
|
||||
Grid of entries where `watchlist = true`. Similar to LibraryPage.
|
||||
|
||||
@@ -27,6 +27,7 @@ Every page uses `React.lazy()` with a custom `<Suspense>` skeleton fallback.
|
||||
| `/collections` | `CollectionsPage` | `CollectionsSkeleton` | [[Collections]] overview |
|
||||
| `/collections/:id` | `CollectionDetailsPage` | `CollectionDetailsSkeleton` | Collection with entries |
|
||||
| `/media` | `MediaPage` | `MediaSkeleton` | Media management |
|
||||
| `/discovery-videos` | `DiscoveryVideosPage` | `DiscoveryVideosSkeleton` | Personal video vault — see [[Discovery Videos]] |
|
||||
| `/calendar` | `CalendarPage` | `CalendarSkeleton` | [[Calendar]] upcoming episodes |
|
||||
| `/entry/:id` | `EntryDetailsPage` | `EntryDetailsSkeleton` | Entry details, seasons, cast |
|
||||
| `/entry/:entryId/season/:seasonId` | `SeasonPage` | `SeasonSkeleton` | Season episodes |
|
||||
|
||||
Generated
+916
-2576
File diff suppressed because it is too large.
Load diff
@@ -49,9 +49,8 @@
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"electron": "^34.0.1",
|
||||
"electron-builder": "^25.1.8"
|
||||
"electron": "^45.1.0",
|
||||
"electron-builder": "^26.18.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+748
-445
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,32 @@
|
||||
allowBuilds:
|
||||
msw: false
|
||||
overrides:
|
||||
'@babel/core@<=7.29.0': ^7.29.6
|
||||
'@hono/node-server@<1.19.15': ^1.19.15
|
||||
'@hono/node-server@>=1.19.10 <2.1.3': ^2.1.3
|
||||
'@modelcontextprotocol/sdk@<1.32.0': ^1.32.0
|
||||
axios@>=1.0.0 <1.20.0: ^1.20.0
|
||||
baseline-browser-mapping@>=2.0.0 <2.11.0: ^2.11.0
|
||||
body-parser@>=2.0.0 <2.4.0: ^2.4.0
|
||||
brace-expansion@<1.1.21: ^1.1.21
|
||||
brace-expansion@>=3.0.0 <5.0.7: ^5.0.7
|
||||
brace-expansion@>=4.0.0 <5.0.12: ^5.0.12
|
||||
browserslist@<=4.28.6: ^4.28.7
|
||||
fast-uri@>=3.0.0 <3.1.9: ^3.1.9
|
||||
follow-redirects@>=1.16.0 <1.16.1: ^1.16.1
|
||||
form-data@>=4.0.0 <4.0.6: ^4.0.6
|
||||
hono@<4.13.7: ^4.13.7
|
||||
hono@>=4.12.4 <4.13.11: ^4.13.11
|
||||
ip-address@<=10.7.3: ^10.7.4
|
||||
js-yaml@>=4.0.0 <4.3.2: ^4.3.2
|
||||
nanoid@<3.3.18: ^3.3.18
|
||||
postcss-selector-parser@>=7.0.0 <7.1.6: ^7.1.6
|
||||
postcss@<=8.5.22: ^8.5.23
|
||||
proxy-addr@>=1.1.0 <2.0.8: ^2.0.8
|
||||
qs@>=2.2.5 <6.16.0: ^6.16.0
|
||||
qs@>=6.7.0 <=6.16.0: ^6.16.1
|
||||
react-router@>=6.0.0 <7.18.0: ^7.18.0
|
||||
react-router@>=7.12.0 <7.18.2: ^7.18.2
|
||||
source-map-js@>=1.0.0 <1.2.2: ^1.2.2
|
||||
vite@>=8.0.0 <=8.1.5: ^8.1.6
|
||||
zod@<4.6.6: ^4.6.6
|
||||
@@ -0,0 +1,43 @@
|
||||
import { api } from "@/lib/api";
|
||||
import { normalizeDiscoveryVideo } from "@/lib/normalizers";
|
||||
import type {
|
||||
DiscoveryVideo,
|
||||
DiscoveryVideoPaginatedResponse,
|
||||
} from "@/types";
|
||||
|
||||
export interface UpdateVideoData {
|
||||
title?: string;
|
||||
description?: string;
|
||||
entryIds: number[];
|
||||
}
|
||||
|
||||
export const discoveryVideosApi = {
|
||||
getAll: (page = 1, limit = 24) =>
|
||||
api
|
||||
.get<DiscoveryVideoPaginatedResponse>("/discovery-videos", {
|
||||
params: { page, limit },
|
||||
})
|
||||
.then((r) => ({
|
||||
...r.data,
|
||||
videos: r.data.videos.map(normalizeDiscoveryVideo),
|
||||
})),
|
||||
|
||||
create: (formData: FormData, onProgress?: (percent: number) => void) =>
|
||||
api
|
||||
.post<DiscoveryVideo[]>("/discovery-videos", formData, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
onUploadProgress: (e) => {
|
||||
if (onProgress && e.total) {
|
||||
onProgress(Math.round((e.loaded / e.total) * 100));
|
||||
}
|
||||
},
|
||||
})
|
||||
.then((r) => r.data.map(normalizeDiscoveryVideo)),
|
||||
|
||||
update: (id: number, data: UpdateVideoData) =>
|
||||
api
|
||||
.put<DiscoveryVideo>(`/discovery-videos/${id}`, data)
|
||||
.then((r) => normalizeDiscoveryVideo(r.data)),
|
||||
|
||||
remove: (id: number) => api.delete(`/discovery-videos/${id}`).then((r) => r.data),
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useCallback, useRef, useEffect } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { getCollectionPosterUrl } from "@/lib/media-utils";
|
||||
import { getCollectionDisplayPosterUrl } from "@/lib/collection-media";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import type { Collection } from "@/types";
|
||||
|
||||
@@ -16,7 +16,7 @@ export function CollectionCard({ collection }: CollectionCardProps) {
|
||||
>
|
||||
<div className="relative aspect-[2/3] w-full overflow-hidden rounded-lg bg-muted">
|
||||
<img
|
||||
src={getCollectionPosterUrl(collection)}
|
||||
src={getCollectionDisplayPosterUrl(collection)}
|
||||
alt={collection.name}
|
||||
className="h-full w-full object-cover transition-transform group-hover:scale-105"
|
||||
loading="lazy"
|
||||
|
||||
@@ -13,6 +13,11 @@ import { Textarea } from "@/components/ui/textarea";
|
||||
import { ImageIcon } from "lucide-react";
|
||||
import { StarRating } from "@/components/ui/star-rating";
|
||||
import { useUpdateCollection } from "@/hooks/useCollections";
|
||||
import {
|
||||
DEFAULT_POSTER,
|
||||
getCollectionDisplayBackdropUrl,
|
||||
getCollectionDisplayPosterUrl,
|
||||
} from "@/lib/collection-media";
|
||||
import type { Collection } from "@/types";
|
||||
|
||||
interface CollectionEditDialogProps {
|
||||
@@ -34,6 +39,14 @@ export function CollectionEditDialog({
|
||||
const [posterPreview, setPosterPreview] = useState<string | null>(null);
|
||||
const [backdropPreview, setBackdropPreview] = useState<string | null>(null);
|
||||
|
||||
// What the collection page currently shows, so the user can see what an
|
||||
// upload would replace. The default placeholder doesn't count as a poster.
|
||||
const displayPoster = getCollectionDisplayPosterUrl(collection);
|
||||
const currentPoster = displayPoster === DEFAULT_POSTER ? null : displayPoster;
|
||||
const currentBackdrop = getCollectionDisplayBackdropUrl(collection);
|
||||
const shownPoster = posterPreview ?? currentPoster;
|
||||
const shownBackdrop = backdropPreview ?? currentBackdrop;
|
||||
|
||||
const posterInputRef = useRef<HTMLInputElement>(null);
|
||||
const backdropInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
@@ -131,15 +144,20 @@ export function CollectionEditDialog({
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
className="w-full h-20 flex flex-col gap-1"
|
||||
className="group relative w-full h-32 p-0 overflow-hidden flex flex-col gap-1"
|
||||
onClick={() => posterInputRef.current?.click()}
|
||||
>
|
||||
{posterPreview ? (
|
||||
<img
|
||||
src={posterPreview}
|
||||
alt="Poster preview"
|
||||
className="h-14 w-auto rounded object-cover"
|
||||
/>
|
||||
{shownPoster ? (
|
||||
<>
|
||||
<img
|
||||
src={shownPoster}
|
||||
alt="Poster preview"
|
||||
className="h-full w-full object-contain bg-muted"
|
||||
/>
|
||||
<span className="absolute inset-0 flex items-center justify-center bg-black/50 text-xs font-medium text-white opacity-0 transition-opacity group-hover:opacity-100">
|
||||
Change Poster
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<ImageIcon className="h-5 w-5 text-muted-foreground" />
|
||||
@@ -163,15 +181,20 @@ export function CollectionEditDialog({
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
className="w-full h-20 flex flex-col gap-1"
|
||||
className="group relative w-full h-32 p-0 overflow-hidden flex flex-col gap-1"
|
||||
onClick={() => backdropInputRef.current?.click()}
|
||||
>
|
||||
{backdropPreview ? (
|
||||
<img
|
||||
src={backdropPreview}
|
||||
alt="Backdrop preview"
|
||||
className="h-14 w-auto rounded object-cover"
|
||||
/>
|
||||
{shownBackdrop ? (
|
||||
<>
|
||||
<img
|
||||
src={shownBackdrop}
|
||||
alt="Backdrop preview"
|
||||
className="h-full w-full object-cover"
|
||||
/>
|
||||
<span className="absolute inset-0 flex items-center justify-center bg-black/50 text-xs font-medium text-white opacity-0 transition-opacity group-hover:opacity-100">
|
||||
Change Backdrop
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<ImageIcon className="h-5 w-5 text-muted-foreground" />
|
||||
|
||||
@@ -34,10 +34,12 @@ export function ConfirmDialog({
|
||||
}: ConfirmDialogProps) {
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent>
|
||||
<DialogContent className="overflow-hidden">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{title}</DialogTitle>
|
||||
<DialogDescription>{description}</DialogDescription>
|
||||
<DialogTitle className="break-all">{title}</DialogTitle>
|
||||
<DialogDescription className="break-all">
|
||||
{description}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
|
||||
@@ -9,6 +9,7 @@ import { Switch } from "@/components/ui/switch";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { useUpdateEntry, useUpdateEntryRatings } from "@/hooks/useEntries";
|
||||
import { StarRating } from "@/components/ui/star-rating";
|
||||
import { useLibraryStore } from "@/stores/useLibraryStore";
|
||||
import type { Entry } from "@/types";
|
||||
|
||||
interface EntrySettingsDialogProps {
|
||||
@@ -20,8 +21,12 @@ interface EntrySettingsDialogProps {
|
||||
export function EntrySettingsDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
entry,
|
||||
entry: entryProp,
|
||||
}: EntrySettingsDialogProps) {
|
||||
// The entry prop can be a stale snapshot (e.g. from a collection query), so
|
||||
// read the live copy from the library store, which updates on every mutation.
|
||||
const storeEntry = useLibraryStore((s) => s.entries.get(entryProp.id));
|
||||
const entry = storeEntry ? { ...entryProp, ...storeEntry } : entryProp;
|
||||
const updateEntry = useUpdateEntry();
|
||||
const updateRatings = useUpdateEntryRatings();
|
||||
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
import { useState } from "react";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Progress } from "@/components/ui/progress";
|
||||
import { VideoDropzone } from "./VideoDropzone";
|
||||
import { EntryMultiSelect } from "./EntryMultiSelect";
|
||||
import { useLibrary } from "@/hooks/useEntries";
|
||||
import { useUploadVideos, useUpdateVideo } from "@/hooks/useDiscoveryVideos";
|
||||
import type { DiscoveryVideo } from "@/types";
|
||||
|
||||
interface AddVideoDialogProps {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
/** When set, the dialog runs in edit mode (no file dropzone). */
|
||||
video?: DiscoveryVideo | null;
|
||||
}
|
||||
|
||||
export function AddVideoDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
video,
|
||||
}: AddVideoDialogProps) {
|
||||
const isEdit = !!video;
|
||||
|
||||
const [files, setFiles] = useState<File[]>([]);
|
||||
const [title, setTitle] = useState("");
|
||||
const [description, setDescription] = useState("");
|
||||
const [entryIds, setEntryIds] = useState<number[]>([]);
|
||||
const [progress, setProgress] = useState<number | null>(null);
|
||||
|
||||
const uploadVideos = useUploadVideos();
|
||||
const updateVideo = useUpdateVideo();
|
||||
|
||||
// Warm the library store so the entry picker has data.
|
||||
useLibrary();
|
||||
|
||||
// Reset form state whenever the dialog opens (or switches between
|
||||
// create/edit mode) — the render-phase pattern from the React docs,
|
||||
// which avoids cascading renders from setState-in-effect.
|
||||
const [prevOpen, setPrevOpen] = useState(open);
|
||||
const [prevVideo, setPrevVideo] = useState(video);
|
||||
if (open !== prevOpen || video !== prevVideo) {
|
||||
setPrevOpen(open);
|
||||
setPrevVideo(video);
|
||||
if (open) {
|
||||
setFiles([]);
|
||||
setTitle(video?.title ?? "");
|
||||
setDescription(video?.description ?? "");
|
||||
setEntryIds(video?.entries?.map((e) => e.id) ?? []);
|
||||
setProgress(null);
|
||||
}
|
||||
}
|
||||
|
||||
const isBusy = uploadVideos.isPending || updateVideo.isPending;
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (isEdit && video) {
|
||||
updateVideo.mutate(
|
||||
{ id: video.id, data: { title, description, entryIds } },
|
||||
{ onSuccess: () => onOpenChange(false) },
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (files.length === 0) return;
|
||||
|
||||
const formData = new FormData();
|
||||
files.forEach((file) => formData.append("videos", file));
|
||||
formData.append("description", description);
|
||||
formData.append("entryIds", JSON.stringify(entryIds));
|
||||
|
||||
uploadVideos.mutate(
|
||||
{ formData, onProgress: setProgress },
|
||||
{ onSuccess: () => onOpenChange(false) },
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="overflow-hidden sm:max-w-xl">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{isEdit ? "Edit video" : "Add media"}</DialogTitle>
|
||||
<DialogDescription>
|
||||
{isEdit
|
||||
? "Update the video details and linked library entries."
|
||||
: "Drop your videos, add a description, and link them to library entries."}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="min-w-0 space-y-4">
|
||||
{!isEdit && (
|
||||
<VideoDropzone
|
||||
files={files}
|
||||
onChange={setFiles}
|
||||
disabled={isBusy}
|
||||
/>
|
||||
)}
|
||||
|
||||
{isEdit && (
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="video-title">Title</Label>
|
||||
<Input
|
||||
id="video-title"
|
||||
value={title}
|
||||
onChange={(e) => setTitle(e.target.value)}
|
||||
disabled={isBusy}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="video-description">Description</Label>
|
||||
<Textarea
|
||||
id="video-description"
|
||||
value={description}
|
||||
onChange={(e) => setDescription(e.target.value)}
|
||||
placeholder="What is this video about? Why did you save it?"
|
||||
rows={3}
|
||||
disabled={isBusy}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<EntryMultiSelect
|
||||
value={entryIds}
|
||||
onChange={setEntryIds}
|
||||
disabled={isBusy}
|
||||
/>
|
||||
|
||||
{progress !== null && !isEdit && (
|
||||
<Progress value={progress} />
|
||||
)}
|
||||
</div>
|
||||
|
||||
<DialogFooter>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => onOpenChange(false)}
|
||||
disabled={isBusy}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleSubmit}
|
||||
disabled={isBusy || (!isEdit && files.length === 0)}
|
||||
>
|
||||
{isBusy && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
||||
{isEdit
|
||||
? "Save changes"
|
||||
: files.length > 0
|
||||
? `Upload (${files.length})`
|
||||
: "Upload"}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import { Link2, Search, X } from "lucide-react";
|
||||
import {
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from "@/components/ui/popover";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { useLibraryEntries } from "@/stores/useLibraryStore";
|
||||
import { useDebounce } from "@/hooks/useDebounce";
|
||||
import { getPosterUrl } from "@/lib/media-utils";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface EntryMultiSelectProps {
|
||||
value: number[];
|
||||
onChange: (ids: number[]) => void;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export function EntryMultiSelect({
|
||||
value,
|
||||
onChange,
|
||||
disabled,
|
||||
}: EntryMultiSelectProps) {
|
||||
const entries = useLibraryEntries();
|
||||
const [search, setSearch] = useState("");
|
||||
const debouncedSearch = useDebounce(search, 250);
|
||||
|
||||
const hasQuery = debouncedSearch.trim().length > 0;
|
||||
|
||||
// Only list entries once the user starts searching (debounced)
|
||||
const visibleEntries = useMemo(() => {
|
||||
if (!hasQuery) return [];
|
||||
const q = debouncedSearch.trim().toLowerCase();
|
||||
return entries
|
||||
.filter((e) => !e.hidden)
|
||||
.filter((e) => e.title.toLowerCase().includes(q));
|
||||
}, [entries, debouncedSearch, hasQuery]);
|
||||
|
||||
const selectedEntries = useMemo(
|
||||
() => entries.filter((e) => value.includes(e.id)),
|
||||
[entries, value],
|
||||
);
|
||||
|
||||
const toggle = (id: number) => {
|
||||
onChange(
|
||||
value.includes(id) ? value.filter((v) => v !== id) : [...value, id],
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<Popover>
|
||||
<PopoverTrigger
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
"inline-flex h-8 items-center gap-2 rounded-lg border border-input bg-transparent px-3 text-sm transition-colors hover:bg-muted disabled:pointer-events-none disabled:opacity-50",
|
||||
)}
|
||||
>
|
||||
<Link2 className="size-4" />
|
||||
Link library entries
|
||||
{value.length > 0 && (
|
||||
<span className="rounded-full bg-primary px-1.5 py-0.5 text-[10px] font-medium text-primary-foreground">
|
||||
{value.length}
|
||||
</span>
|
||||
)}
|
||||
</PopoverTrigger>
|
||||
|
||||
<PopoverContent className="w-80 p-0">
|
||||
<div className="border-b p-2">
|
||||
<div className="relative">
|
||||
<Search className="absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground" />
|
||||
<Input
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
placeholder="Search library…"
|
||||
className="pl-7"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ScrollArea className="h-64">
|
||||
{!hasQuery ? (
|
||||
<p className="p-4 text-center text-sm text-muted-foreground">
|
||||
Type to search your library…
|
||||
</p>
|
||||
) : visibleEntries.length === 0 ? (
|
||||
<p className="p-4 text-center text-sm text-muted-foreground">
|
||||
No entries found.
|
||||
</p>
|
||||
) : (
|
||||
<div className="p-1">
|
||||
{visibleEntries.map((entry) => (
|
||||
<div
|
||||
key={entry.id}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
onClick={() => toggle(entry.id)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" || e.key === " ") {
|
||||
e.preventDefault();
|
||||
toggle(entry.id);
|
||||
}
|
||||
}}
|
||||
className="flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 outline-none hover:bg-accent focus-visible:bg-accent"
|
||||
>
|
||||
<Checkbox
|
||||
checked={value.includes(entry.id)}
|
||||
onCheckedChange={() => toggle(entry.id)}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
tabIndex={-1}
|
||||
/>
|
||||
<img
|
||||
src={getPosterUrl(entry)}
|
||||
alt=""
|
||||
loading="lazy"
|
||||
className="h-9 w-6 shrink-0 rounded object-cover"
|
||||
/>
|
||||
<span className="flex-1 truncate text-sm">
|
||||
{entry.title}
|
||||
</span>
|
||||
{entry.is_tvseries && (
|
||||
<span className="shrink-0 text-[10px] uppercase text-muted-foreground">
|
||||
TV
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</ScrollArea>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
|
||||
{selectedEntries.length > 0 && (
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{selectedEntries.map((entry) => (
|
||||
<span
|
||||
key={entry.id}
|
||||
className="inline-flex items-center gap-1 rounded-full bg-accent px-2 py-0.5 text-xs text-accent-foreground"
|
||||
>
|
||||
{entry.title}
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-xs"
|
||||
disabled={disabled}
|
||||
onClick={() => toggle(entry.id)}
|
||||
className="text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
<X />
|
||||
</Button>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
import { useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { Film, Pencil, Play, Trash2 } from "lucide-react";
|
||||
import { Card } from "@/components/ui/card";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { getVideoThumbnailUrl } from "@/lib/api";
|
||||
import { formatBytes } from "@/lib/format";
|
||||
import type { DiscoveryVideo } from "@/types";
|
||||
|
||||
interface VideoCardProps {
|
||||
video: DiscoveryVideo;
|
||||
onPlay: (video: DiscoveryVideo) => void;
|
||||
onEdit: (video: DiscoveryVideo) => void;
|
||||
onDelete: (video: DiscoveryVideo) => void;
|
||||
}
|
||||
|
||||
export function VideoCard({ video, onPlay, onEdit, onDelete }: VideoCardProps) {
|
||||
// If the thumbnail request fails (e.g. unplayable file), fall back to
|
||||
// the placeholder instead of showing a broken image.
|
||||
const [thumbFailed, setThumbFailed] = useState(false);
|
||||
|
||||
return (
|
||||
<Card className="group flex h-full flex-col overflow-hidden">
|
||||
{/* Thumbnail + play overlay → opens the player dialog */}
|
||||
<div
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
onClick={() => onPlay(video)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" || e.key === " ") {
|
||||
e.preventDefault();
|
||||
onPlay(video);
|
||||
}
|
||||
}}
|
||||
className="relative h-44 w-full cursor-pointer overflow-hidden bg-muted outline-none"
|
||||
>
|
||||
{/* Placeholder (visible while the thumbnail loads or if it fails) */}
|
||||
<div className="absolute inset-0 flex items-center justify-center">
|
||||
<Film className="h-8 w-8 text-muted-foreground/40" />
|
||||
</div>
|
||||
|
||||
{/* Requesting the thumbnail also triggers on-demand generation
|
||||
server-side when the video doesn't have one yet. */}
|
||||
{!thumbFailed && (
|
||||
<img
|
||||
src={getVideoThumbnailUrl(video.id)}
|
||||
alt={video.title}
|
||||
loading="lazy"
|
||||
onError={() => setThumbFailed(true)}
|
||||
className="relative h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"
|
||||
/>
|
||||
)}
|
||||
|
||||
<div className="absolute inset-0 flex items-center justify-center bg-black/30 transition-colors hover:bg-black/20">
|
||||
<span className="flex h-12 w-12 items-center justify-center rounded-full bg-primary text-primary-foreground shadow-lg transition-transform group-hover:scale-110">
|
||||
<Play className="ml-1 h-5 w-5" />
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className="absolute right-2 top-2 z-10 flex gap-1 opacity-0 transition-opacity group-hover:opacity-100"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="icon-sm"
|
||||
onClick={() => onEdit(video)}
|
||||
aria-label="Edit video"
|
||||
>
|
||||
<Pencil />
|
||||
</Button>
|
||||
<Button
|
||||
variant="destructive"
|
||||
size="icon-sm"
|
||||
onClick={() => onDelete(video)}
|
||||
aria-label="Delete video"
|
||||
>
|
||||
<Trash2 />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-2 p-3">
|
||||
<div className="flex h-5 items-start justify-between gap-2">
|
||||
<h3
|
||||
className="line-clamp-1 min-w-0 break-all text-sm font-medium"
|
||||
title={video.title}
|
||||
>
|
||||
{video.title}
|
||||
</h3>
|
||||
<span className="shrink-0 text-[10px] text-muted-foreground">
|
||||
{formatBytes(video.size)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Fixed-height description area keeps all cards the same size */}
|
||||
<p className="h-8 line-clamp-2 text-xs text-muted-foreground">
|
||||
{video.description || ""}
|
||||
</p>
|
||||
|
||||
{/* Single-row chips — extra entries get clipped, never grow the card */}
|
||||
<div className="h-5 overflow-hidden">
|
||||
{video.entries && video.entries.length > 0 && (
|
||||
<div className="flex gap-1.5 overflow-hidden">
|
||||
{video.entries.map((entry) => (
|
||||
<Link
|
||||
key={entry.id}
|
||||
to={`/entry/${entry.id}`}
|
||||
className="shrink-0 rounded-full bg-accent px-2 py-0.5 text-[10px] text-accent-foreground transition-colors hover:bg-accent/70"
|
||||
>
|
||||
{entry.title}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
import { useRef, useState, type DragEvent } from "react";
|
||||
import { FileVideo, UploadCloud, X } from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { formatBytes } from "@/lib/format";
|
||||
|
||||
const ALLOWED_MIME = [
|
||||
"video/mp4",
|
||||
"video/webm",
|
||||
"video/quicktime",
|
||||
"video/x-matroska",
|
||||
"video/x-msvideo",
|
||||
];
|
||||
const ALLOWED_EXT = ["mp4", "webm", "mov", "m4v", "mkv", "avi"];
|
||||
const MAX_FILES = 10;
|
||||
|
||||
function isAccepted(file: File) {
|
||||
if (ALLOWED_MIME.includes(file.type)) return true;
|
||||
const ext = file.name.split(".").pop()?.toLowerCase() ?? "";
|
||||
return ALLOWED_EXT.includes(ext);
|
||||
}
|
||||
|
||||
interface VideoDropzoneProps {
|
||||
files: File[];
|
||||
onChange: (files: File[]) => void;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export function VideoDropzone({ files, onChange, disabled }: VideoDropzoneProps) {
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const [dragActive, setDragActive] = useState(false);
|
||||
|
||||
const addFiles = (incoming: FileList | null) => {
|
||||
if (!incoming || disabled) return;
|
||||
|
||||
const existing = new Set(files.map((f) => `${f.name}:${f.size}`));
|
||||
const fresh = Array.from(incoming)
|
||||
.filter(isAccepted)
|
||||
.filter((f) => !existing.has(`${f.name}:${f.size}`))
|
||||
.slice(0, MAX_FILES - files.length);
|
||||
|
||||
if (fresh.length > 0) {
|
||||
onChange([...files, ...fresh]);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDrop = (e: DragEvent<HTMLDivElement>) => {
|
||||
e.preventDefault();
|
||||
setDragActive(false);
|
||||
addFiles(e.dataTransfer.files);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<div
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
onClick={() => inputRef.current?.click()}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" || e.key === " ") {
|
||||
e.preventDefault();
|
||||
inputRef.current?.click();
|
||||
}
|
||||
}}
|
||||
onDragOver={(e) => {
|
||||
e.preventDefault();
|
||||
setDragActive(true);
|
||||
}}
|
||||
onDragLeave={() => setDragActive(false)}
|
||||
onDrop={handleDrop}
|
||||
className={cn(
|
||||
"flex cursor-pointer flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed p-8 text-center outline-none transition-colors",
|
||||
dragActive ? "border-primary bg-primary/5" : "border-border",
|
||||
disabled && "pointer-events-none opacity-50",
|
||||
)}
|
||||
>
|
||||
<UploadCloud className="h-8 w-8 text-muted-foreground" />
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Drag & drop videos here, or{" "}
|
||||
<span className="font-medium text-primary underline">
|
||||
browse files
|
||||
</span>
|
||||
</p>
|
||||
<p className="text-xs text-muted-foreground/70">
|
||||
mp4, webm, mov, m4v, mkv, avi — up to 10 files per upload
|
||||
</p>
|
||||
<input
|
||||
ref={inputRef}
|
||||
type="file"
|
||||
accept="video/*"
|
||||
multiple
|
||||
className="hidden"
|
||||
onChange={(e) => {
|
||||
addFiles(e.target.files);
|
||||
e.target.value = "";
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{files.length > 0 && (
|
||||
<ul className="max-h-44 space-y-1.5 overflow-y-auto pr-1">
|
||||
{files.map((file, index) => (
|
||||
<li
|
||||
key={`${file.name}-${file.size}-${index}`}
|
||||
className="flex items-center gap-2 rounded-md border px-3 py-2 text-sm"
|
||||
>
|
||||
<FileVideo className="size-4 shrink-0 text-muted-foreground" />
|
||||
{/* break-all: a long filename wraps instead of forcing the
|
||||
dialog wider; line-clamp caps it at two lines */}
|
||||
<span
|
||||
className="min-w-0 flex-1 break-all line-clamp-2"
|
||||
title={file.name}
|
||||
>
|
||||
{file.name}
|
||||
</span>
|
||||
<span className="shrink-0 text-xs text-muted-foreground">
|
||||
{formatBytes(file.size)}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
onClick={() =>
|
||||
onChange(files.filter((_, idx) => idx !== index))
|
||||
}
|
||||
className="shrink-0 text-muted-foreground transition-colors hover:text-foreground"
|
||||
>
|
||||
<X className="size-4" />
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { ChevronDown, ChevronUp, Pencil } from "lucide-react";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { getVideoStreamUrl } from "@/lib/api";
|
||||
import { formatBytes } from "@/lib/format";
|
||||
import type { DiscoveryVideo } from "@/types";
|
||||
|
||||
interface VideoPlayerDialogProps {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
video: DiscoveryVideo | null;
|
||||
onPrevious?: () => void;
|
||||
onNext?: () => void;
|
||||
hasPrevious?: boolean;
|
||||
hasNext?: boolean;
|
||||
onEdit?: (video: DiscoveryVideo) => void;
|
||||
}
|
||||
|
||||
export function VideoPlayerDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
video,
|
||||
onPrevious,
|
||||
onNext,
|
||||
hasPrevious,
|
||||
hasNext,
|
||||
onEdit,
|
||||
}: VideoPlayerDialogProps) {
|
||||
const videoRef = useRef<HTMLVideoElement>(null);
|
||||
|
||||
// Autoplay when the dialog opens or the video changes. The play() call may
|
||||
// be blocked if the browser considers the gesture consumed — the user can
|
||||
// always press play manually.
|
||||
useEffect(() => {
|
||||
if (open && video) {
|
||||
videoRef.current?.play().catch(() => {});
|
||||
}
|
||||
}, [open, video]);
|
||||
|
||||
// Arrow-key navigation. ↑/↓ always switch videos (when available) and are
|
||||
// captured in the CAPTURE phase with preventDefault, so they never reach
|
||||
// the <video> element's native controls or move focus onto the player.
|
||||
// ←/→ switch videos too, except when the player itself is focused — there
|
||||
// they keep their native seek behaviour.
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
const isVideoFocused = e.target instanceof HTMLVideoElement;
|
||||
|
||||
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
||||
e.preventDefault();
|
||||
if (e.key === "ArrowUp" && hasPrevious) onPrevious?.();
|
||||
if (e.key === "ArrowDown" && hasNext) onNext?.();
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
!isVideoFocused &&
|
||||
(e.key === "ArrowLeft" || e.key === "ArrowRight")
|
||||
) {
|
||||
e.preventDefault();
|
||||
if (e.key === "ArrowLeft" && hasPrevious) onPrevious?.();
|
||||
if (e.key === "ArrowRight" && hasNext) onNext?.();
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", onKey, true);
|
||||
return () => window.removeEventListener("keydown", onKey, true);
|
||||
}, [open, hasPrevious, hasNext, onPrevious, onNext]);
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="overflow-hidden sm:max-w-4xl">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="truncate pr-8">{video?.title}</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
{open && video && (
|
||||
<div className="space-y-4">
|
||||
<div className="relative bg-black">
|
||||
{/* tabIndex=-1 keeps the player out of the focus order so the
|
||||
dialog doesn't focus it and arrow keys stay ours */}
|
||||
<video
|
||||
key={video.id}
|
||||
ref={videoRef}
|
||||
src={getVideoStreamUrl(video.id)}
|
||||
controls
|
||||
autoPlay
|
||||
tabIndex={-1}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
||||
e.preventDefault();
|
||||
}
|
||||
}}
|
||||
className="max-h-[65vh] w-full"
|
||||
/>
|
||||
|
||||
{hasPrevious && (
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="icon"
|
||||
onClick={onPrevious}
|
||||
aria-label="Previous video"
|
||||
className="absolute left-2 top-1/2 -translate-y-1/2 opacity-70"
|
||||
>
|
||||
<ChevronUp />
|
||||
</Button>
|
||||
)}
|
||||
{hasNext && (
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="icon"
|
||||
onClick={onNext}
|
||||
aria-label="Next video"
|
||||
className="absolute right-2 top-1/2 -translate-y-1/2 opacity-70"
|
||||
>
|
||||
<ChevronDown />
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center justify-between gap-2">
|
||||
<span className="text-xs text-muted-foreground">
|
||||
{formatBytes(video.size)}
|
||||
</span>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-1.5">
|
||||
{video.entries?.map((entry) => (
|
||||
<Link
|
||||
key={entry.id}
|
||||
to={`/entry/${entry.id}`}
|
||||
onClick={() => onOpenChange(false)}
|
||||
className="rounded-full bg-accent px-2 py-0.5 text-[10px] text-accent-foreground transition-colors hover:bg-accent/70"
|
||||
>
|
||||
{entry.title}
|
||||
</Link>
|
||||
))}
|
||||
{onEdit && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="xs"
|
||||
onClick={() => onEdit(video)}
|
||||
>
|
||||
<Pencil />
|
||||
Edit
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{video.description && (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{video.description}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{(hasPrevious || hasNext) && (
|
||||
<p className="text-center text-[10px] text-muted-foreground/60">
|
||||
Use ↑ / ↓ to switch videos
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
Moon,
|
||||
Sun,
|
||||
Film,
|
||||
Video,
|
||||
} from "lucide-react";
|
||||
import { useThemeStore } from "@/stores/useThemeStore";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
@@ -27,6 +28,7 @@ const libraryNav = [
|
||||
{ to: "/watchlist", icon: ListVideo, label: "Watchlist" },
|
||||
{ to: "/collections", icon: FolderOpen, label: "Collections" },
|
||||
{ to: "/media", icon: Image, label: "Media" },
|
||||
{ to: "/discovery-videos", icon: Video, label: "Discover" },
|
||||
];
|
||||
|
||||
const otherNav = [
|
||||
|
||||
@@ -154,28 +154,39 @@ export function CollectionDetailsSkeleton() {
|
||||
export function EntryDetailsSkeleton() {
|
||||
return (
|
||||
<div className="animate-in fade-in duration-300">
|
||||
<div className="h-52 -mx-6 -mt-6 bg-muted animate-pulse rounded-b-lg" />
|
||||
<div className="max-w-4xl mx-auto flex gap-8 -mt-24">
|
||||
<div className="w-44 shrink-0 space-y-3">
|
||||
<Skeleton className="aspect-[2/3] w-full rounded-xl" />
|
||||
<Skeleton className="h-9 w-full rounded-lg" />
|
||||
<Skeleton className="h-9 w-full rounded-lg" />
|
||||
<Skeleton className="h-9 w-full rounded-lg" />
|
||||
<div className="relative -mx-4 -mt-4 bg-muted/40 md:-mx-6 md:-mt-6">
|
||||
<div className="mx-auto flex max-w-6xl flex-col items-center gap-6 px-4 pb-8 pt-28 sm:flex-row sm:items-end sm:gap-8 sm:pt-44 md:px-6">
|
||||
<Skeleton className="aspect-[2/3] w-40 shrink-0 rounded-xl sm:w-52 lg:w-60" />
|
||||
<div className="w-full flex-1 space-y-4">
|
||||
<Skeleton className="h-5 w-24 rounded-full" />
|
||||
<Skeleton className="h-12 w-3/4 max-w-md" />
|
||||
<Skeleton className="h-4 w-48" />
|
||||
<div className="flex gap-1.5">
|
||||
<Skeleton className="h-6 w-16 rounded-full" />
|
||||
<Skeleton className="h-6 w-20 rounded-full" />
|
||||
<Skeleton className="h-6 w-14 rounded-full" />
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Skeleton className="h-11 w-36 rounded-md" />
|
||||
<Skeleton className="h-11 w-28 rounded-md" />
|
||||
<Skeleton className="h-11 w-11 rounded-full" />
|
||||
<Skeleton className="h-11 w-11 rounded-full" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex-1 space-y-4 pt-24">
|
||||
<Skeleton className="h-9 w-72" />
|
||||
<Skeleton className="h-4 w-32" />
|
||||
<div className="flex gap-2">
|
||||
<Skeleton className="h-5 w-12" />
|
||||
<Skeleton className="h-5 w-16" />
|
||||
<Skeleton className="h-5 w-20" />
|
||||
</div>
|
||||
<div className="mx-auto mt-4 grid max-w-6xl gap-10 lg:grid-cols-[minmax(0,1fr)_300px]">
|
||||
<div className="space-y-3">
|
||||
<Skeleton className="h-6 w-28" />
|
||||
<Skeleton className="h-24 w-full" />
|
||||
</div>
|
||||
<div className="space-y-4">
|
||||
<div className="grid grid-cols-3 gap-2">
|
||||
<Skeleton className="h-20 rounded-xl" />
|
||||
<Skeleton className="h-20 rounded-xl" />
|
||||
<Skeleton className="h-20 rounded-xl" />
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Skeleton className="h-8 w-24 rounded-full" />
|
||||
<Skeleton className="h-8 w-24 rounded-full" />
|
||||
<Skeleton className="h-8 w-20 rounded-full" />
|
||||
</div>
|
||||
<Skeleton className="h-20 w-full" />
|
||||
<Skeleton className="h-40 rounded-xl" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -314,3 +325,26 @@ export function SettingsSkeleton() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function DiscoveryVideosSkeleton() {
|
||||
return (
|
||||
<div className="space-y-6 animate-in fade-in duration-300">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="space-y-2">
|
||||
<Skeleton className="h-8 w-40" />
|
||||
<Skeleton className="h-4 w-64" />
|
||||
</div>
|
||||
<Skeleton className="h-8 w-28 rounded-lg" />
|
||||
</div>
|
||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4">
|
||||
{Array.from({ length: 6 }).map((_, i) => (
|
||||
<div key={i} className="space-y-2">
|
||||
<Skeleton className="aspect-video w-full rounded-lg" />
|
||||
<Skeleton className="h-4 w-3/4" />
|
||||
<Skeleton className="h-3 w-full" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -83,7 +83,7 @@ function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="dialog-header"
|
||||
className={cn("flex flex-col gap-2", className)}
|
||||
className={cn("flex min-w-0 flex-col gap-2", className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import { useInfiniteQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { toast } from "sonner";
|
||||
import {
|
||||
discoveryVideosApi,
|
||||
type UpdateVideoData,
|
||||
} from "@/api/discoveryVideos";
|
||||
|
||||
export const discoveryVideoKeys = {
|
||||
all: ["discovery-videos"] as const,
|
||||
};
|
||||
|
||||
export function useDiscoveryVideos() {
|
||||
return useInfiniteQuery({
|
||||
queryKey: discoveryVideoKeys.all,
|
||||
queryFn: ({ pageParam }) =>
|
||||
discoveryVideosApi.getAll((pageParam as number) ?? 1, 24),
|
||||
initialPageParam: 1,
|
||||
getNextPageParam: (lastPage) =>
|
||||
lastPage.page < lastPage.totalPages ? lastPage.page + 1 : undefined,
|
||||
});
|
||||
}
|
||||
|
||||
export function useUploadVideos() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: ({
|
||||
formData,
|
||||
onProgress,
|
||||
}: {
|
||||
formData: FormData;
|
||||
onProgress?: (percent: number) => void;
|
||||
}) => discoveryVideosApi.create(formData, onProgress),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: discoveryVideoKeys.all });
|
||||
toast.success("Video uploaded successfully");
|
||||
},
|
||||
onError: () => {
|
||||
toast.error("Failed to upload video");
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateVideo() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: ({ id, data }: { id: number; data: UpdateVideoData }) =>
|
||||
discoveryVideosApi.update(id, data),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: discoveryVideoKeys.all });
|
||||
toast.success("Video updated");
|
||||
},
|
||||
onError: () => {
|
||||
toast.error("Failed to update video");
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteVideo() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (id: number) => discoveryVideosApi.remove(id),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: discoveryVideoKeys.all });
|
||||
toast.success("Video deleted");
|
||||
},
|
||||
onError: () => {
|
||||
toast.error("Failed to delete video");
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -28,5 +28,19 @@ export const getMediaUrl = (
|
||||
file: string,
|
||||
) => `${API_BASE_URL}/media/${category}/${type}/${size}/${file}`;
|
||||
|
||||
export const getVideoStreamUrl = (id: number) => {
|
||||
const token = useAuthStore.getState().token;
|
||||
return `${API_BASE_URL}/discovery-videos/${id}/stream${
|
||||
token ? `?token=${encodeURIComponent(token)}` : ''
|
||||
}`;
|
||||
};
|
||||
|
||||
export const getVideoThumbnailUrl = (id: number) => {
|
||||
const token = useAuthStore.getState().token;
|
||||
return `${API_BASE_URL}/discovery-videos/${id}/thumbnail${
|
||||
token ? `?token=${encodeURIComponent(token)}` : ''
|
||||
}`;
|
||||
};
|
||||
|
||||
export const getTmdbImageUrl = (path: string, size = 'w342') =>
|
||||
`https://image.tmdb.org/t/p/${size}${path}`;
|
||||
@@ -0,0 +1,65 @@
|
||||
import { getMediaUrl, getTmdbImageUrl } from "@/lib/api";
|
||||
import { getBackdropUrl, getPosterUrl } from "@/lib/media-utils";
|
||||
import type { Collection, Media } from "@/types";
|
||||
|
||||
export const DEFAULT_POSTER = "/images/default-poster.png";
|
||||
|
||||
/**
|
||||
* Collection poster: uploaded poster, then the collection's own TMDB poster,
|
||||
* then the poster of its first entry, then the default placeholder.
|
||||
*/
|
||||
export function getCollectionDisplayPosterUrl(collection: Collection): string {
|
||||
const selectedPoster = collection.medias?.find(
|
||||
(m: Media) => m.type === "poster" && m.is_selected,
|
||||
);
|
||||
if (selectedPoster?.path) {
|
||||
return getMediaUrl(
|
||||
"collections",
|
||||
"posters",
|
||||
"preview",
|
||||
selectedPoster.path,
|
||||
);
|
||||
}
|
||||
|
||||
if (collection.poster_path) {
|
||||
return getTmdbImageUrl(collection.poster_path, "w342");
|
||||
}
|
||||
|
||||
const firstEntry = collection.entries?.[0];
|
||||
if (firstEntry) {
|
||||
return getPosterUrl({ ...firstEntry, isInLibrary: true });
|
||||
}
|
||||
|
||||
return DEFAULT_POSTER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collection backdrop: uploaded backdrop, then the collection's own TMDB
|
||||
* backdrop, then the first entry that has one. Null when nothing is available.
|
||||
*/
|
||||
export function getCollectionDisplayBackdropUrl(
|
||||
collection: Collection,
|
||||
): string | null {
|
||||
const selectedBackdrop = collection.medias?.find(
|
||||
(m: Media) => m.type === "backdrop" && m.is_selected,
|
||||
);
|
||||
if (selectedBackdrop?.path) {
|
||||
return getMediaUrl(
|
||||
"collections",
|
||||
"backdrops",
|
||||
"full",
|
||||
selectedBackdrop.path,
|
||||
);
|
||||
}
|
||||
|
||||
if (collection.backdrop_path) {
|
||||
return getTmdbImageUrl(collection.backdrop_path, "w1280");
|
||||
}
|
||||
|
||||
for (const entry of collection.entries ?? []) {
|
||||
const url = getBackdropUrl(entry);
|
||||
if (url) return url;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
export function formatBytes(bytes: number): string {
|
||||
if (!bytes || bytes <= 0) return "0 B";
|
||||
const units = ["B", "KB", "MB", "GB", "TB"];
|
||||
let value = bytes;
|
||||
let unit = 0;
|
||||
while (value >= 1024 && unit < units.length - 1) {
|
||||
value /= 1024;
|
||||
unit += 1;
|
||||
}
|
||||
return `${value.toFixed(unit === 0 ? 0 : 1)} ${units[unit]}`;
|
||||
}
|
||||
@@ -29,6 +29,22 @@ export function getPosterUrl(entry: Entry): string {
|
||||
return DEFAULT_POSTER;
|
||||
}
|
||||
|
||||
/** Same source as getPosterUrl, but at original resolution. */
|
||||
export function getFullPosterUrl(entry: Entry): string {
|
||||
const selectedPoster = entry.isInLibrary
|
||||
? entry.medias?.find((m: Media) => m.type === "poster" && m.is_selected)
|
||||
: undefined;
|
||||
if (selectedPoster?.path) {
|
||||
return getMediaUrl("entries", "posters", "full", selectedPoster.path);
|
||||
}
|
||||
|
||||
if (entry.poster_path) {
|
||||
return getTmdbImageUrl(entry.poster_path, "original");
|
||||
}
|
||||
|
||||
return DEFAULT_POSTER;
|
||||
}
|
||||
|
||||
export function getBackdropUrl(entry: Entry): string {
|
||||
if (entry.medias) {
|
||||
const selectedBackdrop = entry.medias.find(
|
||||
@@ -121,3 +137,24 @@ export function getYear(dateStr: string | null): string {
|
||||
if (!dateStr) return "";
|
||||
return new Date(dateStr).getFullYear().toString();
|
||||
}
|
||||
|
||||
export function calculateAge(
|
||||
birthday: string | null | undefined,
|
||||
deathday?: string | null,
|
||||
): number | null {
|
||||
if (!birthday) return null;
|
||||
|
||||
const birth = new Date(birthday);
|
||||
if (isNaN(birth.getTime())) return null;
|
||||
|
||||
let end = deathday ? new Date(deathday) : new Date();
|
||||
if (deathday && isNaN(end.getTime())) end = new Date();
|
||||
|
||||
let age = end.getFullYear() - birth.getFullYear();
|
||||
const monthDiff = end.getMonth() - birth.getMonth();
|
||||
if (monthDiff < 0 || (monthDiff === 0 && end.getDate() < birth.getDate())) {
|
||||
age--;
|
||||
}
|
||||
|
||||
return age;
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
* - Genres come as string arrays from the backend mapper
|
||||
*/
|
||||
|
||||
import type { Entry, Collection, Media, Credit, Genre } from "@/types";
|
||||
import type { Entry, Collection, Media, Credit, Genre, DiscoveryVideo } from "@/types";
|
||||
|
||||
/* ---------- Media ---------- */
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@@ -87,6 +87,25 @@ export function normalizeEntry(raw: any): Entry {
|
||||
};
|
||||
}
|
||||
|
||||
/* ---------- Discovery Video ---------- */
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export function normalizeDiscoveryVideo(raw: any): DiscoveryVideo {
|
||||
return {
|
||||
id: raw.id,
|
||||
title: raw.title,
|
||||
description: raw.description ?? null,
|
||||
filename: raw.filename,
|
||||
original_name: raw.original_name ?? raw.originalName ?? "",
|
||||
mime_type: raw.mime_type ?? raw.mimeType ?? "",
|
||||
size: raw.size ?? 0,
|
||||
duration: raw.duration ?? null,
|
||||
thumbnail_path: raw.thumbnail_path ?? raw.thumbnailPath ?? null,
|
||||
createdAt: raw.createdAt,
|
||||
updatedAt: raw.updatedAt,
|
||||
entries: raw.entries ? raw.entries.map(normalizeEntry) : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
/* ---------- Collection ---------- */
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export function normalizeCollection(raw: any): Collection {
|
||||
|
||||
@@ -7,8 +7,10 @@ import {
|
||||
useRemoveEntryFromCollection,
|
||||
} from "@/hooks/useCollections";
|
||||
import { EntryLibraryGrid } from "@/components/entries/EntryLibraryGrid";
|
||||
import { getCollectionPosterUrl, getBackdropUrl } from "@/lib/media-utils";
|
||||
import { getTmdbImageUrl } from "@/lib/api";
|
||||
import {
|
||||
getCollectionDisplayBackdropUrl,
|
||||
getCollectionDisplayPosterUrl,
|
||||
} from "@/lib/collection-media";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
@@ -101,21 +103,11 @@ export function CollectionDetailsPage() {
|
||||
});
|
||||
}, [entries, sortField, sortDir]);
|
||||
|
||||
// Fallback backdrop: use first entry's backdrop if collection has none
|
||||
const backdropUrl = useMemo(() => {
|
||||
if (collection?.backdrop_path)
|
||||
return getTmdbImageUrl(collection.backdrop_path, "w1280");
|
||||
// Try to find a backdrop from one of the entries
|
||||
const entryWithBackdrop = entries.find((e) => e.banner_path);
|
||||
if (entryWithBackdrop?.banner_path)
|
||||
return getTmdbImageUrl(entryWithBackdrop.banner_path, "w1280");
|
||||
// Try entry medias
|
||||
for (const e of entries) {
|
||||
const url = getBackdropUrl(e);
|
||||
if (url) return url;
|
||||
}
|
||||
return null;
|
||||
}, [collection?.backdrop_path, entries]);
|
||||
// Uploaded backdrop wins, then TMDB backdrop, then the first entry's backdrop
|
||||
const backdropUrl = useMemo(
|
||||
() => (collection ? getCollectionDisplayBackdropUrl(collection) : null),
|
||||
[collection],
|
||||
);
|
||||
|
||||
const handleSort = (field: CollectionSortField) => {
|
||||
if (field === sortField) {
|
||||
@@ -254,7 +246,7 @@ export function CollectionDetailsPage() {
|
||||
<div className="absolute bottom-0 left-0 right-0 flex items-end p-6">
|
||||
<div className="flex items-end gap-4">
|
||||
<img
|
||||
src={getCollectionPosterUrl(collection)}
|
||||
src={getCollectionDisplayPosterUrl(collection)}
|
||||
alt={collection.name}
|
||||
className="h-32 w-auto rounded-lg shadow-lg sm:h-40"
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { Clapperboard, Loader2, Plus } from "lucide-react";
|
||||
import { Card } from "@/components/ui/card";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { VideoCard } from "@/components/discovery-videos/VideoCard";
|
||||
import { VideoPlayerDialog } from "@/components/discovery-videos/VideoPlayerDialog";
|
||||
import { AddVideoDialog } from "@/components/discovery-videos/AddVideoDialog";
|
||||
import { ConfirmDialog } from "@/components/dialogs/ConfirmDialog";
|
||||
import { useLibrary } from "@/hooks/useEntries";
|
||||
import { useDiscoveryVideos, useDeleteVideo } from "@/hooks/useDiscoveryVideos";
|
||||
import type { DiscoveryVideo } from "@/types";
|
||||
|
||||
function VideoCardSkeleton() {
|
||||
return (
|
||||
<Card className="flex h-full flex-col overflow-hidden">
|
||||
<div className="h-44 w-full bg-muted" />
|
||||
{/* Mirror the fixed body heights of VideoCard */}
|
||||
<div className="flex flex-col gap-2 p-3">
|
||||
<Skeleton className="h-5 w-3/4" />
|
||||
<Skeleton className="h-8 w-full" />
|
||||
<Skeleton className="h-5 w-1/2" />
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
export function DiscoveryVideosPage() {
|
||||
useLibrary(); // warm the library store for the entry picker
|
||||
|
||||
const [addOpen, setAddOpen] = useState(false);
|
||||
const [editingVideo, setEditingVideo] = useState<DiscoveryVideo | null>(null);
|
||||
const [deletingVideo, setDeletingVideo] = useState<DiscoveryVideo | null>(
|
||||
null,
|
||||
);
|
||||
const [playerIndex, setPlayerIndex] = useState<number | null>(null);
|
||||
|
||||
const query = useDiscoveryVideos();
|
||||
const deleteVideo = useDeleteVideo();
|
||||
|
||||
// Flatten + dedupe pages
|
||||
const videos = (() => {
|
||||
const seen = new Set<number>();
|
||||
return (query.data?.pages.flatMap((p) => p.videos) ?? []).filter((v) => {
|
||||
if (seen.has(v.id)) return false;
|
||||
seen.add(v.id);
|
||||
return true;
|
||||
});
|
||||
})();
|
||||
|
||||
// Infinite scroll via IntersectionObserver
|
||||
const sentinelRef = useRef<HTMLDivElement>(null);
|
||||
const { hasNextPage, isFetchingNextPage, fetchNextPage } = query;
|
||||
const handleIntersect = useCallback(
|
||||
(entries: IntersectionObserverEntry[]) => {
|
||||
if (
|
||||
entries[0]?.isIntersecting &&
|
||||
hasNextPage &&
|
||||
!isFetchingNextPage
|
||||
) {
|
||||
void fetchNextPage();
|
||||
}
|
||||
},
|
||||
[hasNextPage, isFetchingNextPage, fetchNextPage],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const el = sentinelRef.current;
|
||||
if (!el) return;
|
||||
const observer = new IntersectionObserver(handleIntersect, {
|
||||
rootMargin: "400px",
|
||||
});
|
||||
observer.observe(el);
|
||||
return () => observer.disconnect();
|
||||
}, [handleIntersect]);
|
||||
|
||||
const handleConfirmDelete = () => {
|
||||
if (!deletingVideo) return;
|
||||
deleteVideo.mutate(deletingVideo.id, {
|
||||
onSuccess: () => setDeletingVideo(null),
|
||||
});
|
||||
};
|
||||
|
||||
const openEdit = (video: DiscoveryVideo) => {
|
||||
setEditingVideo(video);
|
||||
setAddOpen(true);
|
||||
};
|
||||
|
||||
const openPlayer = (video: DiscoveryVideo) => {
|
||||
const index = videos.findIndex((v) => v.id === video.id);
|
||||
if (index !== -1) setPlayerIndex(index);
|
||||
};
|
||||
|
||||
const playerVideo = playerIndex !== null ? videos[playerIndex] : null;
|
||||
|
||||
const editFromPlayer = (video: DiscoveryVideo) => {
|
||||
setPlayerIndex(null);
|
||||
openEdit(video);
|
||||
};
|
||||
|
||||
const closeAdd = (open: boolean) => {
|
||||
setAddOpen(open);
|
||||
if (!open) setEditingVideo(null);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="animate-page-enter space-y-6">
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold">Discover</h1>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Your saved videos — recommendations, and more.
|
||||
</p>
|
||||
</div>
|
||||
<Button onClick={() => setAddOpen(true)}>
|
||||
<Plus />
|
||||
Add media
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{query.isLoading ? (
|
||||
<div className="grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] items-start gap-4">
|
||||
{Array.from({ length: 6 }).map((_, i) => (
|
||||
<VideoCardSkeleton key={i} />
|
||||
))}
|
||||
</div>
|
||||
) : videos.length === 0 ? (
|
||||
<div className="flex flex-col items-center gap-3 rounded-xl border border-dashed p-12 text-center">
|
||||
<Clapperboard className="h-10 w-10 text-muted-foreground" />
|
||||
<p className="max-w-sm text-sm text-muted-foreground">
|
||||
No videos yet. Drop your first video and start building your watch
|
||||
pile.
|
||||
</p>
|
||||
<Button onClick={() => setAddOpen(true)}>
|
||||
<Plus />
|
||||
Add media
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
/* items-start: cards keep their own fixed size — a row never
|
||||
stretches smaller cards to follow the biggest one */
|
||||
<div className="grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] items-start gap-4">
|
||||
{videos.map((video, index) => (
|
||||
<div
|
||||
key={video.id}
|
||||
className="animate-card-enter"
|
||||
style={{ animationDelay: `${Math.min(index * 20, 300)}ms` }}
|
||||
>
|
||||
<VideoCard
|
||||
video={video}
|
||||
onPlay={openPlayer}
|
||||
onEdit={openEdit}
|
||||
onDelete={setDeletingVideo}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Infinite scroll sentinel */}
|
||||
<div ref={sentinelRef} className="flex justify-center py-4">
|
||||
{query.isFetchingNextPage && (
|
||||
<Loader2 className="h-6 w-6 animate-spin text-muted-foreground" />
|
||||
)}
|
||||
</div>
|
||||
|
||||
<AddVideoDialog open={addOpen} onOpenChange={closeAdd} video={editingVideo} />
|
||||
|
||||
<VideoPlayerDialog
|
||||
open={playerIndex !== null}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) setPlayerIndex(null);
|
||||
}}
|
||||
video={playerVideo}
|
||||
hasPrevious={playerIndex !== null && playerIndex > 0}
|
||||
hasNext={playerIndex !== null && playerIndex < videos.length - 1}
|
||||
onPrevious={() =>
|
||||
setPlayerIndex((i) => (i !== null ? Math.max(0, i - 1) : i))
|
||||
}
|
||||
onNext={() =>
|
||||
setPlayerIndex((i) =>
|
||||
i !== null ? Math.min(videos.length - 1, i + 1) : i,
|
||||
)
|
||||
}
|
||||
onEdit={editFromPlayer}
|
||||
/>
|
||||
|
||||
<ConfirmDialog
|
||||
open={!!deletingVideo}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) setDeletingVideo(null);
|
||||
}}
|
||||
title="Delete video?"
|
||||
description={
|
||||
deletingVideo
|
||||
? `"${deletingVideo.title}" will be permanently removed from disk.`
|
||||
: ""
|
||||
}
|
||||
confirmLabel="Delete"
|
||||
variant="destructive"
|
||||
isLoading={deleteVideo.isPending}
|
||||
onConfirm={handleConfirmDelete}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,49 +1,57 @@
|
||||
import { useState, useMemo, useCallback, useEffect, useRef } from 'react';
|
||||
import { useSearchParams, useNavigationType } from 'react-router-dom';
|
||||
import { useLibrary } from '@/hooks/useEntries';
|
||||
import { useLibraryEntries } from '@/stores/useLibraryStore';
|
||||
import { useState, useMemo, useCallback, useEffect, useRef } from "react";
|
||||
import { useSearchParams, useNavigationType } from "react-router-dom";
|
||||
import { useLibrary } from "@/hooks/useEntries";
|
||||
import { useLibraryEntries } from "@/stores/useLibraryStore";
|
||||
import {
|
||||
useLibraryFiltersStore,
|
||||
defaultFilters,
|
||||
} from '@/stores/useLibraryFiltersStore';
|
||||
} from "@/stores/useLibraryFiltersStore";
|
||||
import type {
|
||||
FilterTab,
|
||||
SortField,
|
||||
SortDir,
|
||||
Filters,
|
||||
} from '@/stores/useLibraryFiltersStore';
|
||||
import { EntryLibraryGrid } from '@/components/entries/EntryLibraryGrid';
|
||||
import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
} from "@/stores/useLibraryFiltersStore";
|
||||
import { EntryLibraryGrid } from "@/components/entries/EntryLibraryGrid";
|
||||
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import {
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from '@/components/ui/popover';
|
||||
} from "@/components/ui/popover";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import { Search, X, SlidersHorizontal, ArrowUpDown, Info } from 'lucide-react';
|
||||
import type { Entry } from '@/types';
|
||||
} from "@/components/ui/select";
|
||||
import {
|
||||
Search,
|
||||
X,
|
||||
SlidersHorizontal,
|
||||
ArrowUpDown,
|
||||
Info,
|
||||
Heart,
|
||||
EyeOff,
|
||||
} from "lucide-react";
|
||||
import type { Entry } from "@/types";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipProvider,
|
||||
TooltipTrigger,
|
||||
} from '@/components/ui/tooltip';
|
||||
} from "@/components/ui/tooltip";
|
||||
|
||||
const sortLabels: Record<SortField, string> = {
|
||||
date_last_seen: 'Last Watched',
|
||||
createdAt: 'Date Added',
|
||||
title: 'Title',
|
||||
release_date: 'Release Date',
|
||||
rating: 'Rating',
|
||||
date_last_seen: "Last Watched",
|
||||
createdAt: "Date Added",
|
||||
title: "Title",
|
||||
release_date: "Release Date",
|
||||
rating: "Rating",
|
||||
};
|
||||
|
||||
function sortEntries(
|
||||
@@ -54,34 +62,69 @@ function sortEntries(
|
||||
return [...entries].sort((a, b) => {
|
||||
let cmp = 0;
|
||||
switch (field) {
|
||||
case 'title':
|
||||
case "title":
|
||||
cmp = a.title.localeCompare(b.title);
|
||||
break;
|
||||
case 'release_date':
|
||||
case "release_date":
|
||||
cmp =
|
||||
new Date(a.release_date || '1900').getTime() -
|
||||
new Date(b.release_date || '1900').getTime();
|
||||
new Date(a.release_date || "1900").getTime() -
|
||||
new Date(b.release_date || "1900").getTime();
|
||||
break;
|
||||
case 'rating':
|
||||
case "rating":
|
||||
cmp =
|
||||
(a.entryRatings?.user_rating ?? 0) -
|
||||
(b.entryRatings?.user_rating ?? 0);
|
||||
break;
|
||||
case 'date_last_seen':
|
||||
case "date_last_seen":
|
||||
cmp =
|
||||
new Date(a.date_last_seen || '1900').getTime() -
|
||||
new Date(b.date_last_seen || '1900').getTime();
|
||||
new Date(a.date_last_seen || "1900").getTime() -
|
||||
new Date(b.date_last_seen || "1900").getTime();
|
||||
break;
|
||||
case 'createdAt':
|
||||
case "createdAt":
|
||||
cmp = new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime();
|
||||
break;
|
||||
}
|
||||
return dir === 'desc' ? -cmp : cmp;
|
||||
return dir === "desc" ? -cmp : cmp;
|
||||
});
|
||||
}
|
||||
|
||||
const PAGE_SIZE = 28;
|
||||
|
||||
interface FilterTogglesProps {
|
||||
favoritesOnly: boolean;
|
||||
onFavoritesChange: (value: boolean) => void;
|
||||
hiddenOnly: boolean;
|
||||
onHiddenChange: (value: boolean) => void;
|
||||
}
|
||||
|
||||
function FilterToggles({
|
||||
favoritesOnly,
|
||||
onFavoritesChange,
|
||||
hiddenOnly,
|
||||
onHiddenChange,
|
||||
}: FilterTogglesProps) {
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant={favoritesOnly ? "default" : "outline"}
|
||||
aria-pressed={favoritesOnly}
|
||||
onClick={() => onFavoritesChange(!favoritesOnly)}
|
||||
>
|
||||
<Heart className={favoritesOnly ? "fill-current" : ""} />
|
||||
Favorites
|
||||
</Button>
|
||||
<Button
|
||||
variant={hiddenOnly ? "default" : "outline"}
|
||||
aria-pressed={hiddenOnly}
|
||||
onClick={() => onHiddenChange(!hiddenOnly)}
|
||||
>
|
||||
<EyeOff />
|
||||
Hidden
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function LibraryPage() {
|
||||
const { isLoading } = useLibrary();
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
@@ -92,6 +135,10 @@ export function LibraryPage() {
|
||||
const setActiveTab = useLibraryFiltersStore((s) => s.setActiveTab);
|
||||
const search = useLibraryFiltersStore((s) => s.search);
|
||||
const setSearch = useLibraryFiltersStore((s) => s.setSearch);
|
||||
const favoritesOnly = useLibraryFiltersStore((s) => s.favoritesOnly);
|
||||
const setFavoritesOnly = useLibraryFiltersStore((s) => s.setFavoritesOnly);
|
||||
const hiddenOnly = useLibraryFiltersStore((s) => s.hiddenOnly);
|
||||
const setHiddenOnly = useLibraryFiltersStore((s) => s.setHiddenOnly);
|
||||
const sortField = useLibraryFiltersStore((s) => s.sortField);
|
||||
const setSortField = useLibraryFiltersStore((s) => s.setSortField);
|
||||
const sortDir = useLibraryFiltersStore((s) => s.sortDir);
|
||||
@@ -105,13 +152,13 @@ export function LibraryPage() {
|
||||
const [debouncedFilters, setDebouncedFilters] = useState<Filters>(filters);
|
||||
const [visibleCount, setVisibleCount] = useState(PAGE_SIZE);
|
||||
const filtersInitialized = useRef(false);
|
||||
const [statusFilter, setStatusFilter] = useState<string>('');
|
||||
const [statusFilter, setStatusFilter] = useState<string>("");
|
||||
|
||||
const allEntries = useLibraryEntries();
|
||||
|
||||
// Reset filters when navigating TO the library (not when pressing back)
|
||||
useEffect(() => {
|
||||
if (navigationType !== 'POP') {
|
||||
if (navigationType !== "POP") {
|
||||
resetAll();
|
||||
}
|
||||
// Only run on mount
|
||||
@@ -122,9 +169,9 @@ export function LibraryPage() {
|
||||
useEffect(() => {
|
||||
if (filtersInitialized.current) return;
|
||||
filtersInitialized.current = true;
|
||||
const genre = searchParams.get('genre') || '';
|
||||
const ratingMin = searchParams.get('ratingMin') || '';
|
||||
const ratingMax = searchParams.get('ratingMax') || '';
|
||||
const genre = searchParams.get("genre") || "";
|
||||
const ratingMin = searchParams.get("ratingMin") || "";
|
||||
const ratingMax = searchParams.get("ratingMax") || "";
|
||||
if (genre || ratingMin || ratingMax) {
|
||||
const newFilters = {
|
||||
...defaultFilters,
|
||||
@@ -154,7 +201,15 @@ export function LibraryPage() {
|
||||
// Reset visible count when filters/search/tab/sort change
|
||||
useEffect(() => {
|
||||
setVisibleCount(PAGE_SIZE);
|
||||
}, [activeTab, debouncedSearch, debouncedFilters, sortField, sortDir]);
|
||||
}, [
|
||||
activeTab,
|
||||
favoritesOnly,
|
||||
hiddenOnly,
|
||||
debouncedSearch,
|
||||
debouncedFilters,
|
||||
sortField,
|
||||
sortDir,
|
||||
]);
|
||||
|
||||
// Gather unique genres from the library
|
||||
const allGenres = useMemo(() => {
|
||||
@@ -173,31 +228,25 @@ export function LibraryPage() {
|
||||
filters.yearMax ||
|
||||
!!statusFilter;
|
||||
|
||||
// Type tab combines with the favorites/hidden toggles. Hidden mode shows
|
||||
// only hidden entries (watchlist included); otherwise hidden and watchlist
|
||||
// entries are excluded.
|
||||
const baseEntries = useMemo(() => {
|
||||
switch (activeTab) {
|
||||
case 'movies':
|
||||
return allEntries.filter(
|
||||
(e) => !e.is_tvseries && !e.watchlist && !e.hidden,
|
||||
);
|
||||
case 'tv':
|
||||
return allEntries.filter(
|
||||
(e) => e.is_tvseries && !e.watchlist && !e.hidden,
|
||||
);
|
||||
case 'favorites':
|
||||
return allEntries.filter((e) => e.favorit && !e.watchlist && !e.hidden);
|
||||
case 'hidden':
|
||||
return allEntries.filter((e) => e.hidden);
|
||||
default:
|
||||
return allEntries.filter((e) => !e.watchlist && !e.hidden);
|
||||
}
|
||||
}, [activeTab, allEntries]);
|
||||
return allEntries.filter((e) => {
|
||||
if (activeTab === "movies" && e.is_tvseries) return false;
|
||||
if (activeTab === "tv" && !e.is_tvseries) return false;
|
||||
if (favoritesOnly && !e.favorit) return false;
|
||||
if (hiddenOnly) return !!e.hidden;
|
||||
return !e.watchlist && !e.hidden;
|
||||
});
|
||||
}, [activeTab, favoritesOnly, hiddenOnly, allEntries]);
|
||||
|
||||
const filteredEntries = useMemo(() => {
|
||||
let result = baseEntries;
|
||||
|
||||
if (debouncedSearch) {
|
||||
const q = debouncedSearch.toLowerCase();
|
||||
const directorPrefix = '@director:';
|
||||
const directorPrefix = "@director:";
|
||||
if (q.startsWith(directorPrefix)) {
|
||||
const dirQuery = q.slice(directorPrefix.length).trim();
|
||||
if (dirQuery) {
|
||||
@@ -281,7 +330,7 @@ export function LibraryPage() {
|
||||
/>
|
||||
{search && (
|
||||
<button
|
||||
onClick={() => setSearch('')}
|
||||
onClick={() => setSearch("")}
|
||||
className="absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
@@ -303,19 +352,19 @@ export function LibraryPage() {
|
||||
<p className="mb-0.5">
|
||||
<code className="bg-accent px-1 rounded text-[11px]">
|
||||
@director:name
|
||||
</code>{' '}
|
||||
</code>{" "}
|
||||
— by director
|
||||
</p>
|
||||
<p className="text-muted-foreground mb-0.5">
|
||||
<code className="bg-accent px-1 rounded text-[11px]">
|
||||
@country:name
|
||||
</code>{' '}
|
||||
</code>{" "}
|
||||
— coming soon
|
||||
</p>
|
||||
<p className="text-muted-foreground">
|
||||
<code className="bg-accent px-1 rounded text-[11px]">
|
||||
@year:year
|
||||
</code>{' '}
|
||||
</code>{" "}
|
||||
— coming soon
|
||||
</p>
|
||||
</PopoverContent>
|
||||
@@ -330,7 +379,7 @@ export function LibraryPage() {
|
||||
className="h-9 w-9 shrink-0 relative"
|
||||
>
|
||||
<ArrowUpDown className="h-4 w-4" />
|
||||
{sortField !== 'date_last_seen' && (
|
||||
{sortField !== "date_last_seen" && (
|
||||
<span className="absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary" />
|
||||
)}
|
||||
</Button>
|
||||
@@ -346,8 +395,8 @@ export function LibraryPage() {
|
||||
onClick={() => setSortField(value as SortField)}
|
||||
className={`w-full rounded-md px-3 py-1.5 text-left text-sm transition-colors ${
|
||||
sortField === value
|
||||
? 'bg-accent text-accent-foreground font-medium'
|
||||
: 'hover:bg-accent/50'
|
||||
? "bg-accent text-accent-foreground font-medium"
|
||||
: "hover:bg-accent/50"
|
||||
}`}
|
||||
>
|
||||
{label}
|
||||
@@ -356,18 +405,18 @@ export function LibraryPage() {
|
||||
</div>
|
||||
<div className="flex gap-1 pt-1 border-t border-border">
|
||||
<Button
|
||||
variant={sortDir === 'desc' ? 'default' : 'outline'}
|
||||
variant={sortDir === "desc" ? "default" : "outline"}
|
||||
size="sm"
|
||||
className="flex-1 h-8 text-xs"
|
||||
onClick={() => setSortDir('desc')}
|
||||
onClick={() => setSortDir("desc")}
|
||||
>
|
||||
↓ Desc
|
||||
</Button>
|
||||
<Button
|
||||
variant={sortDir === 'asc' ? 'default' : 'outline'}
|
||||
variant={sortDir === "asc" ? "default" : "outline"}
|
||||
size="sm"
|
||||
className="flex-1 h-8 text-xs"
|
||||
onClick={() => setSortDir('asc')}
|
||||
onClick={() => setSortDir("asc")}
|
||||
>
|
||||
↑ Asc
|
||||
</Button>
|
||||
@@ -397,7 +446,7 @@ export function LibraryPage() {
|
||||
onValueChange={(v) =>
|
||||
setFilters((f) => ({
|
||||
...f,
|
||||
genre: v === '_all' ? '' : v || '',
|
||||
genre: v === "_all" ? "" : v || "",
|
||||
}))
|
||||
}
|
||||
>
|
||||
@@ -418,7 +467,7 @@ export function LibraryPage() {
|
||||
<label className="text-sm font-medium">Status</label>
|
||||
<Select
|
||||
value={statusFilter}
|
||||
onValueChange={(v) => setStatusFilter(v === '_all' ? '' : v)}
|
||||
onValueChange={(v) => setStatusFilter(v === "_all" ? "" : v)}
|
||||
>
|
||||
<SelectTrigger className="h-9">
|
||||
<SelectValue placeholder="Any status" />
|
||||
@@ -553,13 +602,19 @@ export function LibraryPage() {
|
||||
value={activeTab}
|
||||
onValueChange={(v) => setActiveTab(v as FilterTab)}
|
||||
>
|
||||
<TabsList className="w-max">
|
||||
<TabsTrigger value="all">All</TabsTrigger>
|
||||
<TabsTrigger value="movies">Movies</TabsTrigger>
|
||||
<TabsTrigger value="tv">TV</TabsTrigger>
|
||||
<TabsTrigger value="favorites">Favorites</TabsTrigger>
|
||||
<TabsTrigger value="hidden">Hidden</TabsTrigger>
|
||||
</TabsList>
|
||||
<div className="flex w-max items-center gap-2">
|
||||
<TabsList>
|
||||
<TabsTrigger value="all">All</TabsTrigger>
|
||||
<TabsTrigger value="movies">Movies</TabsTrigger>
|
||||
<TabsTrigger value="tv">TV</TabsTrigger>
|
||||
</TabsList>
|
||||
<FilterToggles
|
||||
favoritesOnly={favoritesOnly}
|
||||
onFavoritesChange={setFavoritesOnly}
|
||||
hiddenOnly={hiddenOnly}
|
||||
onHiddenChange={setHiddenOnly}
|
||||
/>
|
||||
</div>
|
||||
</Tabs>
|
||||
</div>
|
||||
</div>
|
||||
@@ -587,26 +642,26 @@ export function LibraryPage() {
|
||||
<p className="mb-0.5">
|
||||
<code className="bg-accent px-1 rounded text-[11px]">
|
||||
@director:name
|
||||
</code>{' '}
|
||||
</code>{" "}
|
||||
— by director
|
||||
</p>
|
||||
<p className="text-muted-foreground mb-0.5">
|
||||
<code className="bg-accent px-1 rounded text-[11px]">
|
||||
@country:name
|
||||
</code>{' '}
|
||||
</code>{" "}
|
||||
— coming soon
|
||||
</p>
|
||||
<p className="text-muted-foreground">
|
||||
<code className="bg-accent px-1 rounded text-[11px]">
|
||||
@year:year
|
||||
</code>{' '}
|
||||
</code>{" "}
|
||||
— coming soon
|
||||
</p>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
|
||||
{search && (
|
||||
<Button variant="ghost" size="sm" onClick={() => setSearch('')}>
|
||||
<Button variant="ghost" size="sm" onClick={() => setSearch("")}>
|
||||
<X className="mr-1 h-4 w-4" /> Clear
|
||||
</Button>
|
||||
)}
|
||||
@@ -620,7 +675,7 @@ export function LibraryPage() {
|
||||
<ArrowUpDown className="h-4 w-4" />
|
||||
{sortLabels[sortField]}
|
||||
<span className="text-xs opacity-60">
|
||||
{sortDir === 'desc' ? '↓' : '↑'}
|
||||
{sortDir === "desc" ? "↓" : "↑"}
|
||||
</span>
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
@@ -635,8 +690,8 @@ export function LibraryPage() {
|
||||
onClick={() => setSortField(value as SortField)}
|
||||
className={`w-full rounded-md px-3 py-1.5 text-left text-sm transition-colors ${
|
||||
sortField === value
|
||||
? 'bg-accent text-accent-foreground font-medium'
|
||||
: 'hover:bg-accent/50'
|
||||
? "bg-accent text-accent-foreground font-medium"
|
||||
: "hover:bg-accent/50"
|
||||
}`}
|
||||
>
|
||||
{label}
|
||||
@@ -645,18 +700,18 @@ export function LibraryPage() {
|
||||
</div>
|
||||
<div className="flex gap-1 pt-1 border-t border-border">
|
||||
<Button
|
||||
variant={sortDir === 'desc' ? 'default' : 'outline'}
|
||||
variant={sortDir === "desc" ? "default" : "outline"}
|
||||
size="sm"
|
||||
className="flex-1 h-8 text-xs"
|
||||
onClick={() => setSortDir('desc')}
|
||||
onClick={() => setSortDir("desc")}
|
||||
>
|
||||
↓ Desc
|
||||
</Button>
|
||||
<Button
|
||||
variant={sortDir === 'asc' ? 'default' : 'outline'}
|
||||
variant={sortDir === "asc" ? "default" : "outline"}
|
||||
size="sm"
|
||||
className="flex-1 h-8 text-xs"
|
||||
onClick={() => setSortDir('asc')}
|
||||
onClick={() => setSortDir("asc")}
|
||||
>
|
||||
↑ Asc
|
||||
</Button>
|
||||
@@ -688,7 +743,7 @@ export function LibraryPage() {
|
||||
onValueChange={(v) =>
|
||||
setFilters((f) => ({
|
||||
...f,
|
||||
genre: v === '_all' ? '' : v || '',
|
||||
genre: v === "_all" ? "" : v || "",
|
||||
}))
|
||||
}
|
||||
>
|
||||
@@ -709,7 +764,7 @@ export function LibraryPage() {
|
||||
<label className="text-sm font-medium">Status</label>
|
||||
<Select
|
||||
value={statusFilter}
|
||||
onValueChange={(v) => setStatusFilter(v === '_all' ? '' : v)}
|
||||
onValueChange={(v) => setStatusFilter(v === "_all" ? "" : v)}
|
||||
>
|
||||
<SelectTrigger className="h-9 w-full">
|
||||
<SelectValue placeholder="Any status" />
|
||||
@@ -834,10 +889,15 @@ export function LibraryPage() {
|
||||
<TabsTrigger value="all">All</TabsTrigger>
|
||||
<TabsTrigger value="movies">Movies</TabsTrigger>
|
||||
<TabsTrigger value="tv">TV Series</TabsTrigger>
|
||||
<TabsTrigger value="favorites">Favorites</TabsTrigger>
|
||||
<TabsTrigger value="hidden">Hidden</TabsTrigger>
|
||||
</TabsList>
|
||||
</Tabs>
|
||||
|
||||
<FilterToggles
|
||||
favoritesOnly={favoritesOnly}
|
||||
onFavoritesChange={setFavoritesOnly}
|
||||
hiddenOnly={hiddenOnly}
|
||||
onHiddenChange={setHiddenOnly}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<EntryLibraryGrid
|
||||
|
||||
@@ -8,8 +8,13 @@ import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import { Search, Heart } from "lucide-react";
|
||||
import { getProfileUrl } from "@/lib/media-utils";
|
||||
import { getProfileUrl, formatDate, calculateAge } from "@/lib/media-utils";
|
||||
|
||||
type PeopleFilter = "all" | "favorite";
|
||||
|
||||
@@ -207,6 +212,18 @@ export function PeoplePage() {
|
||||
<p className="text-sm font-medium line-clamp-2">
|
||||
{person.name}
|
||||
</p>
|
||||
{person.birthday && (
|
||||
<Tooltip>
|
||||
<TooltipTrigger render={<span />}>
|
||||
<span className="text-xs text-muted-foreground">
|
||||
Born: {formatDate(person.birthday)}
|
||||
</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
Age: {calculateAge(person.birthday, person.deathday)}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
)}
|
||||
</Link>
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useParams, useNavigate, useLocation } from "react-router-dom";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useState, useEffect } from "react";
|
||||
import {
|
||||
usePerson,
|
||||
@@ -13,8 +13,14 @@ import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import { EntryCard } from "@/components/entries/EntryCard";
|
||||
import { getProfileUrl, formatDate } from "@/lib/media-utils";
|
||||
import { getTmdbImageUrl } from "@/lib/api";
|
||||
import { formatDate, calculateAge } from "@/lib/media-utils";
|
||||
import {
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
@@ -24,58 +30,131 @@ import {
|
||||
ExternalLink,
|
||||
} from "lucide-react";
|
||||
import type { TmdbEntry } from "@/types";
|
||||
import type { TmdbFilmographyItem } from "@/api/people";
|
||||
import type {
|
||||
TmdbFilmographyItem,
|
||||
TmdbFilmographyResponse,
|
||||
} from "@/api/people";
|
||||
|
||||
const TMDB_IMG = "https://image.tmdb.org/t/p";
|
||||
|
||||
export function PersonDetailsPage() {
|
||||
const { id, tmdbId } = useParams<{ id?: string; tmdbId?: string }>();
|
||||
const location = useLocation();
|
||||
const isTmdbMode = location.pathname.startsWith("/people/tmdb/");
|
||||
|
||||
if (isTmdbMode && tmdbId) {
|
||||
return <TmdbPersonView tmdbId={parseInt(tmdbId, 10)} />;
|
||||
}
|
||||
|
||||
return <LocalPersonView personId={parseInt(id!, 10)} />;
|
||||
/** Person data normalized from either the local DB or a TMDB preview. */
|
||||
interface PersonProfile {
|
||||
name: string;
|
||||
biography: string | null;
|
||||
birthday: string | null;
|
||||
deathday: string | null;
|
||||
place_of_birth: string | null;
|
||||
profile_path: string | null;
|
||||
known_for_department: string | null;
|
||||
tmdb_id: number | null;
|
||||
favorite: boolean;
|
||||
}
|
||||
|
||||
/* ─── Local DB person ─── */
|
||||
|
||||
function LocalPersonView({ personId }: { personId: number }) {
|
||||
/**
|
||||
* Person page for both sources:
|
||||
* - `/people/:id`: the person is in the local DB, so details come from there
|
||||
* and the filmography from TMDB via the local id.
|
||||
* - `/people/tmdb/:tmdbId`: the person is not in the local DB, so everything
|
||||
* comes from the TMDB preview. If the preview reports a local id, redirect.
|
||||
*/
|
||||
export function PersonDetailsPage() {
|
||||
const { id, tmdbId } = useParams<{ id?: string; tmdbId?: string }>();
|
||||
const navigate = useNavigate();
|
||||
const { data: person, isLoading, isError } = usePerson(personId);
|
||||
const { data: tmdbFilmography, isLoading: tmdbLoading } =
|
||||
usePersonTmdbFilmography(personId);
|
||||
const localId = id ? parseInt(id, 10) : 0;
|
||||
const isLocal = !!localId;
|
||||
const tmdbIdNum = !isLocal && tmdbId ? parseInt(tmdbId, 10) : 0;
|
||||
|
||||
// Queries are disabled when their id is 0, so only one source is fetched.
|
||||
const localPerson = usePerson(localId);
|
||||
const localFilmography = usePersonTmdbFilmography(localId);
|
||||
const tmdbPreview = useTmdbPersonPreview(tmdbIdNum);
|
||||
|
||||
const updatePerson = useUpdatePerson();
|
||||
const fetchPerson = useFetchPersonByTmdbId();
|
||||
useLibrary();
|
||||
const libraryMap = useLibraryStore((s) => s.entries);
|
||||
const libraryLoaded = useLibraryStore((s) => s.isLoaded);
|
||||
|
||||
const existingLocalId = tmdbPreview.data?.local_id;
|
||||
useEffect(() => {
|
||||
if (existingLocalId) {
|
||||
navigate(`/people/${existingLocalId}`, { replace: true });
|
||||
}
|
||||
}, [existingLocalId, navigate]);
|
||||
|
||||
const isError = isLocal ? localPerson.isError : tmdbPreview.isError;
|
||||
|
||||
if (isError) {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center gap-3 py-20">
|
||||
<p className="text-lg font-semibold">Person not found</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
This person could not be loaded. They may not exist in the database.
|
||||
{isLocal
|
||||
? "This person could not be loaded. They may not exist in the database."
|
||||
: "Could not load person data from TMDB."}
|
||||
</p>
|
||||
<Button variant="outline" onClick={() => navigate("/people")}>
|
||||
Back to People
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => (isLocal ? navigate("/people") : navigate(-1))}
|
||||
>
|
||||
{isLocal ? "Back to People" : "Go back"}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (isLoading || !person) {
|
||||
let person: PersonProfile | null = null;
|
||||
let filmography: TmdbFilmographyResponse | undefined;
|
||||
let filmographyLoading = false;
|
||||
|
||||
if (isLocal && localPerson.data) {
|
||||
const p = localPerson.data;
|
||||
person = {
|
||||
name: p.name,
|
||||
biography: p.biography ?? null,
|
||||
birthday: p.birthday ?? null,
|
||||
deathday: p.deathday ?? null,
|
||||
place_of_birth: p.place_of_birth ?? null,
|
||||
profile_path: p.profile_path ?? null,
|
||||
known_for_department: p.known_for_department ?? null,
|
||||
tmdb_id: p.tmdb_id ?? null,
|
||||
favorite: !!p.favorite,
|
||||
};
|
||||
filmography = localFilmography.data;
|
||||
filmographyLoading = localFilmography.isLoading;
|
||||
} else if (!isLocal && tmdbPreview.data && !existingLocalId) {
|
||||
const p = tmdbPreview.data;
|
||||
person = { ...p, favorite: false };
|
||||
filmography = p.filmography;
|
||||
}
|
||||
|
||||
// Still loading, or about to redirect to the local page.
|
||||
if (!person) {
|
||||
return <PersonSkeleton />;
|
||||
}
|
||||
|
||||
const isFavorite = person.favorite;
|
||||
|
||||
const toggleFavorite = () => {
|
||||
updatePerson.mutate({ id: localId, data: { favorite: !isFavorite } });
|
||||
};
|
||||
|
||||
const addToLibrary = () => {
|
||||
fetchPerson.mutate(tmdbIdNum, {
|
||||
onSuccess: (added) => {
|
||||
navigate(`/people/${added.id}`, { replace: true });
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-8 animate-page-enter">
|
||||
<div className="flex flex-col items-center gap-4 sm:flex-row sm:items-start sm:gap-8">
|
||||
<Avatar className="h-32 w-32 shrink-0 sm:h-48 sm:w-48">
|
||||
<AvatarImage
|
||||
src={getProfileUrl(person.profile_path)}
|
||||
src={
|
||||
person.profile_path
|
||||
? getTmdbImageUrl(person.profile_path, "w300")
|
||||
: undefined
|
||||
}
|
||||
alt={person.name}
|
||||
/>
|
||||
<AvatarFallback className="text-2xl sm:text-3xl">
|
||||
@@ -88,22 +167,33 @@ function LocalPersonView({ personId }: { personId: number }) {
|
||||
<div className="space-y-2 text-center sm:text-left sm:space-y-3">
|
||||
<div className="flex items-center gap-2 justify-center sm:justify-start">
|
||||
<h1 className="text-2xl font-bold sm:text-3xl">{person.name}</h1>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8 shrink-0"
|
||||
onClick={() =>
|
||||
updatePerson.mutate({
|
||||
id: person.id,
|
||||
data: { favorite: !person.favorite },
|
||||
})
|
||||
}
|
||||
disabled={updatePerson.isPending}
|
||||
>
|
||||
<Heart
|
||||
className={`h-5 w-5 ${person.favorite ? "fill-red-500 text-red-500" : "text-muted-foreground"}`}
|
||||
/>
|
||||
</Button>
|
||||
{isLocal ? (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8 shrink-0"
|
||||
onClick={toggleFavorite}
|
||||
disabled={updatePerson.isPending}
|
||||
>
|
||||
<Heart
|
||||
className={`h-5 w-5 ${isFavorite ? "fill-red-500 text-red-500" : "text-muted-foreground"}`}
|
||||
/>
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
onClick={addToLibrary}
|
||||
disabled={fetchPerson.isPending}
|
||||
size="sm"
|
||||
className="ml-1"
|
||||
>
|
||||
{fetchPerson.isPending ? (
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||
) : (
|
||||
<Plus className="mr-2 h-4 w-4" />
|
||||
)}
|
||||
{fetchPerson.isPending ? "Adding..." : "Add to Library"}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<PersonMeta
|
||||
known_for_department={person.known_for_department}
|
||||
@@ -123,117 +213,12 @@ function LocalPersonView({ personId }: { personId: number }) {
|
||||
<Separator />
|
||||
|
||||
<FilmographySection
|
||||
// Reset pagination when moving between people on the same route
|
||||
key={isLocal ? `local-${localId}` : `tmdb-${tmdbIdNum}`}
|
||||
libraryMap={libraryMap}
|
||||
libraryLoaded={libraryLoaded}
|
||||
tmdbFilmography={tmdbFilmography}
|
||||
tmdbLoading={tmdbLoading}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/* ─── TMDB person (not in library) ─── */
|
||||
|
||||
function TmdbPersonView({ tmdbId }: { tmdbId: number }) {
|
||||
const navigate = useNavigate();
|
||||
const { data: preview, isLoading, isError } = useTmdbPersonPreview(tmdbId);
|
||||
const fetchPerson = useFetchPersonByTmdbId();
|
||||
useLibrary();
|
||||
const libraryMap = useLibraryStore((s) => s.entries);
|
||||
const libraryLoaded = useLibraryStore((s) => s.isLoaded);
|
||||
|
||||
// If person already exists in local DB, redirect to their local page
|
||||
useEffect(() => {
|
||||
if (preview?.local_id) {
|
||||
navigate(`/people/${preview.local_id}`, { replace: true });
|
||||
}
|
||||
}, [preview?.local_id, navigate]);
|
||||
|
||||
if (isError) {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center gap-3 py-20">
|
||||
<p className="text-lg font-semibold">Person not found</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Could not load person data from TMDB.
|
||||
</p>
|
||||
<Button variant="outline" onClick={() => navigate(-1)}>
|
||||
Go back
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (isLoading || !preview) {
|
||||
return <PersonSkeleton />;
|
||||
}
|
||||
|
||||
// Redirecting to local page, show skeleton while navigating
|
||||
if (preview.local_id) {
|
||||
return <PersonSkeleton />;
|
||||
}
|
||||
|
||||
const profileUrl = preview.profile_path
|
||||
? `${TMDB_IMG}/w300${preview.profile_path}`
|
||||
: undefined;
|
||||
|
||||
const handleAddToLibrary = () => {
|
||||
fetchPerson.mutate(tmdbId, {
|
||||
onSuccess: (person) => {
|
||||
navigate(`/people/${person.id}`, { replace: true });
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-8 animate-page-enter">
|
||||
<div className="flex flex-col items-center gap-4 sm:flex-row sm:items-start sm:gap-8">
|
||||
<Avatar className="h-32 w-32 shrink-0 sm:h-48 sm:w-48">
|
||||
<AvatarImage src={profileUrl} alt={preview.name} />
|
||||
<AvatarFallback className="text-2xl sm:text-3xl">
|
||||
{preview.name
|
||||
.split(" ")
|
||||
.map((n: string) => n[0])
|
||||
.join("")}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<div className="space-y-2 text-center sm:text-left sm:space-y-3">
|
||||
<div className="flex items-center gap-3 justify-center sm:justify-start">
|
||||
<h1 className="text-2xl font-bold sm:text-3xl">{preview.name}</h1>
|
||||
<Button
|
||||
onClick={handleAddToLibrary}
|
||||
disabled={fetchPerson.isPending}
|
||||
size="sm"
|
||||
>
|
||||
{fetchPerson.isPending ? (
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||
) : (
|
||||
<Plus className="mr-2 h-4 w-4" />
|
||||
)}
|
||||
{fetchPerson.isPending ? "Adding..." : "Add to Library"}
|
||||
</Button>
|
||||
</div>
|
||||
<PersonMeta
|
||||
known_for_department={preview.known_for_department}
|
||||
birthday={preview.birthday}
|
||||
deathday={preview.deathday}
|
||||
place_of_birth={preview.place_of_birth}
|
||||
tmdb_id={preview.tmdb_id}
|
||||
/>
|
||||
{preview.biography && (
|
||||
<p className="text-sm text-muted-foreground leading-relaxed max-w-2xl line-clamp-6">
|
||||
{preview.biography}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Separator />
|
||||
|
||||
<FilmographySection
|
||||
libraryMap={libraryMap}
|
||||
libraryLoaded={libraryLoaded}
|
||||
tmdbFilmography={preview.filmography}
|
||||
tmdbLoading={false}
|
||||
tmdbFilmography={filmography}
|
||||
tmdbLoading={filmographyLoading}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
@@ -260,7 +245,14 @@ function PersonMeta({
|
||||
{birthday && (
|
||||
<>
|
||||
<span>•</span>
|
||||
<span>Born: {formatDate(birthday)}</span>
|
||||
<Tooltip>
|
||||
<TooltipTrigger render={<span className="cursor-default" />}>
|
||||
Born: {formatDate(birthday)}
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
Age: {calculateAge(birthday, deathday)}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</>
|
||||
)}
|
||||
{deathday && (
|
||||
|
||||
@@ -1,364 +0,0 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import {
|
||||
useTmdbPersonPreview,
|
||||
useFetchPersonByTmdbId,
|
||||
} from "@/hooks/usePeople";
|
||||
import { useLibrary } from "@/hooks/useEntries";
|
||||
import { useLibraryStore } from "@/stores/useLibraryStore";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { EntryCard } from "@/components/entries/EntryCard";
|
||||
import { getProfileUrl, formatDate } from "@/lib/media-utils";
|
||||
import { Plus, Loader2, ChevronLeft, ChevronRight } from "lucide-react";
|
||||
import type { TmdbEntry } from "@/types";
|
||||
import type { TmdbFilmographyItem } from "@/api/people";
|
||||
|
||||
const TMDB_IMG = "https://image.tmdb.org/t/p";
|
||||
|
||||
export function PersonTmdbRedirectPage() {
|
||||
const { tmdbId } = useParams<{ tmdbId: string }>();
|
||||
const navigate = useNavigate();
|
||||
const tmdbIdNum = parseInt(tmdbId!, 10);
|
||||
|
||||
const { data: preview, isLoading, isError } = useTmdbPersonPreview(tmdbIdNum);
|
||||
const fetchPerson = useFetchPersonByTmdbId();
|
||||
useLibrary();
|
||||
const libraryMap = useLibraryStore((s) => s.entries);
|
||||
const libraryLoaded = useLibraryStore((s) => s.isLoaded);
|
||||
|
||||
if (isLoading || !preview) {
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex flex-col items-center gap-4 sm:flex-row sm:items-start sm:gap-6">
|
||||
<Skeleton className="h-32 w-32 rounded-full sm:h-48 sm:w-48" />
|
||||
<div className="flex-1 space-y-3 w-full">
|
||||
<Skeleton className="h-8 w-48 mx-auto sm:mx-0" />
|
||||
<Skeleton className="h-4 w-32 mx-auto sm:mx-0" />
|
||||
<Skeleton className="h-20 w-full" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (isError) {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center gap-3 py-20">
|
||||
<p className="text-lg font-semibold">Person not found</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Could not load person data from TMDB.
|
||||
</p>
|
||||
<Button variant="outline" onClick={() => navigate(-1)}>
|
||||
Go back
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const profileUrl = preview.profile_path
|
||||
? `${TMDB_IMG}/w300${preview.profile_path}`
|
||||
: undefined;
|
||||
|
||||
const handleAddToLibrary = () => {
|
||||
fetchPerson.mutate(tmdbIdNum, {
|
||||
onSuccess: (person) => {
|
||||
navigate(`/people/${person.id}`, { replace: true });
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-8 animate-page-enter">
|
||||
<div className="flex flex-col items-center gap-4 sm:flex-row sm:items-start sm:gap-8">
|
||||
<Avatar className="h-32 w-32 shrink-0 sm:h-48 sm:w-48">
|
||||
<AvatarImage src={profileUrl} alt={preview.name} />
|
||||
<AvatarFallback className="text-2xl sm:text-3xl">
|
||||
{preview.name
|
||||
.split(" ")
|
||||
.map((n: string) => n[0])
|
||||
.join("")}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<div className="space-y-2 text-center sm:text-left sm:space-y-3">
|
||||
<div className="flex items-center gap-3 justify-center sm:justify-start">
|
||||
<h1 className="text-2xl font-bold sm:text-3xl">{preview.name}</h1>
|
||||
<Button
|
||||
onClick={handleAddToLibrary}
|
||||
disabled={fetchPerson.isPending}
|
||||
size="sm"
|
||||
>
|
||||
{fetchPerson.isPending ? (
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||
) : (
|
||||
<Plus className="mr-2 h-4 w-4" />
|
||||
)}
|
||||
{fetchPerson.isPending ? "Adding..." : "Add to Library"}
|
||||
</Button>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center justify-center gap-2 text-sm text-muted-foreground sm:justify-start sm:gap-3">
|
||||
{preview.known_for_department && (
|
||||
<span>{preview.known_for_department}</span>
|
||||
)}
|
||||
{preview.birthday && (
|
||||
<>
|
||||
<span>•</span>
|
||||
<span>Born: {formatDate(preview.birthday)}</span>
|
||||
</>
|
||||
)}
|
||||
{preview.deathday && (
|
||||
<>
|
||||
<span>•</span>
|
||||
<span>Died: {formatDate(preview.deathday)}</span>
|
||||
</>
|
||||
)}
|
||||
{preview.place_of_birth && (
|
||||
<>
|
||||
<span>•</span>
|
||||
<span>{preview.place_of_birth}</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{preview.biography && (
|
||||
<p className="text-sm text-muted-foreground leading-relaxed max-w-2xl line-clamp-6">
|
||||
{preview.biography}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Separator />
|
||||
|
||||
<TmdbFilmographySection
|
||||
filmography={preview.filmography}
|
||||
libraryMap={libraryMap}
|
||||
libraryLoaded={libraryLoaded}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
interface TmdbFilmographySectionProps {
|
||||
filmography: { cast: TmdbFilmographyItem[]; crew: TmdbFilmographyItem[] };
|
||||
libraryMap: Map<number, import("@/types").Entry>;
|
||||
libraryLoaded: boolean;
|
||||
}
|
||||
|
||||
function TmdbFilmographySection({
|
||||
filmography,
|
||||
libraryMap,
|
||||
libraryLoaded,
|
||||
}: TmdbFilmographySectionProps) {
|
||||
const [libraryPage, setLibraryPage] = useState(0);
|
||||
const [otherPage, setOtherPage] = useState(0);
|
||||
const PAGE_SIZE = 6;
|
||||
const GRID =
|
||||
"grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6";
|
||||
|
||||
if (!libraryLoaded) {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<h2 className="text-xl font-semibold">Filmography</h2>
|
||||
<div className={GRID}>
|
||||
{Array.from({ length: 6 }).map((_, i) => (
|
||||
<Skeleton key={i} className="aspect-2/3 rounded-lg" />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const allCredits = [
|
||||
...(filmography.cast ?? []),
|
||||
...(filmography.crew?.filter(
|
||||
(c) => c.job === "Director" || c.department === "Directing",
|
||||
) ?? []),
|
||||
];
|
||||
const seenIds = new Set<number>();
|
||||
const deduped = allCredits.filter((c) => {
|
||||
if (seenIds.has(c.id)) return false;
|
||||
seenIds.add(c.id);
|
||||
return true;
|
||||
});
|
||||
|
||||
const tmdbIdToLibraryEntry = new Map<number, import("@/types").Entry>();
|
||||
for (const entry of libraryMap.values()) {
|
||||
if (entry.entryIds?.tmdb_id != null) {
|
||||
tmdbIdToLibraryEntry.set(Number(entry.entryIds.tmdb_id), entry);
|
||||
}
|
||||
}
|
||||
|
||||
const sorted = [...deduped].sort(
|
||||
(a, b) => (b.popularity ?? 0) - (a.popularity ?? 0),
|
||||
);
|
||||
const libraryCredits = sorted.filter((c) => tmdbIdToLibraryEntry.has(c.id));
|
||||
|
||||
const isSelfRole = (character?: string) => {
|
||||
if (!character) return false;
|
||||
const lower = character.toLowerCase().trim();
|
||||
return (
|
||||
lower === "self" ||
|
||||
lower.startsWith("self -") ||
|
||||
lower.startsWith("self (") ||
|
||||
lower === "themselves" ||
|
||||
lower === "himself" ||
|
||||
lower === "herself"
|
||||
);
|
||||
};
|
||||
const otherCredits = sorted
|
||||
.filter((c) => !tmdbIdToLibraryEntry.has(c.id))
|
||||
.sort((a, b) => {
|
||||
const aSelf = isSelfRole(a.character) ? 1 : 0;
|
||||
const bSelf = isSelfRole(b.character) ? 1 : 0;
|
||||
if (aSelf !== bSelf) return aSelf - bSelf;
|
||||
const dateA = new Date(
|
||||
a.release_date || a.first_air_date || "1900",
|
||||
).getTime();
|
||||
const dateB = new Date(
|
||||
b.release_date || b.first_air_date || "1900",
|
||||
).getTime();
|
||||
return dateB - dateA;
|
||||
});
|
||||
|
||||
if (sorted.length === 0) {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<h2 className="text-xl font-semibold">Filmography</h2>
|
||||
<p className="text-sm text-muted-foreground">No filmography found.</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const librarySlice = libraryCredits.slice(
|
||||
libraryPage * PAGE_SIZE,
|
||||
(libraryPage + 1) * PAGE_SIZE,
|
||||
);
|
||||
const otherSlice = otherCredits.slice(
|
||||
otherPage * PAGE_SIZE,
|
||||
(otherPage + 1) * PAGE_SIZE,
|
||||
);
|
||||
const libraryTotalPages = Math.ceil(libraryCredits.length / PAGE_SIZE);
|
||||
const otherTotalPages = Math.ceil(otherCredits.length / PAGE_SIZE);
|
||||
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
<h2 className="text-xl font-semibold">Filmography</h2>
|
||||
|
||||
{libraryCredits.length > 0 && (
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="text-sm font-medium text-muted-foreground uppercase tracking-wide">
|
||||
In Your Library ({libraryCredits.length})
|
||||
</h3>
|
||||
{libraryTotalPages > 1 && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
disabled={libraryPage === 0}
|
||||
onClick={() => setLibraryPage((p) => p - 1)}
|
||||
>
|
||||
<ChevronLeft className="h-4 w-4" />
|
||||
</Button>
|
||||
<span className="text-xs text-muted-foreground tabular-nums">
|
||||
{libraryPage + 1}/{libraryTotalPages}
|
||||
</span>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
disabled={libraryPage === libraryTotalPages - 1}
|
||||
onClick={() => setLibraryPage((p) => p + 1)}
|
||||
>
|
||||
<ChevronRight className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className={GRID}>
|
||||
{librarySlice.map((credit) => {
|
||||
const entry = tmdbIdToLibraryEntry.get(credit.id)!;
|
||||
return (
|
||||
<div key={credit.id} className="space-y-1">
|
||||
<EntryCard entry={entry} />
|
||||
{credit.character && (
|
||||
<p className="text-xs text-muted-foreground text-center line-clamp-1 px-1">
|
||||
{credit.character}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{otherCredits.length > 0 && (
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="text-sm font-medium text-muted-foreground uppercase tracking-wide">
|
||||
Not in Library ({otherCredits.length})
|
||||
</h3>
|
||||
{otherTotalPages > 1 && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
disabled={otherPage === 0}
|
||||
onClick={() => setOtherPage((p) => p - 1)}
|
||||
>
|
||||
<ChevronLeft className="h-4 w-4" />
|
||||
</Button>
|
||||
<span className="text-xs text-muted-foreground tabular-nums">
|
||||
{otherPage + 1}/{otherTotalPages}
|
||||
</span>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
disabled={otherPage === otherTotalPages - 1}
|
||||
onClick={() => setOtherPage((p) => p + 1)}
|
||||
>
|
||||
<ChevronRight className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className={GRID}>
|
||||
{otherSlice.map((credit) => {
|
||||
const tmdbEntry: TmdbEntry = {
|
||||
id: credit.id,
|
||||
title: credit.title,
|
||||
name: credit.name,
|
||||
poster_path: credit.poster_path,
|
||||
backdrop_path: null,
|
||||
release_date: credit.release_date,
|
||||
first_air_date: credit.first_air_date,
|
||||
media_type: credit.media_type,
|
||||
overview: "",
|
||||
vote_average: 0,
|
||||
vote_count: 0,
|
||||
genre_ids: [],
|
||||
popularity: credit.popularity ?? 0,
|
||||
};
|
||||
return (
|
||||
<div key={credit.id} className="space-y-1">
|
||||
<EntryCard tmdbEntry={tmdbEntry} />
|
||||
{credit.character && (
|
||||
<p className="text-xs text-muted-foreground text-center line-clamp-1 px-1">
|
||||
{credit.character}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import { useCommandPaletteStore } from "@/stores/useCommandPaletteStore";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { Star, Plus, Loader2, ExternalLink } from "lucide-react";
|
||||
import { Plus, Loader2, ExternalLink } from "lucide-react";
|
||||
import { EntryDetailsSkeleton } from "@/components/skeletons/PageSkeletons";
|
||||
import { CastList } from "@/components/entries/CastList";
|
||||
import { getYear, formatRuntime } from "@/lib/media-utils";
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
MediaSkeleton,
|
||||
CalendarSkeleton,
|
||||
SettingsSkeleton,
|
||||
DiscoveryVideosSkeleton,
|
||||
} from "@/components/skeletons/PageSkeletons";
|
||||
|
||||
// Lazy-loaded pages
|
||||
@@ -94,6 +95,11 @@ const PersonDetailsPage = lazy(() =>
|
||||
const SettingsPage = lazy(() =>
|
||||
import("@/pages/SettingsPage").then((m) => ({ default: m.SettingsPage })),
|
||||
);
|
||||
const DiscoveryVideosPage = lazy(() =>
|
||||
import("@/pages/DiscoveryVideosPage").then((m) => ({
|
||||
default: m.DiscoveryVideosPage,
|
||||
})),
|
||||
);
|
||||
const DiscoverPage = lazy(() =>
|
||||
import("@/pages/DiscoverPage").then((m) => ({ default: m.DiscoverPage })),
|
||||
);
|
||||
@@ -192,6 +198,14 @@ export const router = createRouter([
|
||||
</SuspensePage>
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "/discovery-videos",
|
||||
element: (
|
||||
<SuspensePage fallback={<DiscoveryVideosSkeleton />}>
|
||||
<DiscoveryVideosPage />
|
||||
</SuspensePage>
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "/calendar",
|
||||
element: (
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { create } from "zustand";
|
||||
|
||||
type FilterTab = "all" | "movies" | "tv" | "favorites" | "hidden";
|
||||
type FilterTab = "all" | "movies" | "tv";
|
||||
type SortField =
|
||||
| "date_last_seen"
|
||||
| "createdAt"
|
||||
@@ -25,9 +25,13 @@ interface LibraryFiltersState {
|
||||
sortField: SortField;
|
||||
sortDir: SortDir;
|
||||
filters: Filters;
|
||||
favoritesOnly: boolean;
|
||||
hiddenOnly: boolean;
|
||||
|
||||
setActiveTab: (tab: FilterTab) => void;
|
||||
setSearch: (search: string) => void;
|
||||
setFavoritesOnly: (value: boolean) => void;
|
||||
setHiddenOnly: (value: boolean) => void;
|
||||
setSortField: (field: SortField) => void;
|
||||
setSortDir: (dir: SortDir) => void;
|
||||
setFilters: (updater: Filters | ((prev: Filters) => Filters)) => void;
|
||||
@@ -51,9 +55,13 @@ export const useLibraryFiltersStore = create<LibraryFiltersState>((set) => ({
|
||||
sortField: "date_last_seen",
|
||||
sortDir: "desc",
|
||||
filters: defaultFilters,
|
||||
favoritesOnly: false,
|
||||
hiddenOnly: false,
|
||||
|
||||
setActiveTab: (tab) => set({ activeTab: tab }),
|
||||
setSearch: (search) => set({ search }),
|
||||
setFavoritesOnly: (value) => set({ favoritesOnly: value }),
|
||||
setHiddenOnly: (value) => set({ hiddenOnly: value }),
|
||||
setSortField: (field) => set({ sortField: field }),
|
||||
setSortDir: (dir) => set({ sortDir: dir }),
|
||||
setFilters: (updater) =>
|
||||
@@ -68,6 +76,8 @@ export const useLibraryFiltersStore = create<LibraryFiltersState>((set) => ({
|
||||
sortField: "date_last_seen",
|
||||
sortDir: "desc",
|
||||
filters: defaultFilters,
|
||||
favoritesOnly: false,
|
||||
hiddenOnly: false,
|
||||
}),
|
||||
}));
|
||||
|
||||
|
||||
@@ -232,6 +232,30 @@ export interface Statistics {
|
||||
totalWatchTime: number;
|
||||
}
|
||||
|
||||
// Discovery videos (personal video vault)
|
||||
export interface DiscoveryVideo {
|
||||
id: number;
|
||||
title: string;
|
||||
description: string | null;
|
||||
filename: string;
|
||||
original_name: string;
|
||||
mime_type: string;
|
||||
size: number;
|
||||
duration: number | null;
|
||||
thumbnail_path: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
entries?: Entry[];
|
||||
}
|
||||
|
||||
export interface DiscoveryVideoPaginatedResponse {
|
||||
videos: DiscoveryVideo[];
|
||||
page: number;
|
||||
limit: number;
|
||||
total: number;
|
||||
totalPages: number;
|
||||
}
|
||||
|
||||
// TMDB types for discover/search
|
||||
export interface TmdbEntry {
|
||||
id: number;
|
||||
|
||||
Reference in new issue
Block a user