From cdbaedd7d0af4af342bc535daf70cf0ee247cd9f Mon Sep 17 00:00:00 2001
From: X4Lo
Date: Tue, 23 Jun 2026 03:39:16 +0100
Subject: [PATCH] Add watch status for TV series with UI and auto-fix
Added watch_status column to Entry model (plan_to_watch/watching/completed/
on_hold/dropped). Status pill on entry details page opens selection dialog.
Set Status in quick actions menu and EntryCard dropdown (TV only).
Status filter in Library filter popover. Maintenance auto-fix endpoint
that sets statuses based on watched episodes (excl. season 0).
---
backend/controllers/entryController.js | 32 +--
backend/controllers/maintenanceController.js | 7 +-
backend/models/Entry.js | 42 ++--
backend/routes/maintenance.routes.js | 30 +--
backend/services/maintenanceService.js | 198 +++++++++++++-----
react_frontend/src/api/maintenance.ts | 31 ++-
.../src/components/entries/EntryCard.tsx | 129 +++++++++---
react_frontend/src/pages/EntryDetailsPage.tsx | 184 ++++++++++++----
react_frontend/src/pages/LibraryPage.tsx | 177 ++++++++++------
react_frontend/src/pages/SettingsPage.tsx | 108 ++++++++--
react_frontend/src/types/index.ts | 11 +-
11 files changed, 663 insertions(+), 286 deletions(-)
diff --git a/backend/controllers/entryController.js b/backend/controllers/entryController.js
index 5209bfa..b7e9b63 100644
--- a/backend/controllers/entryController.js
+++ b/backend/controllers/entryController.js
@@ -1,9 +1,9 @@
-const EntryRating = require("../models/EntryRating");
-const collectionManager = require("../services/collectionManager");
-const entryManager = require("../services/entryManager");
-const entryService = require("../services/entryService");
-const tmdbService = require("../services/tmdbService");
-const asyncWrapper = require("../utils/asyncWrapper");
+const EntryRating = require('../models/EntryRating');
+const collectionManager = require('../services/collectionManager');
+const entryManager = require('../services/entryManager');
+const entryService = require('../services/entryService');
+const tmdbService = require('../services/tmdbService');
+const asyncWrapper = require('../utils/asyncWrapper');
const _collectionManager = collectionManager;
const _entryManager = entryManager;
@@ -105,7 +105,7 @@ class EntryController {
const seasons = await _entryService.getEntrySeasons(id);
if (seasons.length == 0) {
- res.status(204).json({ message: "Provided entry has no seasons" });
+ return res.status(204).json({ message: 'Provided entry has no seasons' });
}
res.status(200).json(seasons);
@@ -145,7 +145,7 @@ class EntryController {
const { page } = req.query;
const data = await tmdbService.fetchTrending(type, page || 1);
if (!data)
- return res.status(500).json({ message: "Failed to fetch trending data" });
+ return res.status(500).json({ message: 'Failed to fetch trending data' });
res.status(200).json(data);
});
@@ -155,7 +155,7 @@ class EntryController {
const { page } = req.query;
const data = await tmdbService.fetchPopular(type, page || 1);
if (!data)
- return res.status(500).json({ message: "Failed to fetch popular data" });
+ return res.status(500).json({ message: 'Failed to fetch popular data' });
res.status(200).json(data);
});
@@ -163,10 +163,10 @@ class EntryController {
getTmdbSearch = asyncWrapper(async (req, res) => {
const { query, page } = req.query;
if (!query)
- return res.status(400).json({ message: "Query parameter is required" });
+ return res.status(400).json({ message: 'Query parameter is required' });
const data = await tmdbService.searchMulti(query, page || 1);
if (!data)
- return res.status(500).json({ message: "Failed to search TMDB" });
+ return res.status(500).json({ message: 'Failed to search TMDB' });
res.status(200).json(data);
});
@@ -178,7 +178,7 @@ class EntryController {
if (!data)
return res
.status(500)
- .json({ message: "Failed to fetch top rated data" });
+ .json({ message: 'Failed to fetch top rated data' });
res.status(200).json(data);
});
@@ -187,17 +187,17 @@ class EntryController {
const { page } = req.query;
const data = await tmdbService.fetchUpcoming(page || 1);
if (!data)
- return res.status(500).json({ message: "Failed to fetch upcoming data" });
+ return res.status(500).json({ message: 'Failed to fetch upcoming data' });
res.status(200).json(data);
});
// * GET - TMDB PREVIEW (fetch details without saving to library)
getTmdbPreview = asyncWrapper(async (req, res) => {
const { type, tmdbId } = req.params;
- const is_tvserie = type === "tv";
+ const is_tvserie = type === 'tv';
const data = await tmdbService.fetchEntryData(tmdbId, is_tvserie);
if (!data)
- return res.status(404).json({ message: "Entry not found on TMDB" });
+ return res.status(404).json({ message: 'Entry not found on TMDB' });
// Fetch credits in parallel
const creditsData = await tmdbService.fetchEntryCredits(tmdbId, is_tvserie);
@@ -208,7 +208,7 @@ class EntryController {
for (const c of creditsData.cast) {
credits.push({
id: c.credit_id || c.id,
- cast_type: "cast",
+ cast_type: 'cast',
character: is_tvserie
? c.roles?.[0]?.character || c.character || null
: c.character || null,
diff --git a/backend/controllers/maintenanceController.js b/backend/controllers/maintenanceController.js
index 4466980..d05a1a9 100644
--- a/backend/controllers/maintenanceController.js
+++ b/backend/controllers/maintenanceController.js
@@ -1,4 +1,4 @@
-const maintenanceService = require("../services/maintenanceService");
+const maintenanceService = require('../services/maintenanceService');
const _maintenanceService = maintenanceService;
@@ -63,6 +63,11 @@ class MaintenanceController {
const result = await _maintenanceService.cleanDuplicateCredits();
return res.status(200).json(result);
}
+
+ async autoFixWatchStatuses(req, res) {
+ const result = await _maintenanceService.autoFixWatchStatuses();
+ return res.status(200).json(result);
+ }
}
module.exports = new MaintenanceController();
diff --git a/backend/models/Entry.js b/backend/models/Entry.js
index efd2063..f35426e 100644
--- a/backend/models/Entry.js
+++ b/backend/models/Entry.js
@@ -1,13 +1,13 @@
-const { DataTypes } = require("sequelize");
-const sequelize = require("../config/database");
+const { DataTypes } = require('sequelize');
+const sequelize = require('../config/database');
-const Entry = sequelize.define("entry", {
+const Entry = sequelize.define('entry', {
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
title: { type: DataTypes.STRING(500) },
- original_title: { type: DataTypes.STRING(100), field: "original_title" },
- release_date: { type: DataTypes.DATE, field: "release_date" },
- release_status: { type: DataTypes.STRING(50), field: "release_status" },
+ original_title: { type: DataTypes.STRING(100), field: 'original_title' },
+ release_date: { type: DataTypes.DATE, field: 'release_date' },
+ release_status: { type: DataTypes.STRING(50), field: 'release_status' },
runtime: { type: DataTypes.INTEGER },
tagline: { type: DataTypes.STRING(200) },
@@ -15,13 +15,13 @@ const Entry = sequelize.define("entry", {
country: { type: DataTypes.STRING(30) },
certification: { type: DataTypes.INTEGER },
- network_studio: { type: DataTypes.STRING(40), field: "network_studio" },
- collection_id: { type: DataTypes.INTEGER, field: "collection_id" },
- max_cast: { type: DataTypes.INTEGER, field: "max_cast", defaultValue: 10 },
+ network_studio: { type: DataTypes.STRING(40), field: 'network_studio' },
+ collection_id: { type: DataTypes.INTEGER, field: 'collection_id' },
+ max_cast: { type: DataTypes.INTEGER, field: 'max_cast', defaultValue: 10 },
credit_fetched: {
type: DataTypes.BOOLEAN,
defaultValue: false,
- field: "credit_fetched",
+ field: 'credit_fetched',
},
watchlist: { type: DataTypes.BOOLEAN, defaultValue: false },
@@ -30,29 +30,35 @@ const Entry = sequelize.define("entry", {
showInCalendar: {
type: DataTypes.BOOLEAN,
defaultValue: true,
- field: "show_in_calendar",
+ field: 'show_in_calendar',
},
- autoSync: { type: DataTypes.BOOLEAN, defaultValue: true, field: "auto_sync" },
+ autoSync: { type: DataTypes.BOOLEAN, defaultValue: true, field: 'auto_sync' },
note: { type: DataTypes.STRING(2000) },
- is_tvseries: { type: DataTypes.BOOLEAN, field: "is_tvseries" },
+ is_tvseries: { type: DataTypes.BOOLEAN, field: 'is_tvseries' },
status: { type: DataTypes.STRING(20) },
- poster_path: { type: DataTypes.STRING(200), field: "poster_path" },
- banner_path: { type: DataTypes.STRING(200), field: "banner_path" },
+ poster_path: { type: DataTypes.STRING(200), field: 'poster_path' },
+ banner_path: { type: DataTypes.STRING(200), field: 'banner_path' },
- date_first_seen: { type: DataTypes.DATEONLY, field: "date_first_seen" },
- date_last_seen: { type: DataTypes.DATEONLY, field: "date_last_seen" },
+ date_first_seen: { type: DataTypes.DATEONLY, field: 'date_first_seen' },
+ date_last_seen: { type: DataTypes.DATEONLY, field: 'date_last_seen' },
last_fetch: { type: DataTypes.DATEONLY },
entry_sync_status: {
type: DataTypes.STRING(50),
- field: "entry_sync_status",
+ field: 'entry_sync_status',
allowNull: true,
},
director: { type: DataTypes.STRING(200), allowNull: true },
+ watch_status: {
+ type: DataTypes.STRING(20),
+ field: 'watch_status',
+ allowNull: true,
+ defaultValue: null,
+ },
});
module.exports = Entry;
diff --git a/backend/routes/maintenance.routes.js b/backend/routes/maintenance.routes.js
index 147e49f..734d7fc 100644
--- a/backend/routes/maintenance.routes.js
+++ b/backend/routes/maintenance.routes.js
@@ -1,61 +1,67 @@
-const express = require("express");
+const express = require('express');
const maintenanceRouter = express.Router();
-const maintenanceController = require("../controllers/maintenanceController");
+const maintenanceController = require('../controllers/maintenanceController');
// ! /maintenance
// * GET - Orphan files
-maintenanceRouter.get("/orphan-files", maintenanceController.getOrpanFiles);
+maintenanceRouter.get('/orphan-files', maintenanceController.getOrpanFiles);
// * GET - Missing files
maintenanceRouter.get(
- "/orphan-media-records",
+ '/orphan-media-records',
maintenanceController.getOrphanMediaRecords,
);
// * DELETE - Orphan files
maintenanceRouter.delete(
- "/orphan-files",
+ '/orphan-files',
maintenanceController.deleteOrpanFiles,
);
// * DELETE - Missing files
maintenanceRouter.delete(
- "/orphan-media-records",
+ '/orphan-media-records',
maintenanceController.deleteOrphanMediaRecords,
);
// * GET - Orphan people (dry run)
-maintenanceRouter.get("/orphan-people", maintenanceController.getOrphanPeople);
+maintenanceRouter.get('/orphan-people', maintenanceController.getOrphanPeople);
// * DELETE - Orphan people
maintenanceRouter.delete(
- "/orphan-people",
+ '/orphan-people',
maintenanceController.deleteOrphanPeople,
);
// * GET - Missing directors count
maintenanceRouter.get(
- "/missing-directors",
+ '/missing-directors',
maintenanceController.getMissingDirectors,
);
// * POST - Fix missing directors
maintenanceRouter.post(
- "/missing-directors",
+ '/missing-directors',
maintenanceController.fixMissingDirectors,
);
// * GET - Duplicate credits count
maintenanceRouter.get(
- "/duplicate-credits",
+ '/duplicate-credits',
maintenanceController.getDuplicateCredits,
);
// * DELETE - Clean duplicate credits
maintenanceRouter.delete(
- "/duplicate-credits",
+ '/duplicate-credits',
maintenanceController.cleanDuplicateCredits,
);
+// * POST - Auto-fix watch statuses based on watched episodes
+maintenanceRouter.post(
+ '/auto-fix-watch-statuses',
+ maintenanceController.autoFixWatchStatuses,
+);
+
module.exports = maintenanceRouter;
diff --git a/backend/services/maintenanceService.js b/backend/services/maintenanceService.js
index 19e5cef..1d52b19 100644
--- a/backend/services/maintenanceService.js
+++ b/backend/services/maintenanceService.js
@@ -1,14 +1,14 @@
-const path = require("path");
-const fsPromises = require("fs").promises;
-const fs = require("fs");
+const path = require('path');
+const fsPromises = require('fs').promises;
+const fs = require('fs');
-const Media = require("../models/Media");
-const People = require("../models/People");
-const Credit = require("../models/Credit");
-const Entry = require("../models/Entry");
+const Media = require('../models/Media');
+const People = require('../models/People');
+const Credit = require('../models/Credit');
+const Entry = require('../models/Entry');
-const { logToFile } = require("./logService");
-const configService = require("./configService");
+const { logToFile } = require('./logService');
+const configService = require('./configService');
const _configService = configService;
@@ -32,30 +32,30 @@ class MaintenanceService {
const dataPath = await _configService.getMediaFolder();
const mediaTypeFolder = {
- "entry;poster": path.join(dataPath, "images", "entries", "posters"),
- "entry;logo": path.join(dataPath, "images", "entries", "logos"),
- "entry;backdrop": path.join(dataPath, "images", "entries", "backdrops"),
+ 'entry;poster': path.join(dataPath, 'images', 'entries', 'posters'),
+ 'entry;logo': path.join(dataPath, 'images', 'entries', 'logos'),
+ 'entry;backdrop': path.join(dataPath, 'images', 'entries', 'backdrops'),
- "collection;poster": path.join(
+ 'collection;poster': path.join(
dataPath,
- "images",
- "collections",
- "posters",
+ 'images',
+ 'collections',
+ 'posters',
),
- "collection;backdrop": path.join(
+ 'collection;backdrop': path.join(
dataPath,
- "images",
- "collections",
- "backdrops",
+ 'images',
+ 'collections',
+ 'backdrops',
),
- "season;poster": path.join(dataPath, "images", "seasons", "posters"),
- "episode;still": path.join(dataPath, "images", "episodes", "stills"),
+ 'season;poster': path.join(dataPath, 'images', 'seasons', 'posters'),
+ 'episode;still': path.join(dataPath, 'images', 'episodes', 'stills'),
};
let missingFiles = [];
for (let i = 0; i < allMedia.length; i++) {
- const folderType = `${allMedia[i].mediaable};${allMedia[i].type.replace("_preview", "")}`;
+ const folderType = `${allMedia[i].mediaable};${allMedia[i].type.replace('_preview', '')}`;
if (!mediaTypeFolder[folderType]) continue;
@@ -73,7 +73,7 @@ class MaintenanceService {
};
for (let i = 0; i < missingFiles.length; i++) {
- removed[missingFiles[i].type + "s"] += 1;
+ removed[missingFiles[i].type + 's'] += 1;
if (!dry) missingFiles[i].destroy();
}
@@ -100,31 +100,31 @@ class MaintenanceService {
// ? Getting the name (without extention) of all media in database
const allMedia = (await Media.findAll()).map((m) => {
- return m.path.split(".")[0];
+ return m.path.split('.')[0];
});
// ? Loop trough the files of the images folder and check
// ? if a file doesnt exist in the allMedia array and mark it to delete
const mediaTypeFolder = {
- "entry;poster": path.join(dataPath, "images", "entries", "posters"),
- "entry;logo": path.join(dataPath, "images", "entries", "logos"),
- "entry;backdrop": path.join(dataPath, "images", "entries", "backdrops"),
+ 'entry;poster': path.join(dataPath, 'images', 'entries', 'posters'),
+ 'entry;logo': path.join(dataPath, 'images', 'entries', 'logos'),
+ 'entry;backdrop': path.join(dataPath, 'images', 'entries', 'backdrops'),
- "collection;poster": path.join(
+ 'collection;poster': path.join(
dataPath,
- "images",
- "collections",
- "posters",
+ 'images',
+ 'collections',
+ 'posters',
),
- "collection;backdrop": path.join(
+ 'collection;backdrop': path.join(
dataPath,
- "images",
- "collections",
- "backdrops",
+ 'images',
+ 'collections',
+ 'backdrops',
),
- "season;poster": path.join(dataPath, "images", "seasons", "posters"),
- "episode;still": path.join(dataPath, "images", "episodes", "stills"),
+ 'season;poster': path.join(dataPath, 'images', 'seasons', 'posters'),
+ 'episode;still': path.join(dataPath, 'images', 'episodes', 'stills'),
};
// * counter
@@ -146,12 +146,12 @@ class MaintenanceService {
// Check each file in the directory
for (let file of files) {
// preparing the file name
- const fileName = file.split(".")[0].replace("_preview", "");
+ const fileName = file.split('.')[0].replace('_preview', '');
const isInDatabase = allMedia.includes(fileName);
// if the file isn't in database even on other extentions then delete it
if (!isInDatabase) {
- removed[folderType.split(";")[1] + "s"]++; // Increment the count of removed files
+ removed[folderType.split(';')[1] + 's']++; // Increment the count of removed files
if (!dry) {
const filePath = path.join(directory, file);
await fsPromises.unlink(filePath);
@@ -182,14 +182,14 @@ class MaintenanceService {
* @param {boolean} [dry=false] - if true only return the count
*/
async deleteOrphanPeople(dry = false) {
- const { Sequelize } = require("sequelize");
+ const { Sequelize } = require('sequelize');
// Find all people who have no credits and are not pinned
const allPeople = await People.findAll({
include: [
{
model: Credit,
- as: "roles",
+ as: 'roles',
required: false,
},
],
@@ -222,9 +222,9 @@ class MaintenanceService {
include: [
{
model: Credit,
- as: "credits",
- where: { cast_type: "crew", job: "Director" },
- include: [{ model: People, as: "person", attributes: ["name"] }],
+ as: 'credits',
+ where: { cast_type: 'crew', job: 'Director' },
+ include: [{ model: People, as: 'person', attributes: ['name'] }],
required: false,
},
],
@@ -257,20 +257,20 @@ class MaintenanceService {
* @param {boolean} [dry=false] - if true only count, if false also delete
*/
async cleanDuplicateCredits(dry = false) {
- const { Sequelize } = require("sequelize");
+ const { Sequelize } = require('sequelize');
const duplicates = await Credit.findAll({
attributes: [
- "entry_id",
- "people_id",
- "cast_type",
- "character",
- "job",
- [Sequelize.fn("COUNT", Sequelize.col("id")), "cnt"],
- [Sequelize.fn("GROUP_CONCAT", Sequelize.col("id")), "ids"],
+ 'entry_id',
+ 'people_id',
+ 'cast_type',
+ 'character',
+ 'job',
+ [Sequelize.fn('COUNT', Sequelize.col('id')), 'cnt'],
+ [Sequelize.fn('GROUP_CONCAT', Sequelize.col('id')), 'ids'],
],
- group: ["entry_id", "people_id", "cast_type", "character", "job"],
- having: Sequelize.literal("COUNT(id) > 1"),
+ group: ['entry_id', 'people_id', 'cast_type', 'character', 'job'],
+ having: Sequelize.literal('COUNT(id) > 1'),
raw: true,
});
@@ -280,7 +280,7 @@ class MaintenanceService {
if (!dry) {
for (const row of duplicates) {
const idList = row.ids
- .split(",")
+ .split(',')
.map(Number)
.sort((a, b) => a - b);
// Keep the newest (highest ID), delete the older ones
@@ -310,6 +310,92 @@ class MaintenanceService {
deleted: deletedCount,
};
}
+
+ async autoFixWatchStatuses() {
+ const Episode = require('../models/Episode');
+ const EpisodeSeen = require('../models/EpisodeSeen');
+ const Season = require('../models/Season');
+ const { Op } = require('sequelize');
+
+ const tvEntries = await Entry.findAll({
+ where: { is_tvseries: true },
+ include: [
+ {
+ model: Season,
+ as: 'seasons',
+ where: { season_number: { [Op.gt]: 0 } },
+ include: [
+ {
+ model: Episode,
+ as: 'episodes',
+ include: [{ model: EpisodeSeen, as: 'episodeSeens' }],
+ },
+ ],
+ },
+ ],
+ });
+
+ let toCompleted = 0;
+ let toWatching = 0;
+ let toPlanToWatch = 0;
+
+ for (const entry of tvEntries) {
+ let totalEpisodes = 0;
+ let watchedEpisodes = 0;
+
+ for (const season of entry.seasons || []) {
+ for (const ep of season.episodes || []) {
+ totalEpisodes++;
+ if (ep.episodeSeens && ep.episodeSeens.length > 0) {
+ watchedEpisodes++;
+ }
+ }
+ }
+
+ const allWatched = totalEpisodes > 0 && watchedEpisodes === totalEpisodes;
+ const hasSomeWatched = watchedEpisodes > 0;
+
+ // Completed but not all watched → downgrade to watching
+ if (entry.watch_status === 'completed' && !allWatched) {
+ entry.watch_status = 'watching';
+ await entry.save();
+ toWatching++;
+ continue;
+ }
+
+ // All watched → completed (unless already completed)
+ if (allWatched && entry.watch_status !== 'completed') {
+ entry.watch_status = 'completed';
+ await entry.save();
+ toCompleted++;
+ continue;
+ }
+
+ // Has some watched but no status → watching
+ if (hasSomeWatched && !entry.watch_status) {
+ entry.watch_status = 'watching';
+ await entry.save();
+ toWatching++;
+ continue;
+ }
+
+ // In watchlist with no status → plan to watch
+ if (entry.watchlist && !entry.watch_status) {
+ entry.watch_status = 'plan_to_watch';
+ await entry.save();
+ toPlanToWatch++;
+ }
+ }
+
+ logToFile(
+ `Auto-fixed watch statuses: ${toCompleted} completed, ${toWatching} watching, ${toPlanToWatch} plan_to_watch`,
+ );
+ return {
+ completed: toCompleted,
+ watching: toWatching,
+ planToWatch: toPlanToWatch,
+ };
+ }
}
module.exports = new MaintenanceService();
diff --git a/react_frontend/src/api/maintenance.ts b/react_frontend/src/api/maintenance.ts
index 380c545..c828116 100644
--- a/react_frontend/src/api/maintenance.ts
+++ b/react_frontend/src/api/maintenance.ts
@@ -1,4 +1,4 @@
-import { api } from "@/lib/api";
+import { api } from '@/lib/api';
export interface OrphanResult {
posters: number;
@@ -13,39 +13,39 @@ export interface OrphanPeopleResult {
export const maintenanceApi = {
scanOrphanFiles: () =>
- api.get("/maintenance/orphan-files").then((r) => r.data),
+ api.get('/maintenance/orphan-files').then((r) => r.data),
deleteOrphanFiles: () =>
- api.delete("/maintenance/orphan-files").then((r) => r.data),
+ api.delete('/maintenance/orphan-files').then((r) => r.data),
scanOrphanMediaRecords: () =>
api
- .get("/maintenance/orphan-media-records")
+ .get('/maintenance/orphan-media-records')
.then((r) => r.data),
deleteOrphanMediaRecords: () =>
api
- .delete("/maintenance/orphan-media-records")
+ .delete('/maintenance/orphan-media-records')
.then((r) => r.data),
scanOrphanPeople: () =>
api
- .get("/maintenance/orphan-people")
+ .get('/maintenance/orphan-people')
.then((r) => r.data),
deleteOrphanPeople: () =>
api
- .delete("/maintenance/orphan-people")
+ .delete('/maintenance/orphan-people')
.then((r) => r.data),
scanMissingDirectors: () =>
api
- .get<{ count: number; fixed: number }>("/maintenance/missing-directors")
+ .get<{ count: number; fixed: number }>('/maintenance/missing-directors')
.then((r) => r.data),
fixMissingDirectors: () =>
api
- .post<{ count: number; fixed: number }>("/maintenance/missing-directors")
+ .post<{ count: number; fixed: number }>('/maintenance/missing-directors')
.then((r) => r.data),
scanDuplicateCredits: () =>
@@ -54,7 +54,7 @@ export const maintenanceApi = {
groups: number;
duplicates: number;
deleted: number;
- }>("/maintenance/duplicate-credits")
+ }>('/maintenance/duplicate-credits')
.then((r) => r.data),
cleanDuplicateCredits: () =>
@@ -63,6 +63,15 @@ export const maintenanceApi = {
groups: number;
duplicates: number;
deleted: number;
- }>("/maintenance/duplicate-credits")
+ }>('/maintenance/duplicate-credits')
+ .then((r) => r.data),
+
+ autoFixWatchStatuses: () =>
+ api
+ .post<{
+ completed: number;
+ watching: number;
+ planToWatch: number;
+ }>('/maintenance/auto-fix-watch-statuses')
.then((r) => r.data),
};
diff --git a/react_frontend/src/components/entries/EntryCard.tsx b/react_frontend/src/components/entries/EntryCard.tsx
index fabb2a5..bfe7cb5 100644
--- a/react_frontend/src/components/entries/EntryCard.tsx
+++ b/react_frontend/src/components/entries/EntryCard.tsx
@@ -1,5 +1,5 @@
-import { useState } from "react";
-import { Link, useNavigate } from "react-router-dom";
+import { useState } from 'react';
+import { Link, useNavigate } from 'react-router-dom';
import {
Plus,
Star,
@@ -15,35 +15,50 @@ import {
RefreshCw,
ImageIcon,
Settings,
-} from "lucide-react";
-import { Badge } from "@/components/ui/badge";
-import { Button } from "@/components/ui/button";
-import { Skeleton } from "@/components/ui/skeleton";
+ BookmarkCheck,
+} from 'lucide-react';
+import { Badge } from '@/components/ui/badge';
+import { Button } from '@/components/ui/button';
+import { Skeleton } from '@/components/ui/skeleton';
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu";
-import { getPosterUrl, getYear, formatRuntime } from "@/lib/media-utils";
+} from '@/components/ui/dropdown-menu';
+import { getPosterUrl, getYear, formatRuntime } from '@/lib/media-utils';
import {
useCreateEntry,
useDeleteEntry,
useUpdateEntry,
useRefreshEntry,
useEntrySeasons,
-} from "@/hooks/useEntries";
-import { useEntrySeenByEntry, useDeleteEntrySeen } from "@/hooks/useEntrySeen";
-import { useLibraryStore } from "@/stores/useLibraryStore";
-import { ConfirmDialog } from "@/components/dialogs/ConfirmDialog";
-import { EntrySeenDialog } from "@/components/dialogs/EntrySeenDialog";
-import { RatingDialog } from "@/components/dialogs/RatingDialog";
-import { MovieWatchHistoryDialog } from "@/components/dialogs/MovieWatchHistoryDialog";
-import { AddEntryToCollectionDialog } from "@/components/dialogs/AddEntryToCollectionDialog";
-import { EntryMediaDialog } from "@/components/dialogs/EntryMediaDialog";
-import { EntrySettingsDialog } from "@/components/dialogs/EntrySettingsDialog";
-import type { Entry, TmdbEntry } from "@/types";
+} from '@/hooks/useEntries';
+import { useEntrySeenByEntry, useDeleteEntrySeen } from '@/hooks/useEntrySeen';
+import { useLibraryStore } from '@/stores/useLibraryStore';
+import { ConfirmDialog } from '@/components/dialogs/ConfirmDialog';
+import { EntrySeenDialog } from '@/components/dialogs/EntrySeenDialog';
+import { RatingDialog } from '@/components/dialogs/RatingDialog';
+import { MovieWatchHistoryDialog } from '@/components/dialogs/MovieWatchHistoryDialog';
+import { AddEntryToCollectionDialog } from '@/components/dialogs/AddEntryToCollectionDialog';
+import { EntryMediaDialog } from '@/components/dialogs/EntryMediaDialog';
+import { EntrySettingsDialog } from '@/components/dialogs/EntrySettingsDialog';
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+} from '@/components/ui/dialog';
+import type { Entry, TmdbEntry } from '@/types';
+
+const CARD_WATCH_STATUSES = [
+ { value: 'plan_to_watch', label: 'Plan to Watch' },
+ { value: 'watching', label: 'Watching' },
+ { value: 'completed', label: 'Completed' },
+ { value: 'on_hold', label: 'On Hold' },
+ { value: 'dropped', label: 'Dropped' },
+];
interface EntryCardProps {
entry?: Entry;
@@ -75,6 +90,7 @@ export function EntryCard({
const [showMediaDialog, setShowMediaDialog] = useState(false);
const [showSettingsDialog, setShowSettingsDialog] = useState(false);
const [dropdownOpen, setDropdownOpen] = useState(false);
+ const [showStatusDialog, setShowStatusDialog] = useState(false);
const navigate = useNavigate();
const createEntry = useCreateEntry();
const deleteEntry = useDeleteEntry();
@@ -100,7 +116,7 @@ export function EntryCard({
// Resolve display data
const title =
- displayEntry?.title || tmdbEntry?.title || tmdbEntry?.name || "Untitled";
+ displayEntry?.title || tmdbEntry?.title || tmdbEntry?.name || 'Untitled';
const year = displayEntry
? getYear(displayEntry.release_date)
: getYear(tmdbEntry?.release_date || tmdbEntry?.first_air_date || null);
@@ -111,22 +127,22 @@ export function EntryCard({
const runtime =
displayEntry && !displayEntry.is_tvseries
? formatRuntime(displayEntry.runtime)
- : "";
+ : '';
const isTv =
displayEntry?.is_tvseries ||
- tmdbEntry?.media_type === "tv" ||
+ tmdbEntry?.media_type === 'tv' ||
!!tmdbEntry?.name;
const posterUrl = displayEntry
? getPosterUrl(displayEntry)
: tmdbEntry?.poster_path
? `https://image.tmdb.org/t/p/w342${tmdbEntry.poster_path}`
- : "/images/default-poster.png";
+ : '/images/default-poster.png';
const entryLink = displayEntry
? `/entry/${displayEntry.id}`
: tmdbEntry
- ? `/entry/tmdb/${isTv ? "tv" : "movie"}/${tmdbEntry.id}`
+ ? `/entry/tmdb/${isTv ? 'tv' : 'movie'}/${tmdbEntry.id}`
: undefined;
const handleAdd = (e: React.MouseEvent) => {
@@ -173,7 +189,7 @@ export function EntryCard({
src={posterUrl}
alt={title}
className={`h-full w-full object-cover transition-all duration-300 group-hover:scale-105 ${
- grayOutUnseen && !isSeen ? "grayscale opacity-40" : ""
+ grayOutUnseen && !isSeen ? 'grayscale opacity-40' : ''
}`}
loading="lazy"
/>
@@ -193,7 +209,7 @@ export function EntryCard({
{/* Quick actions button – top right, shown on hover */}
{isInLibrary && (
@@ -233,6 +249,20 @@ export function EntryCard({
Rate this
+ {isTv && (
+ <>
+
+ {
+ e.stopPropagation();
+ setShowStatusDialog(true);
+ }}
+ >
+
+ Set Status
+
+ >
+ )}
{!isTv && (
{
@@ -253,9 +283,9 @@ export function EntryCard({
}}
>
- {libraryEntry?.favorit ? "Unfavorite" : "Favorite"}
+ {libraryEntry?.favorit ? 'Unfavorite' : 'Favorite'}
{
@@ -273,7 +303,7 @@ export function EntryCard({
}}
>
- {libraryEntry?.hidden ? "Unhide" : "Hide"}
+ {libraryEntry?.hidden ? 'Unhide' : 'Hide'}
{/* Manage */}
@@ -285,9 +315,9 @@ export function EntryCard({
disabled={refreshEntry.isPending}
>
- {refreshEntry.isPending ? "Refreshing..." : "Refresh details"}
+ {refreshEntry.isPending ? 'Refreshing...' : 'Refresh details'}
{
@@ -346,7 +376,7 @@ export function EntryCard({
variant="secondary"
className="absolute bottom-2 right-2 text-[10px] px-1.5 py-0.5 opacity-90 z-10 pointer-events-none"
>
- {isTv ? "TV Series" : "Movie"}
+ {isTv ? 'TV Series' : 'Movie'}
)}
@@ -360,7 +390,7 @@ export function EntryCard({
{rating != null && rating > 0 && (
- {typeof rating === "number" ? rating.toFixed(1) : rating}
+ {typeof rating === 'number' ? rating.toFixed(1) : rating}
)}
{year && {year}}
@@ -381,7 +411,7 @@ export function EntryCard({
) : (
)}
- {createEntry.isPending ? "Adding..." : "Add to Library"}
+ {createEntry.isPending ? 'Adding...' : 'Add to Library'}
)}
@@ -460,6 +490,37 @@ export function EntryCard({
entry={libraryEntry}
/>
)}
+
+
>
);
}
diff --git a/react_frontend/src/pages/EntryDetailsPage.tsx b/react_frontend/src/pages/EntryDetailsPage.tsx
index b3bf051..03c65d0 100644
--- a/react_frontend/src/pages/EntryDetailsPage.tsx
+++ b/react_frontend/src/pages/EntryDetailsPage.tsx
@@ -1,26 +1,26 @@
-import { useState, useEffect } from "react";
-import { useParams, Link, useNavigate } from "react-router-dom";
+import { useState, useEffect } from 'react';
+import { useParams, Link, useNavigate } from 'react-router-dom';
import {
useEntry,
useEntrySeasons,
useRefreshEntry,
useEntryCredits,
-} from "@/hooks/useEntries";
-import { useEntrySeenByEntry, useDeleteEntrySeen } from "@/hooks/useEntrySeen";
-import { useCollections } from "@/hooks/useCollections";
-import { useLibraryStore } from "@/stores/useLibraryStore";
-import { useCommandPaletteStore } from "@/stores/useCommandPaletteStore";
-import { Badge } from "@/components/ui/badge";
-import { Button } from "@/components/ui/button";
-import { Separator } from "@/components/ui/separator";
-import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
+} from '@/hooks/useEntries';
+import { useEntrySeenByEntry, useDeleteEntrySeen } from '@/hooks/useEntrySeen';
+import { useCollections } from '@/hooks/useCollections';
+import { useLibraryStore } from '@/stores/useLibraryStore';
+import { useCommandPaletteStore } from '@/stores/useCommandPaletteStore';
+import { Badge } from '@/components/ui/badge';
+import { Button } from '@/components/ui/button';
+import { Separator } from '@/components/ui/separator';
+import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area';
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu";
+} from '@/components/ui/dropdown-menu';
import {
Heart,
MoreHorizontal,
@@ -35,25 +35,32 @@ import {
Trash2,
ExternalLink,
Play,
-} from "lucide-react";
+ BookmarkCheck,
+} from 'lucide-react';
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
-} from "@/components/ui/tooltip";
-import { CastList } from "@/components/entries/CastList";
-import { SeasonsContainer } from "@/components/entries/SeasonsContainer";
-import { StreamingSection } from "@/components/streaming/StreamingSection";
+} from '@/components/ui/tooltip';
+import { CastList } from '@/components/entries/CastList';
+import { SeasonsContainer } from '@/components/entries/SeasonsContainer';
+import { StreamingSection } from '@/components/streaming/StreamingSection';
// EpisodeWatchHistory is available for future use
-import { EntrySettingsDialog } from "@/components/dialogs/EntrySettingsDialog";
-import { EntrySeenDialog } from "@/components/dialogs/EntrySeenDialog";
-import { EntryMediaDialog } from "@/components/dialogs/EntryMediaDialog";
-import { AddEntryToCollectionDialog } from "@/components/dialogs/AddEntryToCollectionDialog";
-import { RatingDialog } from "@/components/dialogs/RatingDialog";
-import { MovieWatchHistoryDialog } from "@/components/dialogs/MovieWatchHistoryDialog";
-import { ConfirmDialog } from "@/components/dialogs/ConfirmDialog";
-import { EntryDetailsSkeleton } from "@/components/skeletons/PageSkeletons";
+import { EntrySettingsDialog } from '@/components/dialogs/EntrySettingsDialog';
+import { EntrySeenDialog } from '@/components/dialogs/EntrySeenDialog';
+import { EntryMediaDialog } from '@/components/dialogs/EntryMediaDialog';
+import { AddEntryToCollectionDialog } from '@/components/dialogs/AddEntryToCollectionDialog';
+import { RatingDialog } from '@/components/dialogs/RatingDialog';
+import { MovieWatchHistoryDialog } from '@/components/dialogs/MovieWatchHistoryDialog';
+import { ConfirmDialog } from '@/components/dialogs/ConfirmDialog';
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+} from '@/components/ui/dialog';
+import { EntryDetailsSkeleton } from '@/components/skeletons/PageSkeletons';
import {
getPosterUrl,
getBackdropUrl,
@@ -61,9 +68,44 @@ import {
getYear,
formatRuntime,
formatDate,
-} from "@/lib/media-utils";
-import { useUpdateEntry, useDeleteEntry } from "@/hooks/useEntries";
-import type { Collection, Entry } from "@/types";
+} from '@/lib/media-utils';
+import { useUpdateEntry, useDeleteEntry } from '@/hooks/useEntries';
+import type { Collection, Entry } from '@/types';
+
+const WATCH_STATUSES = [
+ {
+ value: 'plan_to_watch',
+ label: 'Plan to Watch',
+ color:
+ 'bg-slate-500/15 border-slate-500/30 text-slate-600 dark:text-slate-400',
+ },
+ {
+ value: 'watching',
+ label: 'Watching',
+ color: 'bg-blue-500/15 border-blue-500/30 text-blue-600 dark:text-blue-400',
+ },
+ {
+ value: 'completed',
+ label: 'Completed',
+ color:
+ 'bg-green-500/15 border-green-500/30 text-green-600 dark:text-green-400',
+ },
+ {
+ value: 'on_hold',
+ label: 'On Hold',
+ color:
+ 'bg-amber-500/15 border-amber-500/30 text-amber-600 dark:text-amber-400',
+ },
+ {
+ value: 'dropped',
+ label: 'Dropped',
+ color: 'bg-red-500/15 border-red-500/30 text-red-600 dark:text-red-400',
+ },
+];
+
+function getWatchStatusInfo(value: string | null | undefined) {
+ return WATCH_STATUSES.find((s) => s.value === value);
+}
export function EntryDetailsPage() {
const { id } = useParams<{ id: string }>();
@@ -92,6 +134,7 @@ export function EntryDetailsPage() {
const [showRatingDialog, setShowRatingDialog] = useState(false);
const [showWatchHistoryDialog, setShowWatchHistoryDialog] = useState(false);
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
+ const [showStatusDialog, setShowStatusDialog] = useState(false);
// Track recently viewed for command palette
const addRecentlyViewed = useCommandPaletteStore((s) => s.addRecentlyViewed);
@@ -100,7 +143,7 @@ export function EntryDetailsPage() {
addRecentlyViewed({
id: `lib-${entryId}`,
title: displayEntry.title,
- type: displayEntry.is_tvseries ? "tv" : "movie",
+ type: displayEntry.is_tvseries ? 'tv' : 'movie',
poster_path: displayEntry.poster_path,
libraryId: entryId,
tmdbId: displayEntry.entryIds?.tmdb_id ?? undefined,
@@ -119,7 +162,7 @@ export function EntryDetailsPage() {
const backdrop = getBackdropUrl(e);
const poster = getPosterUrl(e);
const director = credits.find(
- (c) => c.cast_type === "crew" && c.job === "Director",
+ (c) => c.cast_type === 'crew' && c.job === 'Director',
);
const toggleFavorite = () => {
@@ -162,6 +205,13 @@ export function EntryDetailsPage() {
Rate this
+ {e.is_tvseries && }
+ {e.is_tvseries && (
+ setShowStatusDialog(true)}>
+
+ Set Status
+
+ )}
{!e.is_tvseries && (
setShowWatchHistoryDialog(true)}
@@ -177,9 +227,9 @@ export function EntryDetailsPage() {
disabled={updateEntry.isPending}
>
- {e.favorit ? "Unfavorite" : "Favorite"}
+ {e.favorit ? 'Unfavorite' : 'Favorite'}
setShowCollectionDialog(true)}>
@@ -191,7 +241,7 @@ export function EntryDetailsPage() {
}
>
- {e.hidden ? "Unhide" : "Hide"}
+ {e.hidden ? 'Unhide' : 'Hide'}
{/* Manage */}
@@ -200,9 +250,9 @@ export function EntryDetailsPage() {
disabled={refreshEntry.isPending}
>
- {refreshEntry.isPending ? "Refreshing..." : "Refresh details"}
+ {refreshEntry.isPending ? 'Refreshing...' : 'Refresh details'}
setShowMediaDialog(true)}>
@@ -241,7 +291,7 @@ export function EntryDetailsPage() {
{/* Storyline */}
@@ -448,7 +514,7 @@ export function EntryDetailsPage() {
);
}
@@ -598,8 +692,8 @@ function EntryCollectionsSection({ entryId }: { entryId: number }) {
{col.entries && (
- {col.entries.length}{" "}
- {col.entries.length === 1 ? "title" : "titles"}
+ {col.entries.length}{' '}
+ {col.entries.length === 1 ? 'title' : 'titles'}
)}
diff --git a/react_frontend/src/pages/LibraryPage.tsx b/react_frontend/src/pages/LibraryPage.tsx
index 6df1cc0..c013afc 100644
--- a/react_frontend/src/pages/LibraryPage.tsx
+++ b/react_frontend/src/pages/LibraryPage.tsx
@@ -1,49 +1,49 @@
-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 } from 'lucide-react';
+import type { Entry } from '@/types';
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
-} from "@/components/ui/tooltip";
+} from '@/components/ui/tooltip';
const sortLabels: Record = {
- 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,29 +54,29 @@ 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;
});
}
@@ -105,12 +105,13 @@ export function LibraryPage() {
const [debouncedFilters, setDebouncedFilters] = useState(filters);
const [visibleCount, setVisibleCount] = useState(PAGE_SIZE);
const filtersInitialized = useRef(false);
+ const [statusFilter, setStatusFilter] = useState('');
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
@@ -121,9 +122,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,
@@ -169,21 +170,22 @@ export function LibraryPage() {
filters.userRatingMin ||
filters.userRatingMax ||
filters.yearMin ||
- filters.yearMax;
+ filters.yearMax ||
+ !!statusFilter;
const baseEntries = useMemo(() => {
switch (activeTab) {
- case "movies":
+ case 'movies':
return allEntries.filter(
(e) => !e.is_tvseries && !e.watchlist && !e.hidden,
);
- case "tv":
+ case 'tv':
return allEntries.filter(
(e) => e.is_tvseries && !e.watchlist && !e.hidden,
);
- case "favorites":
+ case 'favorites':
return allEntries.filter((e) => e.favorit && !e.watchlist && !e.hidden);
- case "hidden":
+ case 'hidden':
return allEntries.filter((e) => e.hidden);
default:
return allEntries.filter((e) => !e.watchlist && !e.hidden);
@@ -195,7 +197,7 @@ export function LibraryPage() {
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) {
@@ -208,6 +210,13 @@ export function LibraryPage() {
}
}
+ // Status filter (TV series only)
+ if (statusFilter) {
+ result = result.filter(
+ (e) => e.is_tvseries && e.watch_status === statusFilter,
+ );
+ }
+
if (debouncedFilters.genre) {
result = result.filter((e) =>
e.genres?.some((g) => g.name === debouncedFilters.genre),
@@ -272,7 +281,7 @@ export function LibraryPage() {
/>
{search && (
@@ -337,8 +346,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}
@@ -347,18 +356,18 @@ export function LibraryPage() {
@@ -388,7 +397,7 @@ export function LibraryPage() {
onValueChange={(v) =>
setFilters((f) => ({
...f,
- genre: v === "_all" ? "" : v || "",
+ genre: v === '_all' ? '' : v || '',
}))
}
>
@@ -405,6 +414,25 @@ export function LibraryPage() {
+
+
+
+
@@ -559,26 +587,26 @@ export function LibraryPage() {
@director:name
- {" "}
+ {' '}
— by director
@country:name
- {" "}
+ {' '}
— coming soon
@year:year
- {" "}
+ {' '}
— coming soon
{search && (
-
@@ -607,8 +635,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}
@@ -617,18 +645,18 @@ export function LibraryPage() {
setSortDir("desc")}
+ onClick={() => setSortDir('desc')}
>
↓ Desc
setSortDir("asc")}
+ onClick={() => setSortDir('asc')}
>
↑ Asc
@@ -660,7 +688,7 @@ export function LibraryPage() {
onValueChange={(v) =>
setFilters((f) => ({
...f,
- genre: v === "_all" ? "" : v || "",
+ genre: v === '_all' ? '' : v || '',
}))
}
>
@@ -677,6 +705,25 @@ export function LibraryPage() {
+
+
+
+
diff --git a/react_frontend/src/pages/SettingsPage.tsx b/react_frontend/src/pages/SettingsPage.tsx
index 3fa1a22..ea528c1 100644
--- a/react_frontend/src/pages/SettingsPage.tsx
+++ b/react_frontend/src/pages/SettingsPage.tsx
@@ -1,26 +1,26 @@
-import { useState } from "react";
-import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
-import { settingsApi } from "@/api/settings";
-import { maintenanceApi, type OrphanResult } from "@/api/maintenance";
-import { useForm } from "react-hook-form";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { z } from "zod";
+import { useState } from 'react';
+import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
+import { settingsApi } from '@/api/settings';
+import { maintenanceApi, type OrphanResult } from '@/api/maintenance';
+import { useForm } from 'react-hook-form';
+import { zodResolver } from '@hookform/resolvers/zod';
+import { z } from 'zod';
import {
Card,
CardContent,
CardHeader,
CardTitle,
CardDescription,
-} from "@/components/ui/card";
-import { Input } from "@/components/ui/input";
-import { Label } from "@/components/ui/label";
-import { Button } from "@/components/ui/button";
-import { Skeleton } from "@/components/ui/skeleton";
-import { Save, Search, Trash2, Loader2 } from "lucide-react";
-import type { Settings } from "@/types";
+} from '@/components/ui/card';
+import { Input } from '@/components/ui/input';
+import { Label } from '@/components/ui/label';
+import { Button } from '@/components/ui/button';
+import { Skeleton } from '@/components/ui/skeleton';
+import { Save, Search, Trash2, Loader2 } from 'lucide-react';
+import type { Settings } from '@/types';
const settingsSchema = z.object({
- tmdbApiKey: z.string().min(1, "TMDB API key is required"),
+ tmdbApiKey: z.string().min(1, 'TMDB API key is required'),
backPort: z.coerce.number().int().positive(),
});
@@ -30,7 +30,7 @@ function formatOrphanResult(result: OrphanResult): string {
if (result.logos) parts.push(`${result.logos} logo(s)`);
if (result.backdrops) parts.push(`${result.backdrops} backdrop(s)`);
if (result.stills) parts.push(`${result.stills} still(s)`);
- return parts.length > 0 ? parts.join(", ") : "None found";
+ return parts.length > 0 ? parts.join(', ') : 'None found';
}
function hasOrphans(result: OrphanResult | null): boolean {
@@ -88,7 +88,7 @@ function MissingDirectorsSection() {
{result && (
{result.count === 0
- ? "All entries have directors."
+ ? 'All entries have directors.'
: result.fixed > 0
? `Fixed ${result.fixed} of ${result.count} missing directors.`
: `${result.count} entries missing director.`}
@@ -150,7 +150,7 @@ function DuplicateCreditsSection() {
{result && (
{result.duplicates === 0
- ? "No duplicate credits found."
+ ? 'No duplicate credits found.'
: result.deleted > 0
? `Removed ${result.deleted} duplicates across ${result.groups} groups.`
: `${result.duplicates} duplicates across ${result.groups} groups.`}
@@ -160,17 +160,65 @@ function DuplicateCreditsSection() {
);
}
+function WatchStatusesSection() {
+ const [fixResult, setFixResult] = useState<{
+ completed: number;
+ watching: number;
+ planToWatch: number;
+ } | null>(null);
+
+ const autoFix = useMutation({
+ mutationFn: maintenanceApi.autoFixWatchStatuses,
+ onSuccess: (data) => setFixResult(data),
+ });
+
+ return (
+
+
+ TV series only. Sets status based on watched episodes (excl. season 0).
+
+
+ autoFix.mutate()}
+ disabled={autoFix.isPending}
+ >
+ {autoFix.isPending ? (
+
+ ) : (
+
+ )}
+ Auto-Fix
+
+
+ {fixResult && (
+
+ {fixResult.completed > 0 && `${fixResult.completed} → Completed. `}
+ {fixResult.watching > 0 && `${fixResult.watching} → Watching. `}
+ {fixResult.planToWatch > 0 &&
+ `${fixResult.planToWatch} → Plan to Watch. `}
+ {fixResult.completed === 0 &&
+ fixResult.watching === 0 &&
+ fixResult.planToWatch === 0 &&
+ 'All statuses up to date.'}
+
+ )}
+
+ );
+}
+
export function SettingsPage() {
const queryClient = useQueryClient();
const { data: settings, isLoading } = useQuery({
- queryKey: ["settings"],
+ queryKey: ['settings'],
queryFn: settingsApi.get,
});
const updateSettings = useMutation({
mutationFn: (data: Partial
) => settingsApi.update(data),
onSuccess: () => {
- queryClient.invalidateQueries({ queryKey: ["settings"] });
+ queryClient.invalidateQueries({ queryKey: ['settings'] });
},
});
@@ -241,7 +289,7 @@ export function SettingsPage() {
{errors.tmdbApiKey && (
@@ -252,7 +300,7 @@ export function SettingsPage() {
);
}
diff --git a/react_frontend/src/types/index.ts b/react_frontend/src/types/index.ts
index a2f9709..c7a42c6 100644
--- a/react_frontend/src/types/index.ts
+++ b/react_frontend/src/types/index.ts
@@ -15,9 +15,9 @@ export interface EntryRatings {
export interface Media {
id: number;
- mediaable: "entry" | "people" | "collection" | "season" | "episode";
+ mediaable: 'entry' | 'people' | 'collection' | 'season' | 'episode';
mediaable_id: number;
- type: "poster" | "backdrop" | "logo" | "still" | "profile";
+ type: 'poster' | 'backdrop' | 'logo' | 'still' | 'profile';
path: string;
is_local: boolean;
is_selected: boolean;
@@ -55,6 +55,7 @@ export interface Entry {
credits?: Credit[];
/** Computed — director name string for search (not persisted in DB) */
director?: string | null;
+ watch_status?: string | null;
seasons?: Season[];
entrySeens?: EntrySeen[];
episodeSeens?: EpisodeSeen[];
@@ -104,7 +105,7 @@ export interface Episode {
season?: Season;
}
-export type SeenAccuracy = "EXACT" | "ESTIMATED" | "UNKNOWN";
+export type SeenAccuracy = 'EXACT' | 'ESTIMATED' | 'UNKNOWN';
export interface EntrySeen {
id: number;
@@ -168,7 +169,7 @@ export interface Credit {
entry_id: number;
people_id: number;
character: string | null; // might contain multiple separated by ;
- cast_type: "cast" | "crew";
+ cast_type: 'cast' | 'crew';
department: string | null;
job: string | null;
episode_count?: number | null;
@@ -250,7 +251,7 @@ export interface TmdbPaginatedResponse {
export interface TmdbPreviewCredit {
id: string | number;
- cast_type: "cast";
+ cast_type: 'cast';
character: string | null;
people_id: number;
people: {