mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2025-12-24 02:39:18 -05:00
fix(tvdb): rename tvdb to medatada
This commit is contained in:
@@ -519,12 +519,32 @@ components:
|
||||
serverID:
|
||||
type: string
|
||||
readOnly: true
|
||||
TvdbSettings:
|
||||
MetadataSettings:
|
||||
type: object
|
||||
properties:
|
||||
use:
|
||||
type: boolean
|
||||
example: true
|
||||
settings:
|
||||
type: object
|
||||
properties:
|
||||
tv:
|
||||
type: string
|
||||
enum: [tvdb, tmdb]
|
||||
example: 'tvdb'
|
||||
anime:
|
||||
type: string
|
||||
enum: [tvdb, tmdb]
|
||||
example: 'tvdb'
|
||||
providers:
|
||||
type: object
|
||||
properties:
|
||||
tvdb:
|
||||
type: object
|
||||
properties:
|
||||
apiKey:
|
||||
type: string
|
||||
example: '123456789'
|
||||
pin:
|
||||
type: string
|
||||
example: '1234'
|
||||
TautulliSettings:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2574,10 +2594,10 @@ paths:
|
||||
type: string
|
||||
thumb:
|
||||
type: string
|
||||
/settings/tvdb:
|
||||
/settings/metadatas:
|
||||
get:
|
||||
summary: Get TVDB settings
|
||||
description: Retrieves current TVDB settings.
|
||||
summary: Get Metadata settings
|
||||
description: Retrieves current Metadata settings.
|
||||
tags:
|
||||
- settings
|
||||
responses:
|
||||
@@ -2586,10 +2606,10 @@ paths:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TvdbSettings'
|
||||
$ref: '#/components/schemas/MetadataSettings'
|
||||
put:
|
||||
summary: Update TVDB settings
|
||||
description: Updates TVDB settings with the provided values.
|
||||
summary: Update Metadata settings
|
||||
description: Updates Metadata settings with the provided values.
|
||||
tags:
|
||||
- settings
|
||||
requestBody:
|
||||
@@ -2597,14 +2617,14 @@ paths:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TvdbSettings'
|
||||
$ref: '#/components/schemas/MetadataSettings'
|
||||
responses:
|
||||
'200':
|
||||
description: 'Values were successfully updated'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TvdbSettings'
|
||||
$ref: '#/components/schemas/MetadataSettings'
|
||||
/settings/tvdb/test:
|
||||
post:
|
||||
summary: Test TVDB configuration
|
||||
|
||||
@@ -14,16 +14,13 @@ export const getMetadataProvider = async (
|
||||
return new TheMovieDb();
|
||||
}
|
||||
|
||||
if (
|
||||
mediaType == 'tv' &&
|
||||
settings.metadataSettings.tvShow == IndexerType.TVDB
|
||||
) {
|
||||
if (mediaType == 'tv' && settings.metadataType.tv == IndexerType.TVDB) {
|
||||
return await Tvdb.getInstance();
|
||||
}
|
||||
|
||||
if (
|
||||
mediaType == 'anime' &&
|
||||
settings.metadataSettings.anime == IndexerType.TVDB
|
||||
settings.metadataType.anime == IndexerType.TVDB
|
||||
) {
|
||||
return await Tvdb.getInstance();
|
||||
}
|
||||
|
||||
@@ -87,9 +87,9 @@ class Tvdb extends ExternalAPI implements TvShowIndexer {
|
||||
return this.instance;
|
||||
}
|
||||
|
||||
public async test(): Promise<TvdbLoginResponse> {
|
||||
public async test(): Promise<void> {
|
||||
try {
|
||||
return await this.get<TvdbLoginResponse>('/en/445009', {});
|
||||
await this.login();
|
||||
} catch (error) {
|
||||
this.handleError('Login failed', error);
|
||||
throw error;
|
||||
|
||||
@@ -106,8 +106,8 @@ export enum IndexerType {
|
||||
}
|
||||
|
||||
export interface MetadataSettings {
|
||||
tvShow: IndexerType;
|
||||
anime: IndexerType;
|
||||
settings: MetadataTypeSettings;
|
||||
providers: ProviderSettings;
|
||||
}
|
||||
|
||||
export interface TvdbSettings {
|
||||
@@ -115,6 +115,14 @@ export interface TvdbSettings {
|
||||
pin?: string;
|
||||
}
|
||||
|
||||
export interface ProviderSettings {
|
||||
tvdb: TvdbSettings;
|
||||
}
|
||||
export interface MetadataTypeSettings {
|
||||
tv: IndexerType;
|
||||
anime: IndexerType;
|
||||
}
|
||||
|
||||
export interface ProxySettings {
|
||||
enabled: boolean;
|
||||
hostname: string;
|
||||
@@ -428,8 +436,16 @@ class Settings {
|
||||
},
|
||||
tautulli: {},
|
||||
metadataSettings: {
|
||||
tvShow: IndexerType.TMDB,
|
||||
anime: IndexerType.TVDB,
|
||||
settings: {
|
||||
tv: IndexerType.TMDB,
|
||||
anime: IndexerType.TVDB,
|
||||
},
|
||||
providers: {
|
||||
tvdb: {
|
||||
apiKey: '',
|
||||
pin: '',
|
||||
},
|
||||
},
|
||||
},
|
||||
tvdb: {
|
||||
apiKey: '',
|
||||
@@ -645,6 +661,14 @@ class Settings {
|
||||
this.data.tvdb = data;
|
||||
}
|
||||
|
||||
get metadataType(): MetadataTypeSettings {
|
||||
return this.data.metadataSettings.settings;
|
||||
}
|
||||
|
||||
set metadataType(data: MetadataTypeSettings) {
|
||||
this.data.metadataSettings.settings = data;
|
||||
}
|
||||
|
||||
get radarr(): RadarrSettings[] {
|
||||
return this.data.radarr;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ import { rescheduleJob } from 'node-schedule';
|
||||
import path from 'path';
|
||||
import semver from 'semver';
|
||||
import { URL } from 'url';
|
||||
import tvdbRoutes from './metadata';
|
||||
import metadataRoutes from './metadata';
|
||||
import notificationRoutes from './notifications';
|
||||
import radarrRoutes from './radarr';
|
||||
import sonarrRoutes from './sonarr';
|
||||
@@ -50,7 +50,7 @@ settingsRoutes.use('/notifications', notificationRoutes);
|
||||
settingsRoutes.use('/radarr', radarrRoutes);
|
||||
settingsRoutes.use('/sonarr', sonarrRoutes);
|
||||
settingsRoutes.use('/discover', discoverSettingRoutes);
|
||||
settingsRoutes.use('/tvdb', tvdbRoutes);
|
||||
settingsRoutes.use('/metadatas', metadataRoutes);
|
||||
|
||||
const filteredMainSettings = (
|
||||
user: User,
|
||||
|
||||
@@ -1,30 +1,24 @@
|
||||
import Tvdb from '@server/api/tvdb';
|
||||
import { getSettings, type TvdbSettings } from '@server/lib/settings';
|
||||
import { getSettings, type MetadataSettings } from '@server/lib/settings';
|
||||
import logger from '@server/logger';
|
||||
import { Router } from 'express';
|
||||
|
||||
const tvdbRoutes = Router();
|
||||
const metadataRoutes = Router();
|
||||
|
||||
export interface MetadataSettings {
|
||||
tvdb: boolean;
|
||||
}
|
||||
|
||||
tvdbRoutes.get('/', (_req, res) => {
|
||||
metadataRoutes.get('/', (_req, res) => {
|
||||
const settings = getSettings();
|
||||
|
||||
res.status(200).json({
|
||||
tvdb: settings.tvdb,
|
||||
});
|
||||
res.status(200).json(settings.metadataSettings);
|
||||
});
|
||||
|
||||
tvdbRoutes.put('/', (req, res) => {
|
||||
metadataRoutes.put('/', (req, res) => {
|
||||
const settings = getSettings();
|
||||
|
||||
const body = req.body as TvdbSettings;
|
||||
const body = req.body as MetadataSettings;
|
||||
|
||||
settings.tvdb = {
|
||||
apiKey: body.apiKey,
|
||||
pin: body.pin,
|
||||
settings.metadataSettings = {
|
||||
providers: body.providers,
|
||||
settings: body.settings,
|
||||
};
|
||||
settings.save();
|
||||
|
||||
@@ -33,11 +27,13 @@ tvdbRoutes.put('/', (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
tvdbRoutes.post('/test', async (req, res, next) => {
|
||||
metadataRoutes.post('/test', async (req, res, next) => {
|
||||
try {
|
||||
const tvdb = await Tvdb.getInstance();
|
||||
await tvdb.test();
|
||||
return res.status(200).json({ message: 'Successfully connected to Tvdb' });
|
||||
|
||||
// TODO: add tmdb test
|
||||
return res.status(200).json({ tvdb: true });
|
||||
} catch (e) {
|
||||
logger.error('Failed to test Tvdb', {
|
||||
label: 'Tvdb',
|
||||
@@ -48,4 +44,4 @@ tvdbRoutes.post('/test', async (req, res, next) => {
|
||||
}
|
||||
});
|
||||
|
||||
export default tvdbRoutes;
|
||||
export default metadataRoutes;
|
||||
|
||||
@@ -5,7 +5,6 @@ import SettingsBadge from '@app/components/Settings/SettingsBadge';
|
||||
import globalMessages from '@app/i18n/globalMessages';
|
||||
import defineMessages from '@app/utils/defineMessages';
|
||||
import { ArrowDownOnSquareIcon, BeakerIcon } from '@heroicons/react/24/outline';
|
||||
import type { MetadataSettings } from '@server/routes/settings/metadata';
|
||||
import { Field, Form, Formik } from 'formik';
|
||||
import { useState } from 'react';
|
||||
import { useIntl } from 'react-intl';
|
||||
@@ -15,12 +14,42 @@ import useSWR from 'swr';
|
||||
const messages = defineMessages('components.Settings', {
|
||||
general: 'General',
|
||||
settings: 'Settings',
|
||||
enable: 'Enable',
|
||||
apiKey: 'Api Key',
|
||||
pin: 'Pin',
|
||||
enableTip:
|
||||
'Enable Tvdb (only for season and episode).' +
|
||||
' Due to a limitation of the api used, only English is available.',
|
||||
});
|
||||
|
||||
interface providerResponse {
|
||||
tvdb: boolean;
|
||||
tmdb: boolean;
|
||||
}
|
||||
|
||||
enum indexerType {
|
||||
TMDB,
|
||||
TVDB,
|
||||
}
|
||||
|
||||
interface metadataSettings {
|
||||
settings: metadataTypeSettings;
|
||||
providers: providerSettings;
|
||||
}
|
||||
|
||||
interface metadataTypeSettings {
|
||||
tv: indexerType;
|
||||
anime: indexerType;
|
||||
}
|
||||
|
||||
interface providerSettings {
|
||||
tvdb: tvdbSettings;
|
||||
}
|
||||
|
||||
interface tvdbSettings {
|
||||
apiKey: string;
|
||||
pin: string;
|
||||
}
|
||||
|
||||
const SettingsMetadata = () => {
|
||||
const intl = useIntl();
|
||||
const [isTesting, setIsTesting] = useState(false);
|
||||
@@ -28,35 +57,41 @@ const SettingsMetadata = () => {
|
||||
const { addToast } = useToasts();
|
||||
|
||||
const testConnection = async () => {
|
||||
const response = await fetch('/api/v1/settings/tvdb/test', {
|
||||
const response = await fetch('/api/v1/settings/metadats/test', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
const body = (await response.json()) as providerResponse;
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to test Tvdb');
|
||||
console.log(body);
|
||||
}
|
||||
};
|
||||
|
||||
const saveSettings = async (value: MetadataSettings) => {
|
||||
const response = await fetch('/api/v1/settings/tvdb', {
|
||||
const saveSettings = async (
|
||||
value: metadataSettings
|
||||
): Promise<metadataSettings> => {
|
||||
const response = await fetch('/api/v1/settings/metadatas', {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
tvdb: value.tvdb,
|
||||
}),
|
||||
body: JSON.stringify(value),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to save Tvdb settings');
|
||||
throw new Error('Failed to save Metadata settings');
|
||||
}
|
||||
|
||||
return (await response.json()) as metadataSettings;
|
||||
};
|
||||
|
||||
const { data, error } = useSWR<MetadataSettings>('/api/v1/settings/tvdb');
|
||||
const { data, error } = useSWR<metadataSettings>(
|
||||
'/api/v1/settings/metadatas'
|
||||
);
|
||||
|
||||
if (!data && !error) {
|
||||
return <LoadingSpinner />;
|
||||
@@ -71,32 +106,43 @@ const SettingsMetadata = () => {
|
||||
]}
|
||||
/>
|
||||
<div className="mb-6">
|
||||
me
|
||||
<h3 className="heading">{'Metadata'}</h3>
|
||||
<p className="description">{'Settings for metadata indexer'}</p>
|
||||
</div>
|
||||
<div className="section">
|
||||
<Formik
|
||||
initialValues={{
|
||||
enable: data?.tvdb ?? false,
|
||||
settings: data?.settings ?? {
|
||||
tv: indexerType.TMDB,
|
||||
anime: indexerType.TMDB,
|
||||
},
|
||||
providers: data?.providers ?? {
|
||||
tvdb: {
|
||||
apiKey: '',
|
||||
pin: '',
|
||||
},
|
||||
},
|
||||
}}
|
||||
onSubmit={async (values) => {
|
||||
try {
|
||||
setIsTesting(true);
|
||||
await testConnection();
|
||||
setIsTesting(false);
|
||||
} catch (e) {
|
||||
addToast('Tvdb connection error, check your credentials', {
|
||||
appearance: 'error',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await saveSettings({
|
||||
tvdb: values.enable ?? false,
|
||||
});
|
||||
await saveSettings(
|
||||
data ?? {
|
||||
providers: {
|
||||
tvdb: {
|
||||
apiKey: '',
|
||||
pin: '',
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
tv: indexerType.TMDB,
|
||||
anime: indexerType.TMDB,
|
||||
},
|
||||
}
|
||||
);
|
||||
if (data) {
|
||||
data.tvdb = values.enable;
|
||||
data.providers = values.providers;
|
||||
data.settings = values.settings;
|
||||
}
|
||||
} catch (e) {
|
||||
addToast('Failed to save Tvdb settings', { appearance: 'error' });
|
||||
@@ -111,7 +157,7 @@ const SettingsMetadata = () => {
|
||||
<div className="form-row">
|
||||
<label htmlFor="trustProxy" className="checkbox-label">
|
||||
<span className="mr-2">
|
||||
{intl.formatMessage(messages.enable)}
|
||||
{intl.formatMessage(messages.apiKey)}
|
||||
</span>
|
||||
<SettingsBadge badgeType="experimental" />
|
||||
|
||||
@@ -121,17 +167,26 @@ const SettingsMetadata = () => {
|
||||
</label>
|
||||
<div className="form-input-area">
|
||||
<Field
|
||||
data-testid="tvdb-enable"
|
||||
type="checkbox"
|
||||
id="enable"
|
||||
name="enable"
|
||||
data-testid="tvdb-apiKey"
|
||||
type="text"
|
||||
id="apiKey"
|
||||
name="apiKey"
|
||||
onChange={() => {
|
||||
setFieldValue('enable', !values.enable);
|
||||
setFieldValue('apiKey', values.providers.tvdb.apiKey);
|
||||
addToast('Tvdb connection successful', {
|
||||
appearance: 'success',
|
||||
});
|
||||
}}
|
||||
/>
|
||||
<Field
|
||||
data-testid="tvdb-pin"
|
||||
type="text"
|
||||
id="pin"
|
||||
name="pin"
|
||||
onChange={() => {
|
||||
setFieldValue('pin', values.providers.tvdb.pin);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="error"></div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user