19 Commits
Author SHA1 Message Date
WonderAliceUwU 4f1cde1852 🔖 chore: release 1.2.5 2026-11-17 16:36:48 +01:00
WonderAliceUwU adf9993b10 ✅ test: cover the calendar and hidden sections end to end through the API 2026-11-17 16:33:02 +01:00
WonderAliceUwU 7da0377d50 ✨ feat: search and capped scrolling list for profiles, and per-card unsaved indicator 2026-11-17 16:31:23 +01:00
WonderAliceUwU 64f9a84678 ✨ feat: turn the settings check button amber while there are unsaved changes 2026-11-17 16:29:46 +01:00
WonderAliceUwU ee288e7bd7 💄 style: give the profile dialog more room, section icons and library pills 2026-11-17 16:28:32 +01:00
WonderAliceUwU 6a59aaffa3 💄 style: merge preferences into connections, profiles as a side column, language and region dropdowns 2026-11-17 16:26:42 +01:00
WonderAliceUwU 9ed8260a10 ⭐️ feat: filter upcoming by library folder, profile settings dialog, tests and docs 2026-11-17 15:48:12 +01:00
WonderAliceUwU 1376d75ed8 ♻️ refactor: build each profile's upcoming calendar from the titles in its own Jellyfin libraries 2026-11-17 15:36:00 +01:00
WonderAliceUwU 4cea990eb3 ⭐️ feat: choose the sections each profile sees and review its Jellyfin libraries from the admin menu 2026-11-17 15:24:45 +01:00
WonderAliceUwU 2b4119a906 ⭐️ feat: restrict who can see downloads and hide upcoming releases from libraries a profile cannot open 2026-11-17 15:09:48 +01:00
WonderAliceUwU 8fc9833679 🐛 fix: show the Home button label in English 2026-11-17 15:07:23 +01:00
WonderAliceUwU 0672b8c72b 🐛 fix: show the progress bar only in continue watching 2026-11-03 10:18:08 +01:00
WonderAliceUwU 591fac51b2 🔖 chore: release 1.2.4 2026-11-03 09:33:22 +01:00
WonderAliceUwU a926964834 🐛 fix: use the series TMDb id for episode cards so continue watching gets the right artwork 2026-11-03 09:33:22 +01:00
WonderAliceUwU fb07b27675 🔖 chore: release 1.2.3 2026-11-01 12:17:41 +01:00
WonderAliceUwU 9f1d50b35d 🐛 fix: show the wishlist heart on series opened from continue watching, hide card hearts on mobile and revalidate the app shell 2026-11-01 12:17:41 +01:00
WonderAliceUwU 3c7836e18b 🔖 chore: release 1.2.2 2026-10-30 13:01:16 +01:00
WonderAliceUwU 739afbefe3 ⭐️ feat: download a single episode of a series that is not in sonarr yet
- add the series with nothing monitored and search only that episode
- make the wishlist heart, play, delete and request plain icons split by dividers
2026-10-30 13:01:16 +01:00
WonderAliceUwU d7ff401d33 🐛 fix: keep the master password and save jellyfin from onboarding
- only a missing store counts as a fresh install; read errors no longer reopen the password setup
- read aliceflix.secure.json when omniarr.secure.json does not exist yet
- save the settings when loading the jellyfin users in onboarding
- show a short message instead of the proxy's html on 502, 503 and 504
- keep a wishlist per profile and add admin backup export and import
2026-10-30 12:37:22 +01:00
13 changed files with 2099 additions and 88 deletions

No files matched your search

+48 -3
View File
@@ -33,6 +33,7 @@ If OmniArr is useful to you, you can support its development on [Ko-fi](https://
<img width="4208" height="2562" alt="Screenshot 2026-10-13 at 09 47 49" src="https://github.com/user-attachments/assets/82766b80-fb0d-4ff2-b594-203e6b52828f" />
- A download manager to see what's cooking.
- Per-profile control of which sections each person sees (see [Profiles](#profiles)).
And many things more!
@@ -43,7 +44,7 @@ Create a directory for OmniArr and add this `docker-compose.yml`:
```yaml
services:
omniarr:
image: wonderalice/omniarr:1.2.1
image: wonderalice/omniarr:1.2.5
container_name: omniarr
restart: unless-stopped
ports:
@@ -90,11 +91,11 @@ the mount loses that state when the container is replaced.
The current release is available as:
```text
wonderalice/omniarr:1.2.1
wonderalice/omniarr:1.2.5
wonderalice/omniarr:latest
```
Pin `1.2.1` in production for repeatable updates. Use `latest` only when you want
Pin `1.2.5` in production for repeatable updates. Use `latest` only when you want
Compose to follow the newest published image.
## Build locally
@@ -122,6 +123,50 @@ npm run lint
npm run build
```
## Profiles
Open **Administration → Profiles** to see every Jellyfin profile. Selecting one
opens its settings:
- **Sections** are on/off switches for Search, Upcoming, Downloads, Wishlist,
K-Drama, Anime, Library and each network. Everything is on by default and
Home is always available. A hidden section disappears from the menu and the
server refuses its requests for that profile. The administrator always sees
everything.
- **Libraries** shows which Jellyfin libraries the profile can open. It is read
from Jellyfin and cannot be changed here; manage it in Jellyfin.
Save with the check button of the Profiles card.
### Upcoming and library access
Upcoming comes from Sonarr and Radarr, which know nothing about Jellyfin
permissions. To keep each profile's calendar to what it can open, OmniArr asks
Jellyfin for the libraries a profile cannot open and leaves out the releases
that are stored in them.
Sonarr, Radarr and Jellyfin often mount the media folder under different paths
(for example `/shared/Library/Anime` for Sonarr and `/library/Anime` for
Jellyfin), so a release is matched to a library by the **name of the library
folder** found in the series or movie path. Keep that folder name the same in
all three apps. A release whose path does not contain the name of any library is
shown to everyone, and if Jellyfin cannot be reached the calendar is not
filtered.
## Tests
```bash
npm test
```
The tests run against small stand-ins for Jellyfin, Sonarr and Radarr
(`server/test/mock-services.ts`). Some call the code directly and `api.e2e.test.ts`
starts the real server and signs in as the administrator and as profiles, so it
checks what each of them receives from the API. To point a running OmniArr at them while
developing, start them with `node dist-server/server/test/mock-services.js` after
a build; it prints the three URLs, accepts any API key and offers a `full`
profile and a `limited` one that cannot open Anime or Anime Movies.
## Data and security
OmniArr keeps critical state under `OMNIARR_DATA_DIR` (by default
+1 -1
View File
@@ -1,6 +1,6 @@
services:
omniarr:
image: wonderalice/omniarr:1.2.1
image: wonderalice/omniarr:1.2.5
# Para construir desde código fuente en su lugar, descomenta estas líneas:
# build:
# context: .
+2 -1
View File
@@ -12,7 +12,8 @@
"lint": "eslint .",
"preview": "vite preview",
"start": "node dist-server/server/index.js",
"serve": "npm run build && npm run start"
"serve": "npm run build && npm run start",
"test": "tsc -p tsconfig.server.json && node --test dist-server/server/test/*.test.js"
},
"dependencies": {
"react": "^19.2.5",
+197 -9
View File
@@ -4,11 +4,18 @@ import { BlockList, isIP } from 'node:net';
import { resolve } from 'node:path';
import {
defaultConfig,
HIDEABLE_SECTIONS,
type AppConfig,
type AuthPayload,
type BackupFile,
type MediaCard,
type WishlistEntry,
type WishlistTogglePayload,
type EpisodeRequestPayload,
type SeriesEpisodeRequestPayload,
type EpisodeWatchStateRequest,
type DiskSpaceStatus,
type HideableSection,
type HubPageResponse,
type JellyfinLoginPayload,
type MovieDeletePayload,
@@ -17,7 +24,18 @@ import {
type TitleDetailsRequest
} from '../shared/contracts.js';
import { decryptJson, deriveEncryptionKey, encryptJson, randomToken, verifyPassword, createPasswordRecord } from './lib/security.js';
import { loadState, migrateConfig, readAdmin, readEncryptedConfig, saveAdminAndConfig, updateEncryptedConfig } from './lib/store.js';
import {
loadState,
migrateConfig,
readAdmin,
readAllWishlists,
readEncryptedConfig,
readWishlist,
restoreBackup,
saveAdminAndConfig,
updateEncryptedConfig,
updateWishlist
} from './lib/store.js';
import {
getCalendar,
getConnectionStatuses,
@@ -35,12 +53,14 @@ import {
proxyJellyfinImage,
removeDownload,
requestEpisode,
requestSeriesEpisode,
requestMovie,
requestSeason,
requestSeries,
setEpisodeWatchState,
sanitizeConfig,
getDownloadsResponse,
getProfileLibraryAccess,
dismissCompletedDownload,
dismissAllCompletedDownloads
} from './lib/services.js';
@@ -252,6 +272,89 @@ async function routeRequest(request: IncomingMessage, response: ServerResponse):
return;
}
if (url.pathname.startsWith('/api/admin/') && session?.role !== 'admin') {
sendJson(response, 403, { error: 'Administrator access is required.' });
return;
}
if (url.pathname === '/api/admin/profile-access' && method === 'GET') {
const config = await readConfig(session!.encryptionKey);
sendJson(response, 200, { profiles: await getProfileLibraryAccess(config) });
return;
}
// Sections the administrator switched off for this profile are closed on the
// server too, not only hidden from the menu.
const section = session?.role === 'user' && session.userId ? getSectionOfRoute(url.pathname) : null;
if (section) {
const config = await readConfig(session!.encryptionKey);
if ((config.preferences.hiddenSections[session!.userId!] ?? []).includes(section)) {
sendJson(response, 403, { error: 'This section is not available for your profile.' });
return;
}
}
if (url.pathname === '/api/admin/backup' && method === 'GET') {
const backup: BackupFile = {
app: 'omniarr',
format: 1,
exportedAt: new Date().toISOString(),
config: await readConfig(),
wishlists: await readAllWishlists()
};
const fileName = `omniarr-backup-${backup.exportedAt.slice(0, 10)}.json`;
response.writeHead(200, {
'Content-Type': 'application/json; charset=utf-8',
'Content-Disposition': `attachment; filename="${fileName}"`,
'Cache-Control': 'no-store'
});
response.end(JSON.stringify(backup, null, 2));
return;
}
if (url.pathname === '/api/admin/backup' && method === 'POST') {
let body: Partial<BackupFile>;
let config: AppConfig;
try {
body = await readJson<Partial<BackupFile>>(request);
if (body.app !== 'omniarr' || body.format !== 1 || !body.config || typeof body.config !== 'object') {
throw new Error('invalid');
}
config = mergeStoredConfig(body.config);
} catch {
sendJson(response, 400, { error: 'This file is not an OmniArr backup.' });
return;
}
config = { ...config, jellyfin: { ...config.jellyfin, userId: '' } };
await restoreBackup(
encryptJson(config, await getConfigEncryptionKey()),
sanitizeWishlists(body.wishlists)
);
sendJson(response, 200, { config, connections: await getConnectionStatuses(config) });
return;
}
if (url.pathname === '/api/wishlist' && method === 'GET') {
sendJson(response, 200, { items: await readWishlist(getWishlistOwner(session!)) });
return;
}
if (url.pathname === '/api/wishlist' && method === 'POST') {
const body = await readJson<WishlistTogglePayload>(request);
const card = sanitizeWishlistCard(body.card);
if (!card) {
sendJson(response, 400, { error: 'A title is required.' });
return;
}
const key = getWishlistKey(card);
const items = await updateWishlist(getWishlistOwner(session!), (entries) => {
const remaining = entries.filter((entry) => getWishlistKey(entry.card) !== key);
return body.wishlisted ? [{ card, addedAt: new Date().toISOString() }, ...remaining] : remaining;
});
sendJson(response, 200, { items });
return;
}
if (url.pathname === '/api/settings' && method === 'GET') {
const config = await readConfig(session!.encryptionKey);
sendJson(response, 200, session!.role === 'admin' ? config : redactConfig(config));
@@ -426,6 +529,14 @@ async function routeRequest(request: IncomingMessage, response: ServerResponse):
return;
}
if (url.pathname === '/api/requests/series-episode' && method === 'POST') {
const config = await readConfig(session!.encryptionKey);
const body = await readJson<SeriesEpisodeRequestPayload & { user: string | null }>(request);
await requestSeriesEpisode(config, body, body.user);
sendJson(response, 200, { ok: true });
return;
}
if (url.pathname === '/api/seasons/delete' && method === 'POST') {
const config = await readConfig(session!.encryptionKey);
const body = await readJson<SeasonDeletePayload>(request);
@@ -580,9 +691,17 @@ async function readConfig(legacyEncryptionKey?: Buffer): Promise<AppConfig> {
throw new Error('The configuration must be unlocked by an administrator.');
}
const stored = decryptJson<Partial<AppConfig>>(encrypted, encryptionKey);
const config = mergeStoredConfig(decryptJson<Partial<AppConfig>>(encrypted, encryptionKey));
// The Jellyfin user always comes from the profile the session signed in
// with; admin sessions have none, so a userId saved by older versions is ignored.
const userId = legacyEncryptionKey ? sessionUsers.get(legacyEncryptionKey) : undefined;
return { ...config, jellyfin: { ...config.jellyfin, userId: userId || '' } };
}
const config = sanitizeConfig({
// Fills in whatever a stored config (or an imported backup) leaves out with
// the defaults, so configs saved by older versions keep loading.
function mergeStoredConfig(stored: Partial<AppConfig>): AppConfig {
return sanitizeConfig({
preferences: {
...defaultConfig.preferences,
...(stored.preferences || {})
@@ -608,10 +727,76 @@ async function readConfig(legacyEncryptionKey?: Buffer): Promise<AppConfig> {
...(stored.tvdb || {})
}
});
// The Jellyfin user always comes from the profile the session signed in
// with; admin sessions have none, so a userId saved by older versions is ignored.
const userId = legacyEncryptionKey ? sessionUsers.get(legacyEncryptionKey) : undefined;
return { ...config, jellyfin: { ...config.jellyfin, userId: userId || '' } };
}
// Profiles keep their own wishlist; the administrator has no Jellyfin profile
// and shares a single one.
// The section of the app an API route serves, if the administrator can switch it off.
function getSectionOfRoute(pathname: string): HideableSection | null {
const section = pathname.startsWith('/api/downloads') ? 'downloads'
: pathname.startsWith('/api/calendar') ? 'calendar'
: pathname.startsWith('/api/search') ? 'search'
: pathname.startsWith('/api/hubs/') ? decodeURIComponent(pathname.replace('/api/hubs/', ''))
: '';
return HIDEABLE_SECTIONS.find((candidate) => candidate.id === section)?.id ?? null;
}
function getWishlistOwner(session: SessionRecord): string {
return session.role === 'user' && session.userId ? session.userId : 'admin';
}
// The same title can reach the client as a Jellyfin card or a TMDb card, so
// titles are matched by their TMDb id when they have one.
function getWishlistKey(card: MediaCard): string {
return card.tmdbId ? `${card.mediaType === 'movie' ? 'movie' : 'tv'}:${card.tmdbId}` : card.id;
}
const WISHLIST_MEDIA_TYPES = new Set<MediaCard['mediaType']>(['movie', 'tv', 'series']);
// Only what the wishlist page needs to draw a tile and open the title is kept;
// progress and labels belong to the moment the card was saved.
function sanitizeWishlistCard(input: unknown): MediaCard | null {
if (!input || typeof input !== 'object') {
return null;
}
const card = input as Partial<MediaCard>;
const text = (value: unknown) => (typeof value === 'string' ? value : '');
const id = text(card.id);
if (!id || !card.mediaType || !WISHLIST_MEDIA_TYPES.has(card.mediaType)) {
return null;
}
return {
id,
tmdbId: Number(card.tmdbId) || undefined,
providerId: text(card.providerId) || undefined,
title: text(card.title),
subtitle: text(card.subtitle),
overview: text(card.overview),
mediaType: card.mediaType,
posterUrl: text(card.posterUrl),
backdropUrl: text(card.backdropUrl),
logoUrl: text(card.logoUrl) || undefined,
backdropLanguageFallback: card.backdropLanguageFallback ? true : undefined,
releaseDate: text(card.releaseDate) || undefined,
firstAirDate: text(card.firstAirDate) || undefined
};
}
function sanitizeWishlists(input: unknown): Record<string, WishlistEntry[]> {
const wishlists: Record<string, WishlistEntry[]> = {};
if (!input || typeof input !== 'object') {
return wishlists;
}
for (const [owner, entries] of Object.entries(input)) {
if (!Array.isArray(entries)) {
continue;
}
wishlists[owner] = entries.flatMap((entry: Partial<WishlistEntry>) => {
const card = sanitizeWishlistCard(entry?.card);
return card ? [{ card, addedAt: typeof entry.addedAt === 'string' ? entry.addedAt : new Date().toISOString() }] : [];
});
}
return wishlists;
}
async function getConfigEncryptionKey(): Promise<Buffer> {
@@ -662,14 +847,17 @@ async function serveApp(pathname: string, response: ServerResponse): Promise<voi
try {
const content = await readFile(filePath);
response.writeHead(200, {
'Content-Type': contentType(filePath)
'Content-Type': contentType(filePath),
// Hashed bundles never change; the entry page must always be revalidated so a new release reaches every browser.
'Cache-Control': relativePath.startsWith('/assets/') ? 'public, max-age=31536000, immutable' : 'no-cache'
});
response.end(content);
} catch {
try {
const indexHtml = await readFile(resolve(process.cwd(), 'dist', 'index.html'));
response.writeHead(200, {
'Content-Type': 'text/html; charset=utf-8'
'Content-Type': 'text/html; charset=utf-8',
'Cache-Control': 'no-cache'
});
response.end(indexHtml);
} catch {
+198 -10
View File
@@ -11,12 +11,15 @@ import type {
EpisodeRequestPayload,
EpisodeWatchStateRequest,
HubPageResponse,
HideableSection,
HubSection,
MediaCard,
MovieDeletePayload,
ProcessingItem,
ProfileLibraryAccess,
SeasonDeletePayload,
SeasonRequestPayload,
SeriesEpisodeRequestPayload,
SelectOption,
ServiceOptionsResponse,
TitleDetailsEpisode,
@@ -25,6 +28,7 @@ import type {
TitleDetailsSeason,
TitleDetailsCastMember
} from '../../shared/contracts.js';
import { HIDEABLE_SECTIONS } from '../../shared/contracts.js';
const TMDB_IMAGE = 'https://image.tmdb.org/t/p';
const TMDB_ARTWORK_TTL_MS = 6 * 60 * 60 * 1000;
@@ -189,6 +193,7 @@ interface SonarrCalendarRecord {
series?: {
title?: string;
tmdbId?: number;
path?: string;
images?: Array<{ coverType?: string; remoteUrl?: string; url?: string }>;
year?: number;
status?: string;
@@ -239,6 +244,7 @@ interface RadarrCalendarRecord {
digitalRelease?: string;
monitored?: boolean;
hasFile?: boolean;
path?: string;
images?: Array<{ coverType?: string; remoteUrl?: string; url?: string }>;
}
@@ -370,6 +376,24 @@ let tvdbTokenCache: { token: string; expiresAt: number } | null = null;
const tmdbArtworkCache = new Map<string, { expiresAt: number; value: Promise<TmdbArtwork> }>();
const tvdbTranslationCache = new Map<string, { expiresAt: number; value: Promise<TvdbTranslationRecord | null> }>();
const HIDEABLE_SECTION_IDS = new Set<string>(HIDEABLE_SECTIONS.map((section) => section.id));
function sanitizeHiddenSections(input: unknown): Record<string, HideableSection[]> {
const hidden: Record<string, HideableSection[]> = {};
if (!input || typeof input !== 'object') {
return hidden;
}
for (const [userId, sections] of Object.entries(input)) {
const valid = Array.isArray(sections)
? [...new Set(sections.map(String))].filter((section): section is HideableSection => HIDEABLE_SECTION_IDS.has(section))
: [];
if (userId && valid.length) {
hidden[userId] = valid;
}
}
return hidden;
}
export function sanitizeConfig(input: AppConfig): AppConfig {
return {
preferences: {
@@ -382,7 +406,8 @@ export function sanitizeConfig(input: AppConfig): AppConfig {
: [],
radarrDownloadQualityProfileIds: Array.isArray(input.preferences.radarrDownloadQualityProfileIds)
? input.preferences.radarrDownloadQualityProfileIds.map(String)
: []
: [],
hiddenSections: sanitizeHiddenSections(input.preferences.hiddenSections)
},
jellyfin: {
baseUrl: normalizeBaseUrl(input.jellyfin.baseUrl),
@@ -744,16 +769,22 @@ export async function getCalendar(config: AppConfig, start: Date, end: Date): Pr
getRadarrCalendar(config, start, end)
])
const sonarrItems = sonarrResult.status === 'fulfilled'
? sonarrResult.value.map((item) => mapSonarrCalendarEntry(item))
: []
const radarrItems = radarrResult.status === 'fulfilled'
? radarrResult.value.map((item) => mapRadarrCalendarEntry(item))
: []
// Link each entry to its Jellyfin item, as search does, so the details can
// tell which episodes are already in the library.
const library = await getLibrarySnapshot(config).catch(() => null);
// A profile does not see releases that will be stored in a library it cannot open.
const hiddenFolders = await getHiddenLibraryFolders(config);
const sonarrItems = sonarrResult.status === 'fulfilled'
? sonarrResult.value
.filter((item) => !isInFolders(item.series?.path, hiddenFolders))
.map((item) => mapSonarrCalendarEntry(item))
: []
const radarrItems = radarrResult.status === 'fulfilled'
? radarrResult.value
.filter((item) => !isInFolders(item.path, hiddenFolders))
.map((item) => mapRadarrCalendarEntry(item))
: []
const libraryProviderIds = new Map<string, string>();
for (const libraryItem of library?.allItems ?? []) {
const libraryCard = jellyfinToCard(libraryItem, libraryItem.Name || 'Library');
@@ -790,6 +821,88 @@ export async function getCalendar(config: AppConfig, start: Date, end: Date): Pr
}
}
function normalizeLibraryId(id: string | undefined): string {
return String(id || '').replace(/-/g, '').toLowerCase();
}
function getFolderNames(locations: string[] | undefined): string[] {
return (locations ?? [])
.map((location) => location.replace(/\\/g, '/').split('/').filter(Boolean).pop()?.toLowerCase() ?? '')
.filter(Boolean);
}
// Sonarr and Radarr rarely see a folder under the same path as Jellyfin (they
// mount it differently), so a release is matched to a library by the folder
// name: a series stored in /shared/Library/Shows/X belongs to the library whose
// folder is called "Shows".
export function isInFolders(path: string | undefined, folderNames: string[] | null): boolean {
if (!path || !folderNames?.length) {
return false;
}
// The last segment is the title's own folder, not a library.
const parents = path.replace(/\\/g, '/').split('/').filter(Boolean).slice(0, -1).map((segment) => segment.toLowerCase());
return parents.some((segment) => folderNames.includes(segment));
}
// The folder names of the libraries the signed-in profile cannot open, read
// from Jellyfin (its libraries, and the ones in the profile's views). Admin
// sessions have no profile and see everything.
async function getHiddenLibraryFolders(config: AppConfig): Promise<string[] | null> {
if (!config.jellyfin.userId || !config.jellyfin.baseUrl || !config.jellyfin.apiKey) {
return null;
}
try {
const [folders, views] = await Promise.all([
jellyfinFetch<Array<{ ItemId?: string; Locations?: string[] }>>(config, '/Library/VirtualFolders'),
jellyfinFetch<JellyfinItem[]>(config, `/UserViews?userId=${encodeURIComponent(config.jellyfin.userId)}`)
]);
const visibleLibraryIds = new Set(views.map((view) => normalizeLibraryId(view.Id)));
const visibleNames = new Set(folders.filter((folder) => visibleLibraryIds.has(normalizeLibraryId(folder.ItemId))).flatMap((folder) => getFolderNames(folder.Locations)));
// A name shared with a library the profile can open stays visible.
const hidden = folders
.filter((folder) => folder.ItemId && !visibleLibraryIds.has(normalizeLibraryId(folder.ItemId)))
.flatMap((folder) => getFolderNames(folder.Locations))
.filter((name) => !visibleNames.has(name));
return hidden.length ? [...new Set(hidden)] : null;
} catch (error) {
// Better to show the calendar than to break it when Jellyfin cannot be asked.
console.warn('Could not read the profile libraries; the calendar is not filtered.', error);
return null;
}
}
// What Jellyfin lets each profile open, for the administrator to review; the
// permissions themselves are managed in Jellyfin.
export async function getProfileLibraryAccess(config: AppConfig): Promise<ProfileLibraryAccess[]> {
if (!config.jellyfin.baseUrl || !config.jellyfin.apiKey) {
return [];
}
const [users, folders] = await Promise.all([
jellyfinFetch<Array<{ Id?: string; Name?: string; Policy?: { EnableAllFolders?: boolean; EnabledFolders?: string[] } }>>(config, '/Users'),
jellyfinFetch<Array<{ Name?: string; ItemId?: string }>>(config, '/Library/VirtualFolders')
]);
const libraries = folders.filter((folder) => folder.ItemId && folder.Name);
return users
.filter((user) => user.Id)
.map((user) => {
const allLibraries = user.Policy?.EnableAllFolders !== false;
const enabled = new Set((user.Policy?.EnabledFolders ?? []).map(normalizeLibraryId));
return {
userId: String(user.Id),
label: user.Name || 'User',
allLibraries,
libraries: libraries.map((folder) => ({
id: String(folder.ItemId),
name: String(folder.Name),
access: allLibraries || enabled.has(normalizeLibraryId(folder.ItemId))
}))
};
});
}
export async function searchTitles(
config: AppConfig,
rawQuery: string
@@ -2442,7 +2555,11 @@ async function buildSeasonEpisodes(
availability,
downloadStatus,
downloadProgress: isDownloading ? getEpisodeQueueProgress(queueEntry) : undefined,
canDownload: isManagedInSonarr && availability === 'missing',
// A series that is not in Sonarr yet is added by the request itself,
// unless Jellyfin already has the episode.
canDownload: Boolean(config.sonarr.baseUrl && config.sonarr.apiKey)
&& (isManagedInSonarr || (Boolean(tmdbId) && !jellyfinKnowsAboutIt))
&& availability === 'missing',
canDelete: hasFile,
watched: jellyfinEpisode?.watched,
progress: jellyfinEpisode?.progress,
@@ -2973,6 +3090,67 @@ export async function requestEpisode(config: AppConfig, payload: EpisodeRequestP
});
}
export async function requestSeriesEpisode(config: AppConfig, payload: SeriesEpisodeRequestPayload, user: string | null): Promise<void> {
if (!config.sonarr.baseUrl || !config.sonarr.apiKey) {
throw new Error('Sonarr is not configured.');
}
const headers = { 'X-Api-Key': config.sonarr.apiKey };
const details = await tmdbFetch(
config,
`/tv/${payload.tmdbId}?append_to_response=external_ids&language=${encodeURIComponent(config.preferences.language)}`
);
if (!details) {
throw new Error('Failed to load the series from TMDb.');
}
const tvdbId = Number(asRecord(details?.external_ids).tvdb_id || 0);
if (!tvdbId) {
throw new Error('This series does not have a TVDB ID for Sonarr.');
}
// Nothing is monitored on add, so Sonarr searches for nothing but the
// episode that is monitored and searched below.
const sonarrRequestConfig = await resolveSonarrRequestConfig(config);
const lookup = await fetchJson<SonarrSeriesRecord[]>(
`${config.sonarr.baseUrl}/api/v3/series/lookup?term=${encodeURIComponent(`tvdb:${tvdbId}`)}`,
{ headers }
);
const series = await fetchJson<SonarrSeriesRecord>(`${config.sonarr.baseUrl}/api/v3/series`, {
method: 'POST',
headers: { ...headers, 'Content-Type': 'application/json' },
body: JSON.stringify({
title: details.name || details.original_name || 'Series',
tvdbId,
qualityProfileId: payload.qualityProfileId || sonarrRequestConfig.qualityProfileId,
languageProfileId: sonarrRequestConfig.languageProfileId,
rootFolderPath: sonarrRequestConfig.rootFolderPath,
seasonFolder: true,
monitored: true,
seasons: (lookup[0]?.seasons || []).map((season) => ({ seasonNumber: season.seasonNumber, monitored: false })),
addOptions: { monitor: 'none', searchForMissingEpisodes: false, searchForCutoffUnmetEpisodes: false }
})
});
if (!series.id) {
throw new Error('Sonarr did not return the added series.');
}
// Sonarr lists the episodes only after its first scan of the new series.
for (let attempt = 0; attempt < 20; attempt += 1) {
const episodes = await fetchJson<Array<{ id?: number; seasonNumber?: number; episodeNumber?: number }>>(
`${config.sonarr.baseUrl}/api/v3/episode?seriesId=${series.id}`,
{ headers }
);
const episode = episodes.find((entry) => entry.seasonNumber === payload.seasonNumber && entry.episodeNumber === payload.episodeNumber);
if (episode?.id) {
await requestEpisode(config, { episodeId: episode.id, qualityProfileId: payload.qualityProfileId }, user);
return;
}
await new Promise((resolve) => setTimeout(resolve, 2000));
}
throw new Error('Sonarr added the series but has not listed its episodes yet. Try the episode again in a moment.');
}
export async function deleteSeasonFiles(config: AppConfig, payload: SeasonDeletePayload): Promise<void> {
if (!config.sonarr.baseUrl || !config.sonarr.apiKey) {
throw new Error('Sonarr is not configured.');
@@ -4048,6 +4226,13 @@ async function fetchJson<T>(url: string, init?: RequestInit): Promise<T> {
}
}
// Proxies answer with a whole HTML page; it says nothing the status does not.
if (/^\s*<(!doctype|html)/i.test(detail)) detail = '';
if ([502, 503, 504].includes(response.status)) {
throw new Error(`${response.status} ${response.statusText}: the service did not answer. Check that it is running and that the URL points to it.`);
}
throw new Error(detail
? `${response.status} ${response.statusText}: ${detail}`
: `${response.status} ${response.statusText}`);
@@ -4080,7 +4265,10 @@ function jellyfinToCard(
const backdropItemId = item.ParentBackdropItemId || item.Id;
const backdropTag = item.ParentBackdropImageTags?.[0] || item.BackdropImageTags?.[0] || posterTag;
const progress = Math.round(item.UserData?.PlayedPercentage || 0);
const tmdbId = Number(item.ProviderIds?.Tmdb) || (item.SeriesId ? tmdbIdByItemId?.get(item.SeriesId) : undefined);
// An episode's own TMDb id is not its series' id, and artwork is looked up per series.
const tmdbId = item.Type === 'Episode'
? (item.SeriesId ? tmdbIdByItemId?.get(item.SeriesId) : undefined)
: Number(item.ProviderIds?.Tmdb) || (item.SeriesId ? tmdbIdByItemId?.get(item.SeriesId) : undefined);
const episodeCode = formatEpisodeCode(item.ParentIndexNumber, item.IndexNumber);
return {
+82 -21
View File
@@ -1,5 +1,7 @@
import { mkdir, readFile, writeFile } from 'node:fs/promises';
import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
import { dirname, resolve } from 'node:path';
import type { WishlistEntry } from '../../shared/contracts.js';
interface StoredAdmin {
passwordHash: string;
passwordSalt: string;
@@ -17,37 +19,75 @@ interface StoredState {
admin: StoredAdmin | null;
config: EncryptedConfig | null;
configKey: string | null;
/** Each profile's wishlist, keyed by its Jellyfin user id ('admin' for the administrator). */
wishlists: Record<string, WishlistEntry[]>;
}
const DATA_DIR = resolve(process.env.OMNIARR_DATA_DIR || resolve(process.cwd(), 'data'));
const STORE_FILE = resolve(DATA_DIR, 'omniarr.secure.json');
// The store used to be called aliceflix.secure.json; it is still read when the
// new file does not exist yet, so a rename never looks like a fresh install.
const LEGACY_STORE_FILE = resolve(DATA_DIR, 'aliceflix.secure.json');
const EMPTY_STATE: StoredState = {
version: 1,
admin: null,
config: null,
configKey: null
configKey: null,
wishlists: {}
};
export async function loadState(): Promise<StoredState> {
try {
const raw = await readFile(STORE_FILE, 'utf8');
const parsed = JSON.parse(raw) as Partial<StoredState>;
// Every write reads the file, changes it and writes it back, so writes are
// queued one after another; two profiles saving at once would otherwise drop
// one of the changes.
let writeQueue: Promise<unknown> = Promise.resolve();
return {
version: parsed.configKey ? 2 : 1,
admin: parsed.admin ?? null,
config: parsed.config ?? null,
configKey: typeof parsed.configKey === 'string' ? parsed.configKey : null
};
} catch {
return EMPTY_STATE;
async function readStoreFile(): Promise<string | null> {
for (const file of [STORE_FILE, LEGACY_STORE_FILE]) {
try {
return await readFile(file, 'utf8');
} catch (error) {
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;
}
}
return null;
}
// Only a store that does not exist counts as a fresh install. Any other read or
// parse failure is thrown: treating it as empty would reopen the master
// password setup and let the next visitor overwrite the real one.
export async function loadState(): Promise<StoredState> {
const raw = await readStoreFile();
if (raw === null) return EMPTY_STATE;
const parsed = JSON.parse(raw) as Partial<StoredState>;
return {
version: parsed.configKey ? 2 : 1,
admin: parsed.admin ?? null,
config: parsed.config ?? null,
configKey: typeof parsed.configKey === 'string' ? parsed.configKey : null,
wishlists: parsed.wishlists && typeof parsed.wishlists === 'object' ? parsed.wishlists : {}
};
}
export async function saveState(state: StoredState): Promise<void> {
await mkdir(dirname(STORE_FILE), { recursive: true });
await writeFile(STORE_FILE, JSON.stringify(state, null, 2), 'utf8');
// Written to a temporary file first, so a crash mid-write never leaves a
// half-written store behind.
const temporaryFile = `${STORE_FILE}.tmp`;
await writeFile(temporaryFile, JSON.stringify(state, null, 2), 'utf8');
await rename(temporaryFile, STORE_FILE);
}
export function updateState(change: (state: StoredState) => StoredState): Promise<StoredState> {
const next = writeQueue.then(async () => {
const updated = change(await loadState());
await saveState(updated);
return updated;
});
writeQueue = next.catch(() => undefined);
return next;
}
export async function readEncryptedConfig(): Promise<EncryptedConfig | null> {
@@ -60,20 +100,20 @@ export async function saveAdminAndConfig(
config: EncryptedConfig,
configKey: string
): Promise<void> {
await saveState({
await updateState((state) => ({
...state,
version: 2,
admin,
config,
configKey
});
}));
}
export async function updateEncryptedConfig(config: EncryptedConfig): Promise<void> {
const state = await loadState();
await saveState({
await updateState((state) => ({
...state,
config
});
}));
}
export async function readAdmin(): Promise<StoredAdmin | null> {
@@ -82,8 +122,29 @@ export async function readAdmin(): Promise<StoredAdmin | null> {
}
export async function migrateConfig(config: EncryptedConfig, configKey: string): Promise<void> {
await updateState((state) => ({ ...state, version: 2, config, configKey }));
}
export async function readWishlist(owner: string): Promise<WishlistEntry[]> {
const state = await loadState();
await saveState({ ...state, version: 2, config, configKey });
return state.wishlists[owner] ?? [];
}
export async function updateWishlist(owner: string, change: (entries: WishlistEntry[]) => WishlistEntry[]): Promise<WishlistEntry[]> {
const state = await updateState((current) => ({
...current,
wishlists: { ...current.wishlists, [owner]: change(current.wishlists[owner] ?? []) }
}));
return state.wishlists[owner];
}
export async function readAllWishlists(): Promise<Record<string, WishlistEntry[]>> {
const state = await loadState();
return state.wishlists;
}
export async function restoreBackup(config: EncryptedConfig, wishlists: Record<string, WishlistEntry[]>): Promise<void> {
await updateState((state) => ({ ...state, config, wishlists }));
}
export type { EncryptedConfig, StoredAdmin, StoredState };
+138
View File
@@ -0,0 +1,138 @@
import assert from 'node:assert/strict';
import { spawn, type ChildProcess } from 'node:child_process';
import { randomUUID } from 'node:crypto';
import { mkdtemp, rm } from 'node:fs/promises';
import { createServer } from 'node:net';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { after, before, describe, it } from 'node:test';
import { defaultConfig, type CalendarResponse } from '../../shared/contracts.js';
import { startMockServices } from './mock-services.js';
// The real server, started on its own port and data folder, talking to the
// mock Jellyfin, Sonarr and Radarr. It signs in through the app's own login
// endpoints, so what a profile receives is what the browser would receive.
let mocks: Awaited<ReturnType<typeof startMockServices>>;
let server: ChildProcess;
let dataDir = '';
let baseUrl = '';
let adminCookie = '';
async function freePort(): Promise<number> {
return new Promise((resolve) => {
const probe = createServer().listen(0, '127.0.0.1', () => {
const { port } = probe.address() as { port: number };
probe.close(() => resolve(port));
});
});
}
async function call(path: string, options: { method?: string; cookie?: string; body?: unknown } = {}) {
const response = await fetch(`${baseUrl}${path}`, {
method: options.method ?? 'GET',
headers: {
'Content-Type': 'application/json',
...(options.cookie ? { Cookie: options.cookie } : {})
},
body: options.body === undefined ? undefined : JSON.stringify(options.body)
});
const cookie = response.headers.get('set-cookie')?.split(';')[0] ?? '';
const text = await response.text();
return { status: response.status, cookie, json: text ? JSON.parse(text) : null };
}
async function signInAs(userId: string): Promise<string> {
const result = await call('/api/auth/profile-login', { method: 'POST', body: { userId, password: 'any-password' } });
assert.equal(result.status, 200);
return result.cookie;
}
async function calendarTitles(cookie: string): Promise<string[]> {
const result = await call('/api/calendar?start=2026-11-01&end=2026-11-30', { cookie });
assert.equal(result.status, 200);
return (result.json as CalendarResponse).items.map((item) => item.title).sort();
}
before(async () => {
mocks = await startMockServices();
dataDir = await mkdtemp(join(tmpdir(), 'omniarr-e2e-'));
const port = await freePort();
baseUrl = `http://127.0.0.1:${port}`;
server = spawn(process.execPath, ['dist-server/server/index.js'], {
env: { ...process.env, PORT: String(port), OMNIARR_DATA_DIR: dataDir },
stdio: 'ignore'
});
for (let attempt = 0; attempt < 50; attempt += 1) {
const ready = await fetch(`${baseUrl}/api/health`).then((response) => response.ok).catch(() => false);
if (ready) {
break;
}
await new Promise((resolve) => setTimeout(resolve, 100));
}
// A throwaway master password for this throwaway data folder.
const registered = await call('/api/auth/register', { method: 'POST', body: { password: randomUUID() } });
assert.equal(registered.status, 200);
adminCookie = registered.cookie;
const saved = await call('/api/settings', {
method: 'PUT',
cookie: adminCookie,
body: {
...defaultConfig,
preferences: { ...defaultConfig.preferences, hiddenSections: { limited: ['downloads', 'anime'] } },
jellyfin: { baseUrl: mocks.jellyfinUrl, apiKey: 'key', userId: '' },
sonarr: { ...defaultConfig.sonarr, baseUrl: mocks.sonarrUrl, apiKey: 'key' },
radarr: { ...defaultConfig.radarr, baseUrl: mocks.radarrUrl, apiKey: 'key' }
}
});
assert.equal(saved.status, 200);
});
after(async () => {
server?.kill();
await mocks?.close();
if (dataDir) {
await rm(dataDir, { recursive: true, force: true });
}
});
describe('upcoming calendar through the API', () => {
it('gives the administrator every release', async () => {
assert.deepEqual(await calendarTitles(adminCookie), ['Anime', 'Better Call Saul', 'Dune', 'Frieren', 'Your Name']);
});
it('gives a profile with every library every release', async () => {
assert.deepEqual(await calendarTitles(await signInAs('full')), ['Anime', 'Better Call Saul', 'Dune', 'Frieren', 'Your Name']);
});
it('keeps releases of libraries a profile cannot open out of its calendar', async () => {
assert.deepEqual(await calendarTitles(await signInAs('limited')), ['Anime', 'Better Call Saul', 'Dune']);
});
});
describe('sections hidden for a profile', () => {
it('closes the hidden sections for that profile only', async () => {
const limited = await signInAs('limited');
const full = await signInAs('full');
assert.equal((await call('/api/downloads', { cookie: limited })).status, 403);
assert.equal((await call('/api/hubs/anime', { cookie: limited })).status, 403);
assert.notEqual((await call('/api/downloads', { cookie: full })).status, 403);
assert.notEqual((await call('/api/downloads', { cookie: adminCookie })).status, 403);
});
it('lets only the administrator read the library access and change settings', async () => {
const limited = await signInAs('limited');
assert.equal((await call('/api/admin/profile-access', { cookie: limited })).status, 403);
assert.equal((await call('/api/settings', { method: 'PUT', cookie: limited, body: defaultConfig })).status, 403);
const access = await call('/api/admin/profile-access', { cookie: adminCookie });
assert.equal(access.status, 200);
assert.deepEqual(
(access.json as { profiles: Array<{ userId: string; libraries: Array<{ name: string; access: boolean }> }> })
.profiles.find((profile) => profile.userId === 'limited')?.libraries.filter((library) => library.access).map((library) => library.name),
['Shows', 'Movies']
);
});
});
@@ -0,0 +1,79 @@
import assert from 'node:assert/strict';
import { after, before, describe, it } from 'node:test';
import { defaultConfig, type AppConfig } from '../../shared/contracts.js';
import { getCalendar, getProfileLibraryAccess, isInFolders } from '../lib/services.js';
import { startMockServices } from './mock-services.js';
let mocks: Awaited<ReturnType<typeof startMockServices>>;
function configFor(userId: string): AppConfig {
return {
...defaultConfig,
jellyfin: { baseUrl: mocks.jellyfinUrl, apiKey: 'key', userId },
sonarr: { ...defaultConfig.sonarr, baseUrl: mocks.sonarrUrl, apiKey: 'key' },
radarr: { ...defaultConfig.radarr, baseUrl: mocks.radarrUrl, apiKey: 'key' }
};
}
async function calendarTitles(config: AppConfig): Promise<string[]> {
const calendar = await getCalendar(config, new Date('2026-11-01'), new Date('2026-11-30'));
return calendar.items.map((item) => item.title).sort();
}
before(async () => {
mocks = await startMockServices();
});
after(async () => {
await mocks.close();
});
describe('upcoming calendar per profile', () => {
it('shows everything to the administrator, who has no Jellyfin profile', async () => {
assert.deepEqual(await calendarTitles(configFor('')), ['Anime', 'Better Call Saul', 'Dune', 'Frieren', 'Your Name']);
});
it('shows everything to a profile that opens every library', async () => {
assert.deepEqual(await calendarTitles(configFor('full')), ['Anime', 'Better Call Saul', 'Dune', 'Frieren', 'Your Name']);
});
it('leaves out releases stored in libraries the profile cannot open', async () => {
assert.deepEqual(await calendarTitles(configFor('limited')), ['Anime', 'Better Call Saul', 'Dune']);
});
it('does not calendar-filter when Jellyfin cannot be asked', async () => {
const config = configFor('limited');
config.jellyfin.baseUrl = 'http://127.0.0.1:9';
assert.deepEqual(await calendarTitles(config), ['Anime', 'Better Call Saul', 'Dune', 'Frieren', 'Your Name']);
});
});
describe('library folder matching', () => {
it('matches a title by the library folder it is stored in', () => {
assert.equal(isInFolders('/shared/Library/Anime/Frieren', ['anime']), true);
assert.equal(isInFolders('/shared/library/ANIME/Frieren', ['anime']), true);
assert.equal(isInFolders('/shared/Library/Shows/Frieren', ['anime']), false);
});
it('ignores the title\'s own folder and handles missing data', () => {
assert.equal(isInFolders('/shared/Library/Shows/Anime', ['anime']), false);
assert.equal(isInFolders(undefined, ['anime']), false);
assert.equal(isInFolders('/shared/Library/Anime/Frieren', null), false);
assert.equal(isInFolders('C:\\Media\\Anime\\Frieren', ['anime']), true);
});
});
describe('profile library access', () => {
it('reports which libraries each Jellyfin profile can open', async () => {
const profiles = await getProfileLibraryAccess(configFor(''));
const full = profiles.find((profile) => profile.userId === 'full');
const limited = profiles.find((profile) => profile.userId === 'limited');
assert.equal(full?.allLibraries, true);
assert.ok(full?.libraries.every((library) => library.access));
assert.equal(limited?.allLibraries, false);
assert.deepEqual(
limited?.libraries.filter((library) => library.access).map((library) => library.name),
['Shows', 'Movies']
);
});
});
+95
View File
@@ -0,0 +1,95 @@
import { createServer, type Server } from 'node:http';
import type { AddressInfo } from 'node:net';
// Stand-ins for Jellyfin, Sonarr and Radarr with two profiles: "full" opens
// every library and "limited" cannot open Anime or Anime Movies. Sonarr and
// Radarr see the media under /shared/Library while Jellyfin sees /library, the
// way the Docker mounts differ in a real setup.
export const MOCK_LIBRARIES = [
{ Name: 'Shows', ItemId: 'aaaaaaaa-0000-0000-0000-000000000001', Locations: ['/library/Shows'] },
{ Name: 'Movies', ItemId: 'aaaaaaaa-0000-0000-0000-000000000002', Locations: ['/library/Movies'] },
{ Name: 'Anime', ItemId: 'aaaaaaaa-0000-0000-0000-000000000003', Locations: ['/library/Anime'] },
{ Name: 'Anime Movies', ItemId: 'aaaaaaaa-0000-0000-0000-000000000004', Locations: ['/library/AnimeMovies'] }
];
export const MOCK_USERS = [
{ Id: 'full', Name: 'Full', Policy: { EnableAllFolders: true, EnabledFolders: [] } },
{
Id: 'limited',
Name: 'Limited',
Policy: { EnableAllFolders: false, EnabledFolders: [MOCK_LIBRARIES[0].ItemId, MOCK_LIBRARIES[1].ItemId] }
}
];
const AIR_DATE = '2026-11-20T20:00:00Z';
const SONARR_CALENDAR = [
{ id: 1, title: 'Pilot', airDateUtc: AIR_DATE, seasonNumber: 1, episodeNumber: 1, series: { title: 'Better Call Saul', tmdbId: 60059, path: '/shared/Library/Shows/Better Call Saul' } },
{ id: 2, title: 'Chapter 1', airDateUtc: AIR_DATE, seasonNumber: 1, episodeNumber: 1, series: { title: 'Frieren', tmdbId: 209867, path: '/shared/Library/Anime/Frieren' } },
// A series folder that happens to be called like a library is still a Shows title.
{ id: 3, title: 'Episode 1', airDateUtc: AIR_DATE, seasonNumber: 1, episodeNumber: 1, series: { title: 'Anime', tmdbId: 1, path: '/shared/Library/Shows/Anime' } }
];
const RADARR_CALENDAR = [
{ id: 10, title: 'Dune', tmdbId: 438631, digitalRelease: AIR_DATE, path: '/shared/Library/Movies/Dune' },
{ id: 11, title: 'Your Name', tmdbId: 372058, digitalRelease: AIR_DATE, path: '/shared/Library/AnimeMovies/Your Name' }
];
function listen(server: Server): Promise<string> {
return new Promise((resolve) => {
server.listen(0, '127.0.0.1', () => resolve(`http://127.0.0.1:${(server.address() as AddressInfo).port}`));
});
}
function jsonServer(handler: (path: string, query: URLSearchParams, body: string) => unknown): Server {
return createServer((request, response) => {
const url = new URL(request.url || '/', 'http://localhost');
const chunks: Buffer[] = [];
request.on('data', (chunk: Buffer) => chunks.push(chunk));
request.on('end', () => {
response.writeHead(200, { 'Content-Type': 'application/json' });
response.end(JSON.stringify(handler(url.pathname, url.searchParams, Buffer.concat(chunks).toString('utf8'))));
});
});
}
export async function startMockServices() {
const jellyfin = jsonServer((path, query, body) => {
// Any password signs a profile in, so the app's own login can be exercised.
if (path === '/Users/AuthenticateByName') {
const username = (JSON.parse(body || '{}') as { Username?: string }).Username;
return { User: { Id: MOCK_USERS.find((user) => user.Name === username)?.Id } };
}
if (path === '/Library/VirtualFolders') {
return MOCK_LIBRARIES;
}
if (path === '/Users') {
return MOCK_USERS;
}
if (path === '/UserViews') {
const user = MOCK_USERS.find((candidate) => candidate.Id === query.get('userId'));
const visible = MOCK_LIBRARIES.filter((library) => user?.Policy.EnableAllFolders || user?.Policy.EnabledFolders.includes(library.ItemId));
return { Items: visible.map((library) => ({ Id: library.ItemId.replace(/-/g, ''), Name: library.Name })) };
}
return { Items: [] };
});
const sonarr = jsonServer(() => SONARR_CALENDAR);
const radarr = jsonServer(() => RADARR_CALENDAR);
const [jellyfinUrl, sonarrUrl, radarrUrl] = await Promise.all([listen(jellyfin), listen(sonarr), listen(radarr)]);
return {
jellyfinUrl,
sonarrUrl,
radarrUrl,
close: () => Promise.all([jellyfin, sonarr, radarr].map((server) => new Promise((resolve) => server.close(resolve))))
};
}
// `node dist-server/server/test/mock-services.js` keeps the mocks running so the
// app can be pointed at them (Jellyfin API key and Sonarr/Radarr keys: anything).
const isMain = process.argv[1] !== undefined && import.meta.url.endsWith(process.argv[1].split('/').slice(-3).join('/'));
if (isMain) {
const mocks = await startMockServices();
console.log(`Jellyfin ${mocks.jellyfinUrl}\nSonarr ${mocks.sonarrUrl}\nRadarr ${mocks.radarrUrl}`);
console.log('Profiles: "full" opens every library, "limited" cannot open Anime or Anime Movies.');
}
+63 -1
View File
@@ -12,8 +12,27 @@ export type AppRoute =
| 'library'
| 'calendar'
| 'downloads'
| 'wishlist'
| 'settings';
// Sections of the app the administrator can switch off for a profile.
export const HIDEABLE_SECTIONS = [
{ id: 'search', label: 'Search' },
{ id: 'calendar', label: 'Upcoming' },
{ id: 'downloads', label: 'Downloads' },
{ id: 'wishlist', label: 'Wishlist' },
{ id: 'dorama', label: 'K-Drama' },
{ id: 'anime', label: 'Anime' },
{ id: 'library', label: 'Library' },
{ id: 'netflix', label: 'Netflix' },
{ id: 'primevideo', label: 'Prime Video' },
{ id: 'hbo', label: 'HBO' },
{ id: 'viki', label: 'Viki' },
{ id: 'disney', label: 'Disney+' }
] as const;
export type HideableSection = (typeof HIDEABLE_SECTIONS)[number]['id'];
export interface ServiceConfig {
baseUrl: string;
}
@@ -55,6 +74,16 @@ export interface AppPreferences {
animationLevel: 'smooth' | 'reduced';
sonarrDownloadQualityProfileIds: string[];
radarrDownloadQualityProfileIds: string[];
/** Sections switched off for each Jellyfin profile, by user id; a profile that is not listed sees everything. */
hiddenSections: Record<string, HideableSection[]>;
}
export interface ProfileLibraryAccess {
userId: string;
label: string;
/** Jellyfin lets this profile open every library, including ones added later. */
allLibraries: boolean;
libraries: Array<{ id: string; name: string; access: boolean }>;
}
export interface AppConfig {
@@ -303,6 +332,15 @@ export interface EpisodeRequestPayload {
qualityProfileId?: number;
}
// An episode of a series that is not in Sonarr yet: it is added with nothing
// monitored but this episode.
export interface SeriesEpisodeRequestPayload {
tmdbId: number;
seasonNumber: number;
episodeNumber: number;
qualityProfileId?: number;
}
export interface SeasonDeletePayload {
seriesId: number;
seasonNumber: number;
@@ -347,6 +385,29 @@ export interface AuthResponse {
message?: string;
}
export interface WishlistEntry {
card: MediaCard;
addedAt: string;
}
export interface WishlistResponse {
items: WishlistEntry[];
}
export interface WishlistTogglePayload {
card: MediaCard;
wishlisted: boolean;
}
/** What the administration exports: the service settings and every profile's wishlist. */
export interface BackupFile {
app: 'omniarr';
format: 1;
exportedAt: string;
config: AppConfig;
wishlists: Record<string, WishlistEntry[]>;
}
export interface ApiErrorPayload {
error: string;
}
@@ -358,7 +419,8 @@ export const defaultConfig: AppConfig = {
excludeLibraryItems: true,
animationLevel: 'smooth',
sonarrDownloadQualityProfileIds: [],
radarrDownloadQualityProfileIds: []
radarrDownloadQualityProfileIds: [],
hiddenSections: {}
},
jellyfin: {
baseUrl: '',
+601 -41
View File
@@ -3,13 +3,16 @@ import {
type FormEvent,
type MouseEvent,
type ReactNode,
createContext,
startTransition,
useCallback,
useContext,
useEffect,
useLayoutEffect,
useRef,
useState,
} from 'react'
import { createPortal } from 'react-dom'
import { api } from './api'
import {
type CalendarEntry,
@@ -20,16 +23,20 @@ import {
type CompletedDownloadItem,
type DownloadItem,
type DiskSpaceStatus,
type HideableSection,
type HubPageResponse,
type MediaCard,
type ProcessingItem,
type ProfileLibraryAccess,
type SearchResponse,
type SelectOption,
type ServiceOptionsResponse,
type TitleDetailsCastMember,
type TitleDetailsEpisode,
type TitleDetailsResponse,
type WishlistEntry,
} from '../shared/contracts'
import { HIDEABLE_SECTIONS } from '../shared/contracts'
type AuthState = 'loading' | 'setup' | 'login' | 'profiles' | 'admin' | 'app'
type EntryStage = 'onboarding' | 'profiles' | 'dashboard'
@@ -42,16 +49,32 @@ const EPISODE_SCROLL_DISTANCE_RATIO = 0.72
const SEASON_DOMINANCE_SWITCH_RATIO = 0.12
const SEASON_DOMINANCE_SWITCH_MIN_PX = 56
type SidebarItem = { route: AppRoute; label: string; short: string; icon?: 'calendar' | 'search' | 'downloads' | 'home' | 'library'; iconClassName?: string }
type SidebarItem = { route: AppRoute; label: string; short: string; icon?: 'calendar' | 'search' | 'downloads' | 'home' | 'library' | 'wishlist'; iconClassName?: string }
const topSidebarItems: SidebarItem[] = [
{ route: 'search', label: 'Search', short: 'S', icon: 'search', iconClassName: 'sidebar-search-icon' },
{ route: 'calendar', label: 'Upcoming', short: 'C', icon: 'calendar' },
{ route: 'downloads', label: 'Downloads', short: 'D', icon: 'downloads' },
{ route: 'wishlist', label: 'Wishlist', short: 'W', icon: 'wishlist' },
]
// Only English is translated today; more can be added here and show up in Settings.
const LANGUAGE_OPTIONS: SelectOption[] = [{ id: 'en-US', label: 'English (en-US)' }]
const REGION_CODES = [
'US', 'GB', 'CA', 'AU', 'NZ', 'IE', 'ES', 'MX', 'AR', 'CL', 'CO', 'PE', 'FR', 'DE', 'IT', 'PT', 'BR',
'NL', 'BE', 'SE', 'NO', 'DK', 'FI', 'PL', 'JP', 'KR', 'CN', 'TW', 'IN',
]
const regionNames = new Intl.DisplayNames(['en'], { type: 'region' })
const REGION_OPTIONS: SelectOption[] = REGION_CODES.map((code) => ({ id: code, label: `${regionNames.of(code) ?? code} (${code})` }))
// A value saved earlier that is not in the list stays selectable instead of being lost.
function withCurrentOption(options: SelectOption[], current: string): SelectOption[] {
return current && !options.some((option) => option.id === current) ? [{ id: current, label: current }, ...options] : options
}
const sidebarItems: SidebarItem[] = [
{ route: 'home', label: 'Inicio', short: 'H', icon: 'home' },
{ route: 'home', label: 'Home', short: 'H', icon: 'home' },
{ route: 'dorama', label: 'K-Drama', short: '아' },
{ route: 'anime', label: 'Anime', short: 'あ' },
{ route: 'library', label: 'Library', short: 'L', icon: 'library' },
@@ -65,6 +88,27 @@ const networkSidebarItems: Array<{ route: AppRoute; label: string; icon: string;
{ route: 'disney', label: 'Disney+', icon: '/networks/disney.webp' },
]
// Routes that render their own page instead of a hub fetched from the server.
const NON_HUB_ROUTES = new Set<AppRoute>(['downloads', 'settings', 'search', 'calendar', 'wishlist'])
function isHubRoute(route: AppRoute) {
return !NON_HUB_ROUTES.has(route)
}
// Lets every tile and the title modal show and change whether a title is on
// the current profile's wishlist without passing it through each component.
const WishlistContext = createContext<{ isWishlisted: (card: MediaCard) => boolean; toggle: (card: MediaCard) => void } | null>(null)
// The same title can come from Jellyfin or TMDb, so it is matched by its TMDb
// id when it has one; the server matches titles the same way.
function getWishlistKey(card: MediaCard) {
return card.tmdbId ? `${card.mediaType === 'movie' ? 'movie' : 'tv'}:${card.tmdbId}` : card.id
}
function canWishlist(card: MediaCard) {
return card.mediaType === 'movie' || card.mediaType === 'tv' || card.mediaType === 'series'
}
function App() {
const [authState, setAuthState] = useState<AuthState>('loading')
const [sessionRole, setSessionRole] = useState<'admin' | 'user' | null>(null)
@@ -76,6 +120,10 @@ function App() {
const [notice, setNotice] = useState('')
const [password, setPassword] = useState('')
const [config, setConfig] = useState<AppConfig>(defaultConfig)
// What the server has, to tell when the settings on screen have unsaved changes.
const savedConfigJson = useRef(JSON.stringify(defaultConfig))
const configRef = useRef(config)
configRef.current = config
const [options, setOptions] = useState<ServiceOptionsResponse>({
jellyfinUsers: [],
sonarrRootFolders: [],
@@ -98,7 +146,12 @@ function App() {
const [lastSearchQuery, setLastSearchQuery] = useState('')
const [selectedCard, setSelectedCard] = useState<SelectedCardState | null>(null)
const [downloadDeleteId, setDownloadDeleteId] = useState('')
const [wishlist, setWishlist] = useState<WishlistEntry[]>([])
const [entryTransitionState, setEntryTransitionState] = useState<EntryTransitionState>('idle')
// The administrator can switch sections off for each profile; admin sessions see them all.
const hiddenSections: string[] = sessionRole === 'user' ? (config.preferences.hiddenSections[config.jellyfin.userId] ?? []) : []
const isSectionHidden = (sectionRoute: AppRoute) => hiddenSections.includes(sectionRoute)
const routeHidden = isSectionHidden(route)
async function transitionEntryStage(nextStage: EntryStage) {
if (nextStage === entryStage) {
@@ -122,15 +175,25 @@ function App() {
setEntryTransitionState('idle')
}
function applyServerConfig(next: AppConfig) {
savedConfigJson.current = JSON.stringify(next)
setConfig(next)
}
async function refreshBaseData() {
const [settings, serviceOptions, dashboard, storage] = await Promise.all([
const [settings, serviceOptions, dashboard, storage, savedWishlist] = await Promise.all([
api.getSettings(),
api.getOptions(),
api.getDashboard(),
api.getDiskSpace(),
api.getWishlist(),
])
setConfig(settings)
setWishlist(savedWishlist.items)
// Edits that are not saved yet are not replaced by the periodic refresh.
if (JSON.stringify(configRef.current) === savedConfigJson.current) {
applyServerConfig(settings)
}
setOptions(serviceOptions)
setDownloads(dashboard.downloads)
setProcessingItems(dashboard.processing || [])
@@ -209,7 +272,12 @@ function App() {
return
}
if (route === 'settings' || route === 'calendar' || route === 'search') {
if (routeHidden) {
setRoute('home')
return
}
if (route === 'settings' || route === 'calendar' || route === 'search' || route === 'wishlist') {
return
}
@@ -242,7 +310,7 @@ function App() {
return () => {
cancelled = true
}
}, [authState, entryStage, route])
}, [authState, entryStage, route, routeHidden])
@@ -253,7 +321,7 @@ function App() {
const interval = window.setInterval(() => {
void refreshBaseData()
if (route !== 'downloads' && route !== 'settings' && route !== 'search' && route !== 'calendar') {
if (isHubRoute(route)) {
void loadHub(route as HubPageResponse['page'], { silent: true })
}
}, 30000)
@@ -314,6 +382,13 @@ function App() {
apiKey: config.jellyfin.apiKey,
})
setOptions((current) => ({ ...current, jellyfinUsers: response.jellyfinUsers }))
// Loading the users only tests the typed values; save them so the
// connection stays configured after this screen.
if (sessionRole === 'admin') {
const saved = await api.saveSettings(config)
applyServerConfig(saved.config)
setConnections(saved.connections)
}
await transitionEntryStage(response.jellyfinUsers.length ? 'profiles' : 'onboarding')
setNotice(response.jellyfinUsers.length ? 'Jellyfin users loaded.' : 'No Jellyfin users found.')
} catch (loadError) {
@@ -352,7 +427,7 @@ function App() {
setNotice('')
try {
const response = await api.saveSettings(config)
setConfig(response.config)
applyServerConfig(response.config)
setConnections(response.connections)
await refreshBaseData()
setNotice('Settings saved and services refreshed.')
@@ -375,7 +450,7 @@ function App() {
} else {
await api.requestSeries(card.tmdbId, currentJellyfinUser, qualityProfileId, seasonNumber)
}
if (route !== 'downloads' && route !== 'settings' && route !== 'search' && route !== 'calendar') {
if (isHubRoute(route)) {
await loadHub(route as HubPageResponse['page'], { silent: true })
}
setNotice(`${card.title} sent to ${card.mediaType === 'movie' ? 'Radarr' : 'Sonarr'}.`)
@@ -441,6 +516,66 @@ function App() {
}
}
async function handleToggleWishlist(card: MediaCard) {
const key = getWishlistKey(card)
const wishlisted = !wishlist.some((entry) => getWishlistKey(entry.card) === key)
const previous = wishlist
// The heart fills straight away; the server's answer then replaces the list.
setWishlist(wishlisted
? [{ card, addedAt: new Date().toISOString() }, ...previous]
: previous.filter((entry) => getWishlistKey(entry.card) !== key))
try {
const response = await api.setWishlisted({ card, wishlisted })
setWishlist(response.items)
} catch (wishlistError) {
setWishlist(previous)
setError(wishlistError instanceof Error ? wishlistError.message : 'Failed to update the wishlist.')
}
}
async function handleImportBackup(file: File) {
setBusy(true)
setError('')
setNotice('')
try {
let backup: unknown
try {
backup = JSON.parse(await file.text())
} catch {
throw new Error('This file is not an OmniArr backup.')
}
const response = await api.importBackup(backup)
applyServerConfig(response.config)
setConnections(response.connections)
await refreshBaseData()
setNotice('Backup restored.')
} catch (importError) {
setError(importError instanceof Error ? importError.message : 'Failed to restore the backup.')
} finally {
setBusy(false)
}
}
async function handleExportBackup() {
setError('')
try {
const backup = await api.exportBackup()
const url = URL.createObjectURL(new Blob([JSON.stringify(backup, null, 2)], { type: 'application/json' }))
const link = document.createElement('a')
link.href = url
link.download = `omniarr-backup-${backup.exportedAt.slice(0, 10)}.json`
link.click()
URL.revokeObjectURL(url)
} catch (exportError) {
setError(exportError instanceof Error ? exportError.message : 'Failed to export the backup.')
}
}
const wishlistContext = {
isWishlisted: (card: MediaCard) => wishlist.some((entry) => getWishlistKey(entry.card) === getWishlistKey(card)),
toggle: (card: MediaCard) => void handleToggleWishlist(card),
}
function updateConfig<K extends keyof AppConfig>(key: K, value: AppConfig[K]) {
setConfig((current) => ({
...current,
@@ -513,9 +648,14 @@ function App() {
<AdministrationScreen
busy={busy}
config={config}
savedConfig={JSON.parse(savedConfigJson.current) as AppConfig}
connections={connections}
error={error}
notice={notice}
onExit={() => setAuthState('profiles')}
onCheck={saveSettings}
onExportBackup={handleExportBackup}
onImportBackup={handleImportBackup}
onSave={handleSaveSettings}
options={options}
updateConfig={updateConfig}
@@ -564,12 +704,14 @@ function App() {
const currentJellyfinUser = sessionRole === 'admin'
? 'Administration'
: options.jellyfinUsers.find((option) => option.id === config.jellyfin.userId)?.label || 'Media cockpit'
const currentHub = route !== 'downloads' && route !== 'settings' && route !== 'calendar' && route !== 'search' ? hubPages[route as HubPageResponse['page']] : undefined
const currentHub = isHubRoute(route) ? hubPages[route as HubPageResponse['page']] : undefined
return (
<WishlistContext.Provider value={isSectionHidden('wishlist') ? null : wishlistContext}>
<div className={`omniarr-app ${getEntryTransitionClassName(entryTransitionState)}`}>
<Sidebar
busy={busy}
isSectionHidden={isSectionHidden}
connections={connections}
currentUser={currentJellyfinUser}
diskSpace={diskSpace}
@@ -593,7 +735,7 @@ function App() {
title="Nothing to track yet"
/>
) : null}
{route === 'calendar' && isRouteAvailable(route, connections) ? <CalendarPage onOpenCard={(card, originRect) => setSelectedCard({ card, originRect: originRect ?? null })} /> : null}
{route === 'calendar' && !routeHidden && isRouteAvailable(route, connections) ? <CalendarPage onOpenCard={(card, originRect) => setSelectedCard({ card, originRect: originRect ?? null })} /> : null}
{route === 'downloads' && isRouteAvailable(route, connections) ? <DownloadsPage busyId={downloadDeleteId} completedDownloads={completedDownloads} downloads={downloads} onDelete={handleDeleteDownload} onDismissAllCompleted={handleDismissAllCompleted} onDismissCompleted={handleDismissCompleted} onOpenCard={(card, originRect) => setSelectedCard({ card, originRect: originRect ?? null })} processingItems={processingItems} /> : null}
{route === 'search' ? (
<SearchPage
@@ -610,14 +752,23 @@ function App() {
<SettingsView
busy={busy}
config={config}
savedConfig={JSON.parse(savedConfigJson.current) as AppConfig}
connections={connections}
onCheck={saveSettings}
onExportBackup={handleExportBackup}
onImportBackup={handleImportBackup}
onSave={handleSaveSettings}
options={options}
updateConfig={updateConfig}
/>
) : null}
{route !== 'downloads' && route !== 'settings' && route !== 'calendar' && route !== 'search' ? (
{route === 'wishlist' ? (
<WishlistPage
items={wishlist}
onOpenCard={(card, originRect) => setSelectedCard({ card, originRect: originRect ?? null })}
/>
) : null}
{isHubRoute(route) ? (
<HubPageView
busy={busy}
hub={currentHub}
@@ -647,6 +798,7 @@ function App() {
/>
) : null}
</div>
</WishlistContext.Provider>
)
}
@@ -666,6 +818,7 @@ function Sidebar(props: {
connections: ConnectionStatus[]
busy: boolean
canManage: boolean
isSectionHidden: (route: AppRoute) => boolean
onExitProfile: () => void
}) {
const [menuOpen, setMenuOpen] = useState(false)
@@ -726,7 +879,7 @@ function Sidebar(props: {
</button>
<div className="sidebar-links">
{topSidebarItems.filter((item) => isRouteAvailable(item.route, props.connections)).map((item) => (
{topSidebarItems.filter((item) => isRouteAvailable(item.route, props.connections) && !props.isSectionHidden(item.route)).map((item) => (
<button
className={item.route === props.route ? 'sidebar-link active' : 'sidebar-link'}
key={item.route}
@@ -734,7 +887,7 @@ function Sidebar(props: {
type="button"
>
<span className={item.iconClassName ? `sidebar-link-short ${item.iconClassName}` : 'sidebar-link-short'} aria-hidden="true">
{item.icon === 'calendar' ? <CalendarGlyph /> : item.icon === 'search' ? <SearchGlyph /> : item.icon === 'downloads' ? <DownloadGlyph /> : item.icon === 'home' ? <HomeGlyph /> : item.icon === 'library' ? <LibraryGlyph /> : item.short}
{item.icon === 'calendar' ? <CalendarGlyph /> : item.icon === 'search' ? <SearchGlyph /> : item.icon === 'downloads' ? <DownloadGlyph /> : item.icon === 'home' ? <HomeGlyph /> : item.icon === 'library' ? <LibraryGlyph /> : item.icon === 'wishlist' ? <HeartGlyph /> : item.short}
</span>
<span>{item.label}</span>
</button>
@@ -742,7 +895,7 @@ function Sidebar(props: {
</div>
<div className="sidebar-links">
{sidebarItems.map((item) => (
{sidebarItems.filter((item) => !props.isSectionHidden(item.route)).map((item) => (
<button
className={item.route === props.route ? 'sidebar-link active' : 'sidebar-link'}
key={item.route}
@@ -750,7 +903,7 @@ function Sidebar(props: {
type="button"
>
<span className={item.iconClassName ? `sidebar-link-short ${item.iconClassName}` : 'sidebar-link-short'} aria-hidden="true">
{item.icon === 'calendar' ? <CalendarGlyph /> : item.icon === 'search' ? <SearchGlyph /> : item.icon === 'downloads' ? <DownloadGlyph /> : item.icon === 'home' ? <HomeGlyph /> : item.icon === 'library' ? <LibraryGlyph /> : item.short}
{item.icon === 'calendar' ? <CalendarGlyph /> : item.icon === 'search' ? <SearchGlyph /> : item.icon === 'downloads' ? <DownloadGlyph /> : item.icon === 'home' ? <HomeGlyph /> : item.icon === 'library' ? <LibraryGlyph /> : item.icon === 'wishlist' ? <HeartGlyph /> : item.short}
</span>
<span>{item.label}</span>
</button>
@@ -758,7 +911,7 @@ function Sidebar(props: {
</div>
<div className="sidebar-links">
{networkSidebarItems.map((item) => (
{networkSidebarItems.filter((item) => !props.isSectionHidden(item.route)).map((item) => (
<button
className={item.route === props.route ? 'sidebar-link active' : 'sidebar-link'}
key={item.route}
@@ -1677,8 +1830,9 @@ function MediaTile(props: {
</div>
) : null}
{props.card.hoverLabel && !continueEpisodeMeta ? <div className="media-hover-label">{props.card.hoverLabel}</div> : null}
{props.card.progress ? <div className="tile-progress"><div className="tile-progress-fill" style={{ width: `${props.card.progress}%` }} /></div> : null}
{props.isContinueWatching && props.card.progress ? <div className="tile-progress"><div className="tile-progress-fill" style={{ width: `${props.card.progress}%` }} /></div> : null}
</button>
{!props.isContinueWatching && (props.styleType === 'landscape' || props.styleType === 'poster') ? <WishlistHeart card={props.card} className="media-wishlist-button" /> : null}
</article>
)
}
@@ -1998,6 +2152,26 @@ function TitleDetailsModal(props: {
const backgroundImage = details?.backdropUrl || props.card.backdropUrl || props.card.posterUrl
const logoUrl = details?.logoUrl || props.card.logoUrl
const displayTitle = details?.title || props.card.title
// Titles opened from Continue Watching arrive as a Jellyfin episode card, which
// cannot be wishlisted; the series the details resolved to can.
const wishlistCard: MediaCard = props.card.mediaType === 'episode' && details?.mediaType === 'series'
? {
...props.card,
id: details.providerId ? `jellyfin-${details.providerId}` : details.id,
tmdbId: details.tmdbId ?? props.card.tmdbId,
providerId: details.providerId ?? props.card.providerId,
title: details.title,
subtitle: '',
overview: details.overview,
mediaType: 'series',
posterUrl: details.posterUrl,
backdropUrl: details.backdropUrl,
logoUrl: details.logoUrl ?? props.card.logoUrl,
progress: undefined,
secondaryValue: undefined,
hoverLabel: undefined
}
: props.card
const displaySubtitle = details?.subtitle || props.card.subtitle
const displayOverview = details?.overview || props.card.overview || 'No details available yet.'
const displayYear = props.card.releaseDate?.slice(0, 4)
@@ -2449,7 +2623,11 @@ function TitleDetailsModal(props: {
event.preventDefault()
event.stopPropagation()
if (!sonarrEpisodeId || availability === 'downloading' || episodeDownloadBusyId === episodeId) {
if (availability === 'downloading' || episodeDownloadBusyId === episodeId) {
return
}
// Without a Sonarr id the series is not in Sonarr yet; it is added by the request.
if (!sonarrEpisodeId && !props.card.tmdbId) {
return
}
@@ -2462,7 +2640,7 @@ function TitleDetailsModal(props: {
function queueEpisodeDownload(
episodeId: string,
sonarrEpisodeId: number,
sonarrEpisodeId: number | undefined,
availability: TitleDetailsResponse['episodes'][number]['availability'],
qualityProfileId?: number
) {
@@ -2475,7 +2653,17 @@ function TitleDetailsModal(props: {
canDownload: false,
}))
void api.requestEpisode({ episodeId: sonarrEpisodeId, qualityProfileId }, props.currentUser)
const episode = details?.episodes.find((entry) => entry.id === episodeId)
const request = sonarrEpisodeId
? api.requestEpisode({ episodeId: sonarrEpisodeId, qualityProfileId }, props.currentUser)
: api.requestSeriesEpisode({
tmdbId: props.card.tmdbId!,
seasonNumber: episode?.seasonNumber ?? 0,
episodeNumber: episode?.episodeNumber ?? 0,
qualityProfileId,
}, props.currentUser)
void request
.then(() => refreshSeasonState(seasonValue || undefined))
.catch(() => {
setPendingEpisodeRequestIds((current) => current.filter((id) => id !== episodeId))
updateEpisodeInCaches(episodeId, (episode) => ({
@@ -2591,12 +2779,16 @@ function TitleDetailsModal(props: {
) : null}
</p>
<div className="title-details-summary-header">
{details?.mediaType !== 'series' ? (
<WishlistHeart card={wishlistCard} className="title-season-action title-wishlist-button" divider="after" />
) : null}
{canPlay && details?.mediaType !== 'series' ? (
<ActionButton className="title-summary-header-play" onClick={() => setPlayerTarget({ id: playId!, title: playLabel })} variant="play">
<PlayGlyph />
<span>Play</span>
</ActionButton>
) : null}
{canDeleteMovieAction ? <div className="title-season-divider title-season-action-divider" aria-hidden="true" /> : null}
{canDeleteMovieAction ? (
<ActionButton
aria-label="Delete movie files"
@@ -2708,8 +2900,9 @@ function TitleDetailsModal(props: {
<strong>{activeSeasonDetails?.episodes.length ?? activeSeasonMeta?.episodeCount ?? details.episodes.length}</strong>
<span>{(activeSeasonDetails?.episodes.length ?? activeSeasonMeta?.episodeCount ?? details.episodes.length) === 1 ? 'episode' : 'episodes'}</span>
</div>
{shouldShowDownloadSeasonAction || canDeleteSeasonAction ? (
<>
<div className="title-season-actions">
<WishlistHeart card={wishlistCard} className="title-season-action title-wishlist-button" divider="before" />
{shouldShowDownloadSeasonAction || activeSeasonMeta?.isDownloading ? <div className="title-season-divider title-season-action-divider" aria-hidden="true" /> : null}
{shouldShowDownloadSeasonAction || activeSeasonMeta?.isDownloading ? (
activeSeasonDownloadStatus === 'downloading' ? (
@@ -2775,7 +2968,7 @@ function TitleDetailsModal(props: {
</>
) : null}
</div>
) : null}
</>
<div className="title-season-strip-spacer" />
{canPlay ? (
<ActionButton
@@ -3052,6 +3245,79 @@ function PlayGlyph() {
)
}
function HeartGlyph({ filled, className = 'sidebar-glyph-icon' }: { filled?: boolean; className?: string }) {
return (
<svg aria-hidden="true" className={className} fill={filled ? 'currentColor' : 'none'} viewBox="0 0 24 24">
<path d="M12 20.3 4.6 13a4.8 4.8 0 0 1 6.8-6.8l.6.6.6-.6a4.8 4.8 0 0 1 6.8 6.8Z" stroke="currentColor" strokeLinejoin="round" strokeWidth="1.8" />
</svg>
)
}
function WishlistHeart({ card, className, divider }: { card: MediaCard; className: string; divider?: 'before' | 'after' }) {
const wishlist = useContext(WishlistContext)
if (!wishlist || !canWishlist(card)) {
return null
}
const wishlisted = wishlist.isWishlisted(card)
const separator = <div className="title-season-divider title-season-action-divider" aria-hidden="true" />
return (
<>
{divider === 'before' ? separator : null}
<button
aria-label={wishlisted ? `Remove ${card.title} from wishlist` : `Add ${card.title} to wishlist`}
aria-pressed={wishlisted}
className={wishlisted ? `${className} is-wishlisted` : className}
onClick={(event) => {
event.stopPropagation()
wishlist.toggle(card)
}}
title={wishlisted ? 'Remove from wishlist' : 'Add to wishlist'}
type="button"
>
<HeartGlyph className="title-action-icon" filled={wishlisted} />
</button>
{divider === 'after' ? separator : null}
</>
)
}
function WishlistPage(props: {
items: WishlistEntry[]
onOpenCard: (card: MediaCard, originRect?: ModalOriginRect | null) => void
}) {
return (
<div className="search-page wishlist-page">
<section className="search-header">
<h2><HeartGlyph /> <span>Wishlist</span></h2>
</section>
{props.items.length ? (
<section className="search-results-section">
<div className="search-results-grid">
{props.items.map((entry) => (
<MediaTile
busy={false}
key={getWishlistKey(entry.card)}
card={entry.card}
isContinueWatching={false}
onOpenCard={props.onOpenCard}
onRequest={async () => {}}
styleType="landscape"
/>
))}
</div>
</section>
) : (
<EmptyState
copy="Tap the heart on any movie or series to save it here."
title="Your wishlist is empty"
/>
)}
</div>
)
}
function CalendarGlyph() {
return (
<svg aria-hidden="true" className="sidebar-glyph-icon" viewBox="0 0 16 16">
@@ -3947,8 +4213,13 @@ function GlobeGlyph() {
function AdministrationScreen(props: {
config: AppConfig
savedConfig: AppConfig
connections: ConnectionStatus[]
error: string
notice: string
onExit: () => void
onExportBackup: () => Promise<void>
onImportBackup: (file: File) => Promise<void>
updateConfig: <K extends keyof AppConfig>(key: K, value: AppConfig[K]) => void
options: ServiceOptionsResponse
onSave: (event: FormEvent<HTMLFormElement>) => Promise<void>
@@ -3968,11 +4239,16 @@ function AdministrationScreen(props: {
<h1>Settings</h1>
</div>
</header>
{props.notice ? <p className="notice">{props.notice}</p> : null}
{props.error ? <p className="error-banner">{props.error}</p> : null}
<SettingsView
busy={props.busy}
config={props.config}
savedConfig={props.savedConfig}
connections={props.connections}
onCheck={props.onCheck}
onExportBackup={props.onExportBackup}
onImportBackup={props.onImportBackup}
onSave={props.onSave}
options={props.options}
formId="administration-settings"
@@ -3984,19 +4260,25 @@ function AdministrationScreen(props: {
function SettingsView(props: {
config: AppConfig
savedConfig: AppConfig
connections: ConnectionStatus[]
updateConfig: <K extends keyof AppConfig>(key: K, value: AppConfig[K]) => void
options: ServiceOptionsResponse
onSave: (event: FormEvent<HTMLFormElement>) => Promise<void>
onCheck: () => Promise<void>
onExportBackup: () => Promise<void>
onImportBackup: (file: File) => Promise<void>
busy: boolean
formId?: string
}) {
const check = { busy: props.busy, onCheck: props.onCheck }
// Each card lights up only for the fields it owns.
const changed = (pick: (config: AppConfig) => unknown) => JSON.stringify(pick(props.config)) !== JSON.stringify(pick(props.savedConfig))
const importInputRef = useRef<HTMLInputElement | null>(null)
return (
<form className="settings-page" id={props.formId} onSubmit={(event) => void props.onSave(event)}>
<SettingsCard title="Connections">
<SettingsCard title="Connections" {...check} dirty={changed((c) => [c.preferences.language, c.preferences.region])}>
<div className="settings-connections">
{SERVICE_KEYS.map((key) => getServiceStatus(props.connections, key) ?? notCheckedYet(key)).map((connection) => (
<div className="settings-connection" key={connection.key} title={connection.message}>
@@ -4008,20 +4290,43 @@ function SettingsView(props: {
</div>
))}
</div>
<div className="settings-preferences">
<label>
Language
<select
className="input"
onChange={(event) => props.updateConfig('preferences', { ...props.config.preferences, language: event.target.value })}
value={props.config.preferences.language}
>
{withCurrentOption(LANGUAGE_OPTIONS, props.config.preferences.language).map((option) => (
<option key={option.id} value={option.id}>{option.label}</option>
))}
</select>
</label>
<label>
Region
<select
className="input"
onChange={(event) => props.updateConfig('preferences', { ...props.config.preferences, region: event.target.value })}
value={props.config.preferences.region}
>
{withCurrentOption(REGION_OPTIONS, props.config.preferences.region).map((option) => (
<option key={option.id} value={option.id}>{option.label}</option>
))}
</select>
</label>
</div>
</SettingsCard>
<SettingsCard title="Preferences" {...check}>
<label>
Language
<input className="input" onChange={(event) => props.updateConfig('preferences', { ...props.config.preferences, language: event.target.value })} value={props.config.preferences.language} />
</label>
<label>
Region
<input className="input" maxLength={2} onChange={(event) => props.updateConfig('preferences', { ...props.config.preferences, region: event.target.value })} value={props.config.preferences.region} />
</label>
<SettingsCard side title="Profiles" {...check} dirty={changed((c) => c.preferences.hiddenSections)}>
<ProfilesAccess
config={props.config}
updateConfig={props.updateConfig}
users={props.options.jellyfinUsers}
/>
</SettingsCard>
<SettingsCard status={getServiceStatus(props.connections, 'jellyfin') ?? notCheckedYet('jellyfin')} title="Jellyfin" {...check}>
<SettingsCard status={getServiceStatus(props.connections, 'jellyfin') ?? notCheckedYet('jellyfin')} title="Jellyfin" {...check} dirty={changed((c) => [c.jellyfin.baseUrl, c.jellyfin.apiKey])}>
<ServiceFields
apiKey={props.config.jellyfin.apiKey}
baseUrl={props.config.jellyfin.baseUrl}
@@ -4030,7 +4335,7 @@ function SettingsView(props: {
/>
</SettingsCard>
<SettingsCard status={getServiceStatus(props.connections, 'sonarr') ?? notCheckedYet('sonarr')} title="Sonarr" {...check}>
<SettingsCard status={getServiceStatus(props.connections, 'sonarr') ?? notCheckedYet('sonarr')} title="Sonarr" {...check} dirty={changed((c) => [c.sonarr, c.preferences.sonarrDownloadQualityProfileIds])}>
<ServiceFields
apiKey={props.config.sonarr.apiKey}
baseUrl={props.config.sonarr.baseUrl}
@@ -4047,7 +4352,7 @@ function SettingsView(props: {
/>
</SettingsCard>
<SettingsCard status={getServiceStatus(props.connections, 'radarr') ?? notCheckedYet('radarr')} title="Radarr" {...check}>
<SettingsCard status={getServiceStatus(props.connections, 'radarr') ?? notCheckedYet('radarr')} title="Radarr" {...check} dirty={changed((c) => [c.radarr, c.preferences.radarrDownloadQualityProfileIds])}>
<ServiceFields
apiKey={props.config.radarr.apiKey}
baseUrl={props.config.radarr.baseUrl}
@@ -4064,20 +4369,49 @@ function SettingsView(props: {
/>
</SettingsCard>
<SettingsCard status={getServiceStatus(props.connections, 'tmdb') ?? notCheckedYet('tmdb')} title="TMDb" {...check}>
<SettingsCard status={getServiceStatus(props.connections, 'tmdb') ?? notCheckedYet('tmdb')} title="TMDb" {...check} dirty={changed((c) => c.tmdb)}>
<label>
API key or Read Access Token
<input className="input" onChange={(event) => props.updateConfig('tmdb', { bearerToken: event.target.value })} placeholder="API key or API Read Access Token" value={props.config.tmdb.bearerToken} />
</label>
</SettingsCard>
<SettingsCard status={getServiceStatus(props.connections, 'tvdb') ?? notCheckedYet('tvdb')} title="TVDB" {...check}>
<SettingsCard status={getServiceStatus(props.connections, 'tvdb') ?? notCheckedYet('tvdb')} title="TVDB" {...check} dirty={changed((c) => c.tvdb)}>
<label>
API key
<input className="input" onChange={(event) => props.updateConfig('tvdb', { apiKey: event.target.value })} placeholder="Optional if already provided via TVDB_API_KEY" value={props.config.tvdb.apiKey} />
</label>
</SettingsCard>
<SettingsCard title="Backup">
<p className="settings-backup-copy">
Saves every service connection and each profile's wishlist to a file. It holds your API keys, so keep it somewhere safe.
Restoring replaces the current settings and wishlists; the master password stays as it is.
</p>
<div className="settings-backup-actions">
<button className="secondary-button" disabled={props.busy} onClick={() => void props.onExportBackup()} type="button">
<DownloadGlyph />
<span>Export</span>
</button>
<button className="secondary-button" disabled={props.busy} onClick={() => importInputRef.current?.click()} type="button">
<span>Import</span>
</button>
<input
accept="application/json,.json"
hidden
onChange={(event) => {
const file = event.target.files?.[0]
event.target.value = ''
if (file && window.confirm('Restore this backup? The current settings and wishlists will be replaced.')) {
void props.onImportBackup(file)
}
}}
ref={importInputRef}
type="file"
/>
</div>
</SettingsCard>
</form>
)
}
@@ -4090,13 +4424,20 @@ function notCheckedYet(key: ConnectionStatus['key']): ConnectionStatus {
return { key, label: SERVICE_LABELS[key], ok: false, message: 'Not configured', configured: false, optional: key !== 'jellyfin' }
}
function SettingsCard({ title, status, busy, onCheck, children }: { title: string; status?: ConnectionStatus; busy?: boolean; onCheck?: () => Promise<void>; children: ReactNode }) {
function SettingsCard({ title, status, busy, dirty, side, onCheck, children }: { title: string; status?: ConnectionStatus; busy?: boolean; dirty?: boolean; side?: boolean; onCheck?: () => Promise<void>; children: ReactNode }) {
return (
<section className="settings-card">
<section className={side ? 'settings-card is-side' : 'settings-card'}>
<div className="settings-card-header">
<h2>{title}</h2>
{onCheck ? (
<button aria-label={`Save and check ${title}`} className="settings-card-check" disabled={busy} onClick={() => void onCheck()} title="Save and check" type="button">
<button
aria-label={dirty ? `Save changes and check ${title}` : `Save and check ${title}`}
className={dirty ? 'settings-card-check is-dirty' : 'settings-card-check'}
disabled={busy}
onClick={() => void onCheck()}
title={dirty ? 'You have unsaved changes: click to save and apply them' : 'Save and check'}
type="button"
>
<CheckGlyph />
</button>
) : null}
@@ -4170,6 +4511,225 @@ function QualityProfileVisibility(props: {
)
}
function ProfilesAccess(props: {
users: SelectOption[]
config: AppConfig
updateConfig: <K extends keyof AppConfig>(key: K, value: AppConfig[K]) => void
}) {
const [access, setAccess] = useState<ProfileLibraryAccess[]>([])
const [accessError, setAccessError] = useState('')
const [openUserId, setOpenUserId] = useState('')
const [query, setQuery] = useState('')
const [moreBelow, setMoreBelow] = useState(false)
const listRef = useRef<HTMLUListElement | null>(null)
const preferences = props.config.preferences
const openUser = props.users.find((user) => user.id === openUserId)
const visibleUsers = props.users.filter((user) => user.label.toLowerCase().includes(query.trim().toLowerCase()))
function updateMoreBelow() {
const list = listRef.current
setMoreBelow(Boolean(list) && list!.scrollHeight - list!.scrollTop - list!.clientHeight > 4)
}
// The list is as tall as the card next to it, so tell whether more rows hide below.
useEffect(() => {
const list = listRef.current
updateMoreBelow()
if (!list) {
return
}
const observer = new ResizeObserver(updateMoreBelow)
observer.observe(list)
return () => observer.disconnect()
}, [visibleUsers.length, props.users.length])
useEffect(() => {
if (!props.users.length) {
return
}
let cancelled = false
api.getProfileAccess()
.then((response) => {
if (cancelled) return
setAccess(response.profiles)
setAccessError('')
})
.catch((loadError) => {
if (cancelled) return
setAccessError(loadError instanceof Error ? loadError.message : 'Could not read the Jellyfin libraries.')
})
return () => {
cancelled = true
}
}, [props.users.length])
useEffect(() => {
if (!openUser) {
return
}
const closeOnEscape = (event: KeyboardEvent) => {
if (event.key === 'Escape') setOpenUserId('')
}
window.addEventListener('keydown', closeOnEscape)
return () => window.removeEventListener('keydown', closeOnEscape)
}, [openUser])
function setSectionVisible(userId: string, section: HideableSection, visible: boolean) {
const current = preferences.hiddenSections[userId] ?? []
const next = visible ? current.filter((id) => id !== section) : [...current.filter((id) => id !== section), section]
const hiddenSections = { ...preferences.hiddenSections }
if (next.length) {
hiddenSections[userId] = next
} else {
delete hiddenSections[userId]
}
props.updateConfig('preferences', { ...preferences, hiddenSections })
}
if (!props.users.length) {
return <p className="profiles-access-note">Connect Jellyfin first to load its profiles.</p>
}
return (
<div className="profiles-access">
<p className="profiles-access-note">
Pick a profile to choose which sections it sees and review the libraries Jellyfin gives it.
Upcoming also leaves out releases stored in libraries a profile cannot open.
</p>
<input
aria-label="Search profiles"
className="input profiles-access-search"
onChange={(event) => setQuery(event.target.value)}
placeholder="Search profiles"
type="search"
value={query}
/>
<div className="profiles-access-scroll">
<ul className="profiles-access-list" onScroll={updateMoreBelow} ref={listRef}>
{visibleUsers.map((user) => {
const hidden = preferences.hiddenSections[user.id] ?? []
return (
<li key={user.id}>
<button className="profiles-access-summary" onClick={() => setOpenUserId(user.id)} type="button">
<ProfileAvatar user={user} />
<span className="profiles-access-name">{user.label}</span>
<span className="profiles-access-meta">
{hidden.length ? `${hidden.length} hidden` : 'All sections'}
</span>
<span aria-hidden="true" className="profiles-access-chevron" />
</button>
</li>
)
})}
{!visibleUsers.length ? <li className="profiles-access-note">No profiles match “{query.trim()}”.</li> : null}
</ul>
{moreBelow ? (
<button
aria-label="Show more profiles"
className="profiles-access-more"
onClick={() => listRef.current?.scrollBy({ top: listRef.current.clientHeight * 0.8, behavior: 'smooth' })}
type="button"
>
<span aria-hidden="true" />
</button>
) : null}
</div>
{openUser ? createPortal(
<div className="profile-dialog-backdrop" onClick={() => setOpenUserId('')}>
<div
aria-label={`${openUser.label} settings`}
aria-modal="true"
className="profile-dialog"
onClick={(event) => event.stopPropagation()}
role="dialog"
>
<header className="profile-dialog-header">
<ProfileAvatar user={openUser} />
<div>
<h2>{openUser.label}</h2>
<p>Changes are saved with the check button of the Profiles card.</p>
</div>
<button aria-label="Close" className="profile-dialog-close" onClick={() => setOpenUserId('')} type="button">×</button>
</header>
<div className="profile-dialog-body">
<section>
<h3>Sections</h3>
<div className="profile-sections">
{HIDEABLE_SECTIONS.map((section) => (
<label className="profile-section-row" key={section.id}>
<span className="profile-section-icon">{renderSectionIcon(section.id)}</span>
<span className="profile-section-label">{section.label}</span>
<ToggleSwitch
checked={!(preferences.hiddenSections[openUser.id] ?? []).includes(section.id)}
label={`${section.label} for ${openUser.label}`}
onChange={(visible) => setSectionVisible(openUser.id, section.id, visible)}
/>
</label>
))}
</div>
</section>
<section>
<h3>Libraries</h3>
{(() => {
const profileAccess = access.find((entry) => entry.userId === openUser.id)
if (!profileAccess) {
return <p className="profiles-access-note">{accessError || 'Loading libraries…'}</p>
}
return (
<>
<ul className="profile-libraries">
{profileAccess.libraries.map((library) => (
<li className={library.access ? 'profile-library-row has-access' : 'profile-library-row no-access'} key={library.id}>
<span className="profile-library-name">{library.name}</span>
<span className="profile-library-state">{library.access ? 'Has access' : 'No access'}</span>
</li>
))}
</ul>
<p className="profiles-access-note">{profileAccess.allLibraries ? 'Can open every library. ' : ''}Managed in Jellyfin.</p>
</>
)
})()}
</section>
</div>
</div>
</div>,
document.body
) : null}
</div>
)
}
// The icon each section has in the sidebar, for the profile settings.
function renderSectionIcon(section: HideableSection) {
switch (section) {
case 'search': return <SearchGlyph />
case 'calendar': return <CalendarGlyph />
case 'downloads': return <DownloadGlyph />
case 'wishlist': return <HeartGlyph />
case 'library': return <LibraryGlyph />
case 'dorama': return <span className="profile-section-letter">아</span>
case 'anime': return <span className="profile-section-letter">あ</span>
default: {
const network = networkSidebarItems.find((item) => item.route === section)
return network ? <img alt="" className={network.iconClassName || 'sidebar-network-icon-image'} src={network.icon} /> : null
}
}
}
function ToggleSwitch(props: { checked: boolean; label: string; onChange: (checked: boolean) => void }) {
return (
<span className="toggle-switch">
<input
aria-label={props.label}
checked={props.checked}
onChange={(event) => props.onChange(event.target.checked)}
type="checkbox"
/>
<span aria-hidden="true" className="toggle-switch-track" />
</span>
)
}
function EmptyState({ title, copy, className }: { title: string; copy: string; className?: string }) {
return (
<div className={className ? `empty-state ${className}` : 'empty-state'}>
+24 -1
View File
@@ -2,6 +2,7 @@ import type {
AppConfig,
AuthPayload,
AuthResponse,
BackupFile,
CalendarResponse,
ConnectionStatus,
DashboardResponse,
@@ -11,15 +12,19 @@ import type {
JellyfinLoginPayload,
MediaCard,
MovieDeletePayload,
ProfileLibraryAccess,
SearchResponse,
ServiceOptionsResponse,
SessionResponse,
EpisodeWatchStateRequest,
EpisodeRequestPayload,
SeasonDeletePayload,
SeriesEpisodeRequestPayload,
SeasonRequestPayload,
TitleDetailsRequest,
TitleDetailsResponse
TitleDetailsResponse,
WishlistResponse,
WishlistTogglePayload
} from '../shared/contracts'
async function request<T>(input: string, init?: RequestInit): Promise<T> {
@@ -92,6 +97,19 @@ export const api = {
method: 'POST',
body: JSON.stringify(payload),
}),
getWishlist: () => request<WishlistResponse>('/api/wishlist'),
setWishlisted: (payload: WishlistTogglePayload) =>
request<WishlistResponse>('/api/wishlist', {
method: 'POST',
body: JSON.stringify(payload),
}),
exportBackup: () => request<BackupFile>('/api/admin/backup'),
getProfileAccess: () => request<{ profiles: ProfileLibraryAccess[] }>('/api/admin/profile-access'),
importBackup: (backup: unknown) =>
request<{ config: AppConfig; connections: ConnectionStatus[] }>('/api/admin/backup', {
method: 'POST',
body: JSON.stringify(backup),
}),
getDashboard: () => request<DashboardResponse>('/api/dashboard'),
getDiskSpace: () => request<DiskSpaceStatus | null>('/api/storage'),
getCalendar: (start: Date, end: Date) => request<CalendarResponse>(`/api/calendar?start=${start.toISOString()}&end=${end.toISOString()}`),
@@ -142,6 +160,11 @@ export const api = {
method: 'POST',
body: JSON.stringify({ ...payload, user }),
}),
requestSeriesEpisode: (payload: SeriesEpisodeRequestPayload, user: string | null) =>
request<{ ok: boolean }>('/api/requests/series-episode', {
method: 'POST',
body: JSON.stringify({ ...payload, user }),
}),
deleteSeason: (payload: SeasonDeletePayload) =>
request<{ ok: boolean }>('/api/seasons/delete', {
method: 'POST',
+571
View File
@@ -1857,6 +1857,55 @@ img {
gap: 0.6rem;
}
/* Movie header: every control is a plain icon (heart, play, delete, request)
like the ones in a series' season bar, centred on one line and split by
dividers instead of sitting in boxes. */
.title-details-summary-header > .title-season-action,
.title-details-summary-header > .title-season-divider,
.title-details-summary-header .title-summary-header-play,
.title-details-summary-header .title-summary-header-delete,
.title-details-summary-header > .secondary-button {
align-self: center;
}
.title-details-summary-header .title-summary-header-play,
.title-details-summary-header .title-summary-header-delete,
.title-details-summary-header > .secondary-button {
min-width: 1.9rem;
width: auto;
min-height: 1.9rem;
height: auto;
margin-top: 0;
padding: 0.18rem 0.4rem;
border: 0;
border-radius: 0;
background: transparent;
color: rgba(237, 242, 255, 0.82);
font-weight: 600;
transition: color 180ms ease, transform 180ms ease, opacity 180ms ease;
}
.title-details-summary-header .title-summary-header-delete {
padding: 0.18rem;
}
.title-details-summary-header .title-summary-header-play:hover,
.title-details-summary-header .title-summary-header-play:focus-visible,
.title-details-summary-header .title-summary-header-delete:hover,
.title-details-summary-header .title-summary-header-delete:focus-visible,
.title-details-summary-header > .secondary-button:hover,
.title-details-summary-header > .secondary-button:focus-visible {
border: 0;
background: transparent;
color: #ffffff;
transform: translateY(-1px);
}
.title-details-summary-header .title-action-icon {
width: 1.2rem;
height: 1.2rem;
}
.title-movie-request-processing,
.title-movie-request-progress {
display: inline-flex;
@@ -3942,6 +3991,23 @@ img {
opacity: 0.5;
}
/* Unsaved changes: the button turns amber and pulses until they are applied. */
.settings-card-check.is-dirty {
background: #f6ad55;
animation: settings-check-pulse 1.8s ease-in-out infinite;
}
@keyframes settings-check-pulse {
0%, 100% { box-shadow: 0 0 0 0 rgba(246, 173, 85, 0.5); }
50% { box-shadow: 0 0 0 0.45rem rgba(246, 173, 85, 0); }
}
@media (prefers-reduced-motion: reduce) {
.settings-card-check.is-dirty {
animation: none;
}
}
.settings-card label,
.auth-form label {
display: grid;
@@ -5950,3 +6016,508 @@ img {
outline-offset: 4px;
border-radius: 1rem;
}
/* Wishlist */
.media-wishlist-button {
position: absolute;
top: 0.6rem;
right: 0.6rem;
z-index: 3;
display: grid;
place-items: center;
width: 2.2rem;
height: 2.2rem;
padding: 0;
border: 1px solid rgba(255, 255, 255, 0.14);
border-radius: 999px;
background: rgba(6, 8, 12, 0.55);
color: #f3f6ff;
backdrop-filter: blur(8px);
opacity: 0;
transition: opacity 180ms ease, transform 180ms ease, color 180ms ease;
}
.media-wishlist-button .title-action-icon {
width: 1.05rem;
height: 1.05rem;
}
.media-tile:hover .media-wishlist-button,
.media-tile:focus-within .media-wishlist-button,
.media-wishlist-button.is-wishlisted {
opacity: 1;
}
.media-wishlist-button:hover,
.media-wishlist-button:focus-visible {
transform: scale(1.08);
}
.media-wishlist-button.is-wishlisted,
.title-wishlist-button.is-wishlisted {
color: #ff5c7a;
}
/* Phones and touch screens have no hover, and a heart on every poster is noise;
the wishlist stays reachable from the title details. */
@media (hover: none), (max-width: 980px) {
.media-wishlist-button {
display: none;
}
}
.settings-backup-copy {
margin: 0;
color: #98a8c4;
font-size: 0.92rem;
line-height: 1.45;
}
.settings-backup-actions {
display: flex;
flex-wrap: wrap;
gap: 0.75rem;
}
.settings-backup-actions .secondary-button {
display: inline-flex;
align-items: center;
gap: 0.6rem;
}
.administration-layout > .notice,
.administration-layout > .error-banner {
max-width: 76rem;
margin: 0 auto 1rem;
}
/* Profiles: who sees which sections, and which libraries Jellyfin gives them. */
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
.profiles-access {
display: grid;
gap: 0.9rem;
}
.profiles-access-note {
margin: 0;
color: #9ba9c2;
font-size: 0.86rem;
}
.profiles-access-scroll {
position: relative;
display: flex;
flex: 1;
flex-direction: column;
min-height: 0;
}
.profiles-access-list {
display: grid;
flex: 1;
grid-template-columns: minmax(0, 1fr);
align-content: start;
gap: 0.6rem;
min-height: 0;
max-height: 26rem;
margin: 0;
padding: 0;
overflow-y: auto;
list-style: none;
scrollbar-width: thin;
}
/* A hint that more profiles wait below: a fade with an arrow that scrolls down. */
.profiles-access-more {
position: absolute;
right: 0;
bottom: 0;
left: 0;
display: grid;
place-items: end center;
height: 3.6rem;
padding: 0 0 0.35rem;
border: 0;
background: linear-gradient(to top, rgba(10, 12, 18, 0.96) 15%, rgba(10, 12, 18, 0));
color: #dfe7f7;
cursor: pointer;
}
.profiles-access-more span {
width: 0.55rem;
height: 0.55rem;
border-right: 2px solid currentColor;
border-bottom: 2px solid currentColor;
transform: rotate(45deg);
animation: profiles-access-nudge 1.6s ease-in-out infinite;
}
@keyframes profiles-access-nudge {
0%, 100% { translate: 0 0; }
50% { translate: 0 0.25rem; }
}
@media (prefers-reduced-motion: reduce) {
.profiles-access-more span {
animation: none;
}
}
/* Next to the Connections card, the card takes that card's height instead of
stretching the row, and its list scrolls inside it. */
.settings-card.is-side {
display: flex;
flex-direction: column;
}
.settings-card.is-side .settings-fields {
display: flex;
flex: 1;
flex-direction: column;
min-height: 0;
}
.settings-card.is-side .profiles-access {
display: flex;
flex: 1;
flex-direction: column;
min-height: 0;
}
@media (min-width: 981px) {
.settings-card.is-side {
min-height: 20rem;
contain: size;
}
.settings-card.is-side .profiles-access-list {
max-height: none;
}
}
.profiles-access-summary {
display: flex;
align-items: center;
gap: 0.85rem;
width: 100%;
padding: 0.7rem 0.95rem;
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 1rem;
background: rgba(255, 255, 255, 0.025);
color: #f4f7ff;
text-align: left;
cursor: pointer;
transition: background 160ms ease, border-color 160ms ease;
}
.profiles-access-summary:hover,
.profiles-access-summary:focus-visible {
border-color: rgba(255, 255, 255, 0.2);
background: rgba(255, 255, 255, 0.06);
}
.profiles-access-summary .profile-avatar,
.profile-dialog-header .profile-avatar {
flex: none;
width: 2.4rem;
height: 2.4rem;
border-radius: 50%;
font-size: 1rem;
overflow: hidden;
}
.profile-dialog-header .profile-avatar {
width: 3.2rem;
height: 3.2rem;
font-size: 1.3rem;
}
.profiles-access-name {
flex: 1;
min-width: 0;
font-weight: 600;
}
.profiles-access-meta {
color: #9ba9c2;
font-size: 0.82rem;
}
.profiles-access-chevron {
width: 0.5rem;
height: 0.5rem;
border-top: 2px solid #9ba9c2;
border-right: 2px solid #9ba9c2;
transform: rotate(45deg);
}
.profile-dialog-backdrop {
position: fixed;
inset: 0;
z-index: 200;
display: grid;
place-items: center;
padding: 1.5rem;
background: rgba(3, 5, 10, 0.72);
backdrop-filter: blur(6px);
}
.profile-dialog {
display: grid;
gap: 1.6rem;
width: min(46rem, 100%);
max-height: calc(100vh - 3rem);
padding: 1.8rem;
overflow-y: auto;
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 1.4rem;
background: #0b0e16;
box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.profile-dialog-body {
display: grid;
gap: 1.8rem;
}
.profile-dialog-header {
display: flex;
align-items: center;
gap: 1rem;
}
.profile-dialog-header > div {
flex: 1;
min-width: 0;
}
.profile-dialog-header h2 {
margin: 0;
color: #f4f7ff;
font-size: 1.25rem;
}
.profile-dialog-header p {
margin: 0.15rem 0 0;
color: #9ba9c2;
font-size: 0.82rem;
}
.profile-dialog-close {
display: grid;
flex: none;
place-items: center;
width: 2.2rem;
height: 2.2rem;
border: 0;
border-radius: 50%;
background: rgba(255, 255, 255, 0.08);
color: #f4f7ff;
font-size: 1.3rem;
line-height: 1;
cursor: pointer;
}
.profile-dialog-close:hover,
.profile-dialog-close:focus-visible {
background: rgba(255, 255, 255, 0.16);
}
.profile-dialog-body h3 {
margin: 0 0 0.7rem;
color: #e8efff;
font-size: 0.84rem;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.profile-sections {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 0.75rem;
}
.profile-section-row {
display: flex;
align-items: center;
gap: 0.9rem;
padding: 0.8rem 1rem;
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 1rem;
background: rgba(255, 255, 255, 0.03);
color: #dfe7f7;
cursor: pointer;
}
.profile-section-row:hover {
background: rgba(255, 255, 255, 0.06);
}
.profile-section-icon {
display: grid;
flex: none;
place-items: center;
width: 2.4rem;
height: 2.4rem;
border-radius: 0.75rem;
background: rgba(255, 255, 255, 0.08);
color: #f4f7ff;
overflow: hidden;
}
.profile-section-icon svg {
width: 1.15rem;
height: 1.15rem;
}
.profile-section-icon img {
width: 1.5rem;
height: 1.5rem;
object-fit: contain;
}
.profile-section-letter {
font-size: 1rem;
font-weight: 700;
}
.profile-section-label {
flex: 1;
min-width: 0;
font-size: 0.95rem;
font-weight: 600;
}
.profile-libraries {
display: grid;
gap: 0.6rem;
margin: 0 0 0.8rem;
padding: 0;
list-style: none;
}
.profile-library-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
padding: 0.8rem 1rem;
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 1rem;
background: rgba(255, 255, 255, 0.03);
font-size: 0.95rem;
font-weight: 600;
}
.profile-library-state {
padding: 0.2rem 0.7rem;
border-radius: 999px;
font-size: 0.78rem;
font-weight: 700;
}
.profile-library-row.has-access .profile-library-state {
background: rgba(104, 211, 145, 0.16);
color: #68d391;
}
.profile-library-row.no-access {
color: #7d89a1;
}
.profile-library-row.no-access .profile-library-state {
background: rgba(255, 107, 129, 0.16);
color: #ff6b81;
}
.toggle-switch {
position: relative;
display: inline-flex;
flex: none;
width: 2.5rem;
height: 1.4rem;
}
.toggle-switch input {
position: absolute;
inset: 0;
z-index: 1;
width: 100%;
height: 100%;
margin: 0;
opacity: 0;
cursor: pointer;
}
.toggle-switch-track {
position: absolute;
inset: 0;
border-radius: 999px;
background: rgba(255, 255, 255, 0.16);
transition: background 160ms ease;
}
.toggle-switch-track::after {
content: '';
position: absolute;
top: 0.2rem;
left: 0.2rem;
width: 1rem;
height: 1rem;
border-radius: 50%;
background: #f4f7ff;
transition: transform 160ms ease;
}
.toggle-switch input:checked + .toggle-switch-track {
background: #68d391;
}
.toggle-switch input:checked + .toggle-switch-track::after {
transform: translateX(1.1rem);
}
.toggle-switch input:focus-visible + .toggle-switch-track {
outline: 2px solid #dfe7f7;
outline-offset: 2px;
}
@media (max-width: 760px) {
.profile-sections {
grid-template-columns: minmax(0, 1fr);
}
}
.settings-preferences {
display: grid;
gap: 0.9rem;
margin-top: 0.4rem;
padding-top: 1.1rem;
border-top: 1px solid rgba(255, 255, 255, 0.06);
}
select.input {
appearance: none;
padding-right: 2.6rem;
background-image: linear-gradient(45deg, transparent 50%, #9ba9c2 50%), linear-gradient(135deg, #9ba9c2 50%, transparent 50%);
background-position: calc(100% - 1.3rem) 50%, calc(100% - 0.95rem) 50%;
background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
background-repeat: no-repeat;
}
select.input option {
background: #0b0e16;
color: #f4f7ff;
}