mirror of
https://github.com/WonderAliceUwU/OmniArr.git
synced 2026-11-18 11:28:37 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f1cde1852 | ||
|
|
adf9993b10 | ||
|
|
7da0377d50 | ||
|
|
64f9a84678 | ||
|
|
ee288e7bd7 | ||
|
|
6a59aaffa3 | ||
|
|
9ed8260a10 | ||
|
|
1376d75ed8 | ||
|
|
4cea990eb3 | ||
|
|
2b4119a906 | ||
|
|
8fc9833679 | ||
|
|
0672b8c72b | ||
|
|
591fac51b2 | ||
|
|
a926964834 | ||
|
|
fb07b27675 | ||
|
|
9f1d50b35d | ||
|
|
3c7836e18b | ||
|
|
739afbefe3 | ||
|
|
d7ff401d33 | ||
|
|
cda724e736 | ||
|
|
e0baa13ef9 |
No files matched your search
@@ -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" />
|
<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.
|
- A download manager to see what's cooking.
|
||||||
|
- Per-profile control of which sections each person sees (see [Profiles](#profiles)).
|
||||||
|
|
||||||
And many things more!
|
And many things more!
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ Create a directory for OmniArr and add this `docker-compose.yml`:
|
|||||||
```yaml
|
```yaml
|
||||||
services:
|
services:
|
||||||
omniarr:
|
omniarr:
|
||||||
image: wonderalice/omniarr:1.2
|
image: wonderalice/omniarr:1.2.5
|
||||||
container_name: omniarr
|
container_name: omniarr
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
@@ -90,11 +91,11 @@ the mount loses that state when the container is replaced.
|
|||||||
The current release is available as:
|
The current release is available as:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
wonderalice/omniarr:1.2
|
wonderalice/omniarr:1.2.5
|
||||||
wonderalice/omniarr:latest
|
wonderalice/omniarr:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
Pin `1.2` 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.
|
Compose to follow the newest published image.
|
||||||
|
|
||||||
## Build locally
|
## Build locally
|
||||||
@@ -122,6 +123,50 @@ npm run lint
|
|||||||
npm run build
|
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
|
## Data and security
|
||||||
|
|
||||||
OmniArr keeps critical state under `OMNIARR_DATA_DIR` (by default
|
OmniArr keeps critical state under `OMNIARR_DATA_DIR` (by default
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
omniarr:
|
omniarr:
|
||||||
image: wonderalice/omniarr:1.2
|
image: wonderalice/omniarr:1.2.5
|
||||||
# Para construir desde código fuente en su lugar, descomenta estas líneas:
|
# Para construir desde código fuente en su lugar, descomenta estas líneas:
|
||||||
# build:
|
# build:
|
||||||
# context: .
|
# context: .
|
||||||
|
|||||||
+2
-1
@@ -12,7 +12,8 @@
|
|||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"start": "node dist-server/server/index.js",
|
"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": {
|
"dependencies": {
|
||||||
"react": "^19.2.5",
|
"react": "^19.2.5",
|
||||||
|
|||||||
+197
-9
@@ -4,11 +4,18 @@ import { BlockList, isIP } from 'node:net';
|
|||||||
import { resolve } from 'node:path';
|
import { resolve } from 'node:path';
|
||||||
import {
|
import {
|
||||||
defaultConfig,
|
defaultConfig,
|
||||||
|
HIDEABLE_SECTIONS,
|
||||||
type AppConfig,
|
type AppConfig,
|
||||||
type AuthPayload,
|
type AuthPayload,
|
||||||
|
type BackupFile,
|
||||||
|
type MediaCard,
|
||||||
|
type WishlistEntry,
|
||||||
|
type WishlistTogglePayload,
|
||||||
type EpisodeRequestPayload,
|
type EpisodeRequestPayload,
|
||||||
|
type SeriesEpisodeRequestPayload,
|
||||||
type EpisodeWatchStateRequest,
|
type EpisodeWatchStateRequest,
|
||||||
type DiskSpaceStatus,
|
type DiskSpaceStatus,
|
||||||
|
type HideableSection,
|
||||||
type HubPageResponse,
|
type HubPageResponse,
|
||||||
type JellyfinLoginPayload,
|
type JellyfinLoginPayload,
|
||||||
type MovieDeletePayload,
|
type MovieDeletePayload,
|
||||||
@@ -17,7 +24,18 @@ import {
|
|||||||
type TitleDetailsRequest
|
type TitleDetailsRequest
|
||||||
} from '../shared/contracts.js';
|
} from '../shared/contracts.js';
|
||||||
import { decryptJson, deriveEncryptionKey, encryptJson, randomToken, verifyPassword, createPasswordRecord } from './lib/security.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 {
|
import {
|
||||||
getCalendar,
|
getCalendar,
|
||||||
getConnectionStatuses,
|
getConnectionStatuses,
|
||||||
@@ -35,12 +53,14 @@ import {
|
|||||||
proxyJellyfinImage,
|
proxyJellyfinImage,
|
||||||
removeDownload,
|
removeDownload,
|
||||||
requestEpisode,
|
requestEpisode,
|
||||||
|
requestSeriesEpisode,
|
||||||
requestMovie,
|
requestMovie,
|
||||||
requestSeason,
|
requestSeason,
|
||||||
requestSeries,
|
requestSeries,
|
||||||
setEpisodeWatchState,
|
setEpisodeWatchState,
|
||||||
sanitizeConfig,
|
sanitizeConfig,
|
||||||
getDownloadsResponse,
|
getDownloadsResponse,
|
||||||
|
getProfileLibraryAccess,
|
||||||
dismissCompletedDownload,
|
dismissCompletedDownload,
|
||||||
dismissAllCompletedDownloads
|
dismissAllCompletedDownloads
|
||||||
} from './lib/services.js';
|
} from './lib/services.js';
|
||||||
@@ -252,6 +272,89 @@ async function routeRequest(request: IncomingMessage, response: ServerResponse):
|
|||||||
return;
|
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') {
|
if (url.pathname === '/api/settings' && method === 'GET') {
|
||||||
const config = await readConfig(session!.encryptionKey);
|
const config = await readConfig(session!.encryptionKey);
|
||||||
sendJson(response, 200, session!.role === 'admin' ? config : redactConfig(config));
|
sendJson(response, 200, session!.role === 'admin' ? config : redactConfig(config));
|
||||||
@@ -426,6 +529,14 @@ async function routeRequest(request: IncomingMessage, response: ServerResponse):
|
|||||||
return;
|
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') {
|
if (url.pathname === '/api/seasons/delete' && method === 'POST') {
|
||||||
const config = await readConfig(session!.encryptionKey);
|
const config = await readConfig(session!.encryptionKey);
|
||||||
const body = await readJson<SeasonDeletePayload>(request);
|
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.');
|
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: {
|
preferences: {
|
||||||
...defaultConfig.preferences,
|
...defaultConfig.preferences,
|
||||||
...(stored.preferences || {})
|
...(stored.preferences || {})
|
||||||
@@ -608,10 +727,76 @@ async function readConfig(legacyEncryptionKey?: Buffer): Promise<AppConfig> {
|
|||||||
...(stored.tvdb || {})
|
...(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;
|
// Profiles keep their own wishlist; the administrator has no Jellyfin profile
|
||||||
return { ...config, jellyfin: { ...config.jellyfin, userId: userId || '' } };
|
// 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> {
|
async function getConfigEncryptionKey(): Promise<Buffer> {
|
||||||
@@ -662,14 +847,17 @@ async function serveApp(pathname: string, response: ServerResponse): Promise<voi
|
|||||||
try {
|
try {
|
||||||
const content = await readFile(filePath);
|
const content = await readFile(filePath);
|
||||||
response.writeHead(200, {
|
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);
|
response.end(content);
|
||||||
} catch {
|
} catch {
|
||||||
try {
|
try {
|
||||||
const indexHtml = await readFile(resolve(process.cwd(), 'dist', 'index.html'));
|
const indexHtml = await readFile(resolve(process.cwd(), 'dist', 'index.html'));
|
||||||
response.writeHead(200, {
|
response.writeHead(200, {
|
||||||
'Content-Type': 'text/html; charset=utf-8'
|
'Content-Type': 'text/html; charset=utf-8',
|
||||||
|
'Cache-Control': 'no-cache'
|
||||||
});
|
});
|
||||||
response.end(indexHtml);
|
response.end(indexHtml);
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
+229
-7
@@ -11,12 +11,15 @@ import type {
|
|||||||
EpisodeRequestPayload,
|
EpisodeRequestPayload,
|
||||||
EpisodeWatchStateRequest,
|
EpisodeWatchStateRequest,
|
||||||
HubPageResponse,
|
HubPageResponse,
|
||||||
|
HideableSection,
|
||||||
HubSection,
|
HubSection,
|
||||||
MediaCard,
|
MediaCard,
|
||||||
MovieDeletePayload,
|
MovieDeletePayload,
|
||||||
ProcessingItem,
|
ProcessingItem,
|
||||||
|
ProfileLibraryAccess,
|
||||||
SeasonDeletePayload,
|
SeasonDeletePayload,
|
||||||
SeasonRequestPayload,
|
SeasonRequestPayload,
|
||||||
|
SeriesEpisodeRequestPayload,
|
||||||
SelectOption,
|
SelectOption,
|
||||||
ServiceOptionsResponse,
|
ServiceOptionsResponse,
|
||||||
TitleDetailsEpisode,
|
TitleDetailsEpisode,
|
||||||
@@ -25,6 +28,7 @@ import type {
|
|||||||
TitleDetailsSeason,
|
TitleDetailsSeason,
|
||||||
TitleDetailsCastMember
|
TitleDetailsCastMember
|
||||||
} from '../../shared/contracts.js';
|
} from '../../shared/contracts.js';
|
||||||
|
import { HIDEABLE_SECTIONS } from '../../shared/contracts.js';
|
||||||
|
|
||||||
const TMDB_IMAGE = 'https://image.tmdb.org/t/p';
|
const TMDB_IMAGE = 'https://image.tmdb.org/t/p';
|
||||||
const TMDB_ARTWORK_TTL_MS = 6 * 60 * 60 * 1000;
|
const TMDB_ARTWORK_TTL_MS = 6 * 60 * 60 * 1000;
|
||||||
@@ -189,6 +193,7 @@ interface SonarrCalendarRecord {
|
|||||||
series?: {
|
series?: {
|
||||||
title?: string;
|
title?: string;
|
||||||
tmdbId?: number;
|
tmdbId?: number;
|
||||||
|
path?: string;
|
||||||
images?: Array<{ coverType?: string; remoteUrl?: string; url?: string }>;
|
images?: Array<{ coverType?: string; remoteUrl?: string; url?: string }>;
|
||||||
year?: number;
|
year?: number;
|
||||||
status?: string;
|
status?: string;
|
||||||
@@ -239,6 +244,7 @@ interface RadarrCalendarRecord {
|
|||||||
digitalRelease?: string;
|
digitalRelease?: string;
|
||||||
monitored?: boolean;
|
monitored?: boolean;
|
||||||
hasFile?: boolean;
|
hasFile?: boolean;
|
||||||
|
path?: string;
|
||||||
images?: Array<{ coverType?: string; remoteUrl?: string; url?: 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 tmdbArtworkCache = new Map<string, { expiresAt: number; value: Promise<TmdbArtwork> }>();
|
||||||
const tvdbTranslationCache = new Map<string, { expiresAt: number; value: Promise<TvdbTranslationRecord | null> }>();
|
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 {
|
export function sanitizeConfig(input: AppConfig): AppConfig {
|
||||||
return {
|
return {
|
||||||
preferences: {
|
preferences: {
|
||||||
@@ -382,7 +406,8 @@ export function sanitizeConfig(input: AppConfig): AppConfig {
|
|||||||
: [],
|
: [],
|
||||||
radarrDownloadQualityProfileIds: Array.isArray(input.preferences.radarrDownloadQualityProfileIds)
|
radarrDownloadQualityProfileIds: Array.isArray(input.preferences.radarrDownloadQualityProfileIds)
|
||||||
? input.preferences.radarrDownloadQualityProfileIds.map(String)
|
? input.preferences.radarrDownloadQualityProfileIds.map(String)
|
||||||
: []
|
: [],
|
||||||
|
hiddenSections: sanitizeHiddenSections(input.preferences.hiddenSections)
|
||||||
},
|
},
|
||||||
jellyfin: {
|
jellyfin: {
|
||||||
baseUrl: normalizeBaseUrl(input.jellyfin.baseUrl),
|
baseUrl: normalizeBaseUrl(input.jellyfin.baseUrl),
|
||||||
@@ -744,15 +769,36 @@ export async function getCalendar(config: AppConfig, start: Date, end: Date): Pr
|
|||||||
getRadarrCalendar(config, start, end)
|
getRadarrCalendar(config, start, end)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
// 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'
|
const sonarrItems = sonarrResult.status === 'fulfilled'
|
||||||
? sonarrResult.value.map((item) => mapSonarrCalendarEntry(item))
|
? sonarrResult.value
|
||||||
|
.filter((item) => !isInFolders(item.series?.path, hiddenFolders))
|
||||||
|
.map((item) => mapSonarrCalendarEntry(item))
|
||||||
: []
|
: []
|
||||||
const radarrItems = radarrResult.status === 'fulfilled'
|
const radarrItems = radarrResult.status === 'fulfilled'
|
||||||
? radarrResult.value.map((item) => mapRadarrCalendarEntry(item))
|
? 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');
|
||||||
|
if (libraryCard?.tmdbId && libraryCard.providerId && (libraryCard.mediaType === 'movie' || libraryCard.mediaType === 'series')) {
|
||||||
|
libraryProviderIds.set(`${libraryCard.mediaType}:${libraryCard.tmdbId}`, libraryCard.providerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const allItems = [...sonarrItems, ...radarrItems]
|
const allItems = [...sonarrItems, ...radarrItems]
|
||||||
.filter((item): item is CalendarEntry => Boolean(item));
|
.filter((item): item is CalendarEntry => Boolean(item))
|
||||||
|
.map((item) => {
|
||||||
|
const providerId = item.card.tmdbId ? libraryProviderIds.get(`${item.card.mediaType}:${item.card.tmdbId}`) : undefined;
|
||||||
|
return providerId ? { ...item, card: { ...item.card, providerId } } : item;
|
||||||
|
});
|
||||||
|
|
||||||
const backdropCache = new Map<string, Promise<TmdbBackdropChoice>>();
|
const backdropCache = new Map<string, Promise<TmdbBackdropChoice>>();
|
||||||
const cards = await applyHighResBackdropsToCards(config, allItems.map(i => i.card), shouldUseHighResBackdropForCard, backdropCache, 'en');
|
const cards = await applyHighResBackdropsToCards(config, allItems.map(i => i.card), shouldUseHighResBackdropForCard, backdropCache, 'en');
|
||||||
@@ -775,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(
|
export async function searchTitles(
|
||||||
config: AppConfig,
|
config: AppConfig,
|
||||||
rawQuery: string
|
rawQuery: string
|
||||||
@@ -968,11 +1096,30 @@ async function removeSonarrSeriesIfEmpty(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function withLibraryProviderId(config: AppConfig, card: MediaCard): Promise<MediaCard> {
|
||||||
|
if (!card.tmdbId || (card.mediaType !== 'movie' && card.mediaType !== 'series' && card.mediaType !== 'tv')) {
|
||||||
|
return card;
|
||||||
|
}
|
||||||
|
|
||||||
|
const library = await getLibrarySnapshot(config).catch(() => null);
|
||||||
|
const wantedType = card.mediaType === 'movie' ? 'movie' : 'series';
|
||||||
|
for (const libraryItem of library?.allItems ?? []) {
|
||||||
|
const libraryCard = jellyfinToCard(libraryItem, libraryItem.Name || 'Library');
|
||||||
|
if (libraryCard?.tmdbId === card.tmdbId && libraryCard.mediaType === wantedType) {
|
||||||
|
return { ...card, providerId: libraryCard.providerId };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return card;
|
||||||
|
}
|
||||||
|
|
||||||
export async function getTitleDetails(
|
export async function getTitleDetails(
|
||||||
config: AppConfig,
|
config: AppConfig,
|
||||||
request: TitleDetailsRequest
|
request: TitleDetailsRequest
|
||||||
): Promise<TitleDetailsResponse> {
|
): Promise<TitleDetailsResponse> {
|
||||||
const { card, seasonId } = request;
|
const { seasonId } = request;
|
||||||
|
// Cards that don't come from Jellyfin (downloads, upcoming) are linked to
|
||||||
|
// their library item by TMDb id.
|
||||||
|
const card = request.card.providerId ? request.card : await withLibraryProviderId(config, request.card);
|
||||||
const item = card.providerId ? await getJellyfinItemDetails(config, card.providerId) : null;
|
const item = card.providerId ? await getJellyfinItemDetails(config, card.providerId) : null;
|
||||||
const seriesItem = await resolveSeriesItem(config, card, item);
|
const seriesItem = await resolveSeriesItem(config, card, item);
|
||||||
const primaryItem = seriesItem || item;
|
const primaryItem = seriesItem || item;
|
||||||
@@ -2408,7 +2555,11 @@ async function buildSeasonEpisodes(
|
|||||||
availability,
|
availability,
|
||||||
downloadStatus,
|
downloadStatus,
|
||||||
downloadProgress: isDownloading ? getEpisodeQueueProgress(queueEntry) : undefined,
|
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,
|
canDelete: hasFile,
|
||||||
watched: jellyfinEpisode?.watched,
|
watched: jellyfinEpisode?.watched,
|
||||||
progress: jellyfinEpisode?.progress,
|
progress: jellyfinEpisode?.progress,
|
||||||
@@ -2939,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> {
|
export async function deleteSeasonFiles(config: AppConfig, payload: SeasonDeletePayload): Promise<void> {
|
||||||
if (!config.sonarr.baseUrl || !config.sonarr.apiKey) {
|
if (!config.sonarr.baseUrl || !config.sonarr.apiKey) {
|
||||||
throw new Error('Sonarr is not configured.');
|
throw new Error('Sonarr is not configured.');
|
||||||
@@ -4014,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
|
throw new Error(detail
|
||||||
? `${response.status} ${response.statusText}: ${detail}`
|
? `${response.status} ${response.statusText}: ${detail}`
|
||||||
: `${response.status} ${response.statusText}`);
|
: `${response.status} ${response.statusText}`);
|
||||||
@@ -4046,7 +4265,10 @@ function jellyfinToCard(
|
|||||||
const backdropItemId = item.ParentBackdropItemId || item.Id;
|
const backdropItemId = item.ParentBackdropItemId || item.Id;
|
||||||
const backdropTag = item.ParentBackdropImageTags?.[0] || item.BackdropImageTags?.[0] || posterTag;
|
const backdropTag = item.ParentBackdropImageTags?.[0] || item.BackdropImageTags?.[0] || posterTag;
|
||||||
const progress = Math.round(item.UserData?.PlayedPercentage || 0);
|
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);
|
const episodeCode = formatEpisodeCode(item.ParentIndexNumber, item.IndexNumber);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
+82
-21
@@ -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 { dirname, resolve } from 'node:path';
|
||||||
|
import type { WishlistEntry } from '../../shared/contracts.js';
|
||||||
|
|
||||||
interface StoredAdmin {
|
interface StoredAdmin {
|
||||||
passwordHash: string;
|
passwordHash: string;
|
||||||
passwordSalt: string;
|
passwordSalt: string;
|
||||||
@@ -17,37 +19,75 @@ interface StoredState {
|
|||||||
admin: StoredAdmin | null;
|
admin: StoredAdmin | null;
|
||||||
config: EncryptedConfig | null;
|
config: EncryptedConfig | null;
|
||||||
configKey: string | 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 DATA_DIR = resolve(process.env.OMNIARR_DATA_DIR || resolve(process.cwd(), 'data'));
|
||||||
const STORE_FILE = resolve(DATA_DIR, 'omniarr.secure.json');
|
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 = {
|
const EMPTY_STATE: StoredState = {
|
||||||
version: 1,
|
version: 1,
|
||||||
admin: null,
|
admin: null,
|
||||||
config: null,
|
config: null,
|
||||||
configKey: null
|
configKey: null,
|
||||||
|
wishlists: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function loadState(): Promise<StoredState> {
|
// Every write reads the file, changes it and writes it back, so writes are
|
||||||
try {
|
// queued one after another; two profiles saving at once would otherwise drop
|
||||||
const raw = await readFile(STORE_FILE, 'utf8');
|
// one of the changes.
|
||||||
const parsed = JSON.parse(raw) as Partial<StoredState>;
|
let writeQueue: Promise<unknown> = Promise.resolve();
|
||||||
|
|
||||||
return {
|
async function readStoreFile(): Promise<string | null> {
|
||||||
version: parsed.configKey ? 2 : 1,
|
for (const file of [STORE_FILE, LEGACY_STORE_FILE]) {
|
||||||
admin: parsed.admin ?? null,
|
try {
|
||||||
config: parsed.config ?? null,
|
return await readFile(file, 'utf8');
|
||||||
configKey: typeof parsed.configKey === 'string' ? parsed.configKey : null
|
} catch (error) {
|
||||||
};
|
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;
|
||||||
} catch {
|
}
|
||||||
return EMPTY_STATE;
|
|
||||||
}
|
}
|
||||||
|
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> {
|
export async function saveState(state: StoredState): Promise<void> {
|
||||||
await mkdir(dirname(STORE_FILE), { recursive: true });
|
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> {
|
export async function readEncryptedConfig(): Promise<EncryptedConfig | null> {
|
||||||
@@ -60,20 +100,20 @@ export async function saveAdminAndConfig(
|
|||||||
config: EncryptedConfig,
|
config: EncryptedConfig,
|
||||||
configKey: string
|
configKey: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await saveState({
|
await updateState((state) => ({
|
||||||
|
...state,
|
||||||
version: 2,
|
version: 2,
|
||||||
admin,
|
admin,
|
||||||
config,
|
config,
|
||||||
configKey
|
configKey
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateEncryptedConfig(config: EncryptedConfig): Promise<void> {
|
export async function updateEncryptedConfig(config: EncryptedConfig): Promise<void> {
|
||||||
const state = await loadState();
|
await updateState((state) => ({
|
||||||
await saveState({
|
|
||||||
...state,
|
...state,
|
||||||
config
|
config
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function readAdmin(): Promise<StoredAdmin | null> {
|
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> {
|
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();
|
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 };
|
export type { EncryptedConfig, StoredAdmin, StoredState };
|
||||||
@@ -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']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -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
@@ -12,8 +12,27 @@ export type AppRoute =
|
|||||||
| 'library'
|
| 'library'
|
||||||
| 'calendar'
|
| 'calendar'
|
||||||
| 'downloads'
|
| 'downloads'
|
||||||
|
| 'wishlist'
|
||||||
| 'settings';
|
| '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 {
|
export interface ServiceConfig {
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
}
|
}
|
||||||
@@ -55,6 +74,16 @@ export interface AppPreferences {
|
|||||||
animationLevel: 'smooth' | 'reduced';
|
animationLevel: 'smooth' | 'reduced';
|
||||||
sonarrDownloadQualityProfileIds: string[];
|
sonarrDownloadQualityProfileIds: string[];
|
||||||
radarrDownloadQualityProfileIds: 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 {
|
export interface AppConfig {
|
||||||
@@ -303,6 +332,15 @@ export interface EpisodeRequestPayload {
|
|||||||
qualityProfileId?: number;
|
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 {
|
export interface SeasonDeletePayload {
|
||||||
seriesId: number;
|
seriesId: number;
|
||||||
seasonNumber: number;
|
seasonNumber: number;
|
||||||
@@ -347,6 +385,29 @@ export interface AuthResponse {
|
|||||||
message?: string;
|
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 {
|
export interface ApiErrorPayload {
|
||||||
error: string;
|
error: string;
|
||||||
}
|
}
|
||||||
@@ -358,7 +419,8 @@ export const defaultConfig: AppConfig = {
|
|||||||
excludeLibraryItems: true,
|
excludeLibraryItems: true,
|
||||||
animationLevel: 'smooth',
|
animationLevel: 'smooth',
|
||||||
sonarrDownloadQualityProfileIds: [],
|
sonarrDownloadQualityProfileIds: [],
|
||||||
radarrDownloadQualityProfileIds: []
|
radarrDownloadQualityProfileIds: [],
|
||||||
|
hiddenSections: {}
|
||||||
},
|
},
|
||||||
jellyfin: {
|
jellyfin: {
|
||||||
baseUrl: '',
|
baseUrl: '',
|
||||||
|
|||||||
+668
-59
File diff suppressed because it is too large.
Load diff
+24
-1
@@ -2,6 +2,7 @@ import type {
|
|||||||
AppConfig,
|
AppConfig,
|
||||||
AuthPayload,
|
AuthPayload,
|
||||||
AuthResponse,
|
AuthResponse,
|
||||||
|
BackupFile,
|
||||||
CalendarResponse,
|
CalendarResponse,
|
||||||
ConnectionStatus,
|
ConnectionStatus,
|
||||||
DashboardResponse,
|
DashboardResponse,
|
||||||
@@ -11,15 +12,19 @@ import type {
|
|||||||
JellyfinLoginPayload,
|
JellyfinLoginPayload,
|
||||||
MediaCard,
|
MediaCard,
|
||||||
MovieDeletePayload,
|
MovieDeletePayload,
|
||||||
|
ProfileLibraryAccess,
|
||||||
SearchResponse,
|
SearchResponse,
|
||||||
ServiceOptionsResponse,
|
ServiceOptionsResponse,
|
||||||
SessionResponse,
|
SessionResponse,
|
||||||
EpisodeWatchStateRequest,
|
EpisodeWatchStateRequest,
|
||||||
EpisodeRequestPayload,
|
EpisodeRequestPayload,
|
||||||
SeasonDeletePayload,
|
SeasonDeletePayload,
|
||||||
|
SeriesEpisodeRequestPayload,
|
||||||
SeasonRequestPayload,
|
SeasonRequestPayload,
|
||||||
TitleDetailsRequest,
|
TitleDetailsRequest,
|
||||||
TitleDetailsResponse
|
TitleDetailsResponse,
|
||||||
|
WishlistResponse,
|
||||||
|
WishlistTogglePayload
|
||||||
} from '../shared/contracts'
|
} from '../shared/contracts'
|
||||||
|
|
||||||
async function request<T>(input: string, init?: RequestInit): Promise<T> {
|
async function request<T>(input: string, init?: RequestInit): Promise<T> {
|
||||||
@@ -92,6 +97,19 @@ export const api = {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(payload),
|
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'),
|
getDashboard: () => request<DashboardResponse>('/api/dashboard'),
|
||||||
getDiskSpace: () => request<DiskSpaceStatus | null>('/api/storage'),
|
getDiskSpace: () => request<DiskSpaceStatus | null>('/api/storage'),
|
||||||
getCalendar: (start: Date, end: Date) => request<CalendarResponse>(`/api/calendar?start=${start.toISOString()}&end=${end.toISOString()}`),
|
getCalendar: (start: Date, end: Date) => request<CalendarResponse>(`/api/calendar?start=${start.toISOString()}&end=${end.toISOString()}`),
|
||||||
@@ -142,6 +160,11 @@ export const api = {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({ ...payload, user }),
|
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) =>
|
deleteSeason: (payload: SeasonDeletePayload) =>
|
||||||
request<{ ok: boolean }>('/api/seasons/delete', {
|
request<{ ok: boolean }>('/api/seasons/delete', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
+581
@@ -1857,6 +1857,55 @@ img {
|
|||||||
gap: 0.6rem;
|
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-processing,
|
||||||
.title-movie-request-progress {
|
.title-movie-request-progress {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
@@ -3942,6 +3991,23 @@ img {
|
|||||||
opacity: 0.5;
|
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,
|
.settings-card label,
|
||||||
.auth-form label {
|
.auth-form label {
|
||||||
display: grid;
|
display: grid;
|
||||||
@@ -5940,3 +6006,518 @@ img {
|
|||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.download-card.is-openable {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.download-card.is-openable:focus-visible {
|
||||||
|
outline: 2px solid rgba(255, 255, 255, 0.6);
|
||||||
|
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;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user