diff --git a/overseerr-api.yml b/overseerr-api.yml index b4047e52f..f59ca11af 100644 --- a/overseerr-api.yml +++ b/overseerr-api.yml @@ -55,6 +55,9 @@ components: plexToken: type: string readOnly: true + jellyfinAuthToken: + type: string + readOnly: true userType: type: integer example: 1 @@ -124,6 +127,9 @@ components: localLogin: type: boolean example: true + mediaServerType: + type: string + example: 'PLEX | JELLYFIN' defaultPermissions: type: number example: 32 @@ -292,6 +298,47 @@ components: - provides - owned - connection + JellyfinLibrary: + type: object + properties: + id: + type: string + name: + type: string + example: Movies + enabled: + type: boolean + example: false + required: + - id + - name + - enabled + JellyfinSettings: + type: object + properties: + name: + type: string + example: 'Main Server' + readOnly: true + hostname: + type: string + example: 'http://my.jellyfin.host' + adminUser: + type: string + example: 'admin' + adminPass: + type: string + example: 'mypassword' + libraries: + type: array + readOnly: true + items: + $ref: '#/components/schemas/JellyfinLibrary' + serverID: + type: string + readOnly: true + required: + - hostname RadarrSettings: type: object properties: @@ -1630,6 +1677,136 @@ paths: application/json: schema: $ref: '#/components/schemas/MainSettings' + /settings/jellyfin: + get: + summary: Get Jellyfin settings + description: Retrieves current Jellyfin settings. + tags: + - settings + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/JellyfinSettings' + post: + summary: Update Jellyfin settings + description: Updates Jellyfin settings with the provided values. + tags: + - settings + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/JellyfinSettings' + responses: + '200': + description: 'Values were successfully updated' + content: + application/json: + schema: + $ref: '#/components/schemas/JellyfinSettings' + /settings/jellyfin/library: + get: + summary: Get Jellyfin libraries + description: Returns a list of Jellyfin libraries in a JSON array. + tags: + - settings + parameters: + - in: query + name: sync + description: Syncs the current libraries with the current Jellyfin server + schema: + type: string + nullable: true + - in: query + name: enable + explode: false + allowReserved: true + description: Comma separated list of libraries to enable. Any libraries not passed will be disabled! + schema: + type: string + nullable: true + responses: + '200': + description: 'Jellyfin libraries returned' + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/JellyfinLibrary' + /settings/jellyfin/sync: + get: + summary: Get status of full Jellyfin library sync + description: Returns sync progress in a JSON array. + tags: + - settings + responses: + '200': + description: Status of Jellyfin sync + content: + application/json: + schema: + type: object + properties: + running: + type: boolean + example: false + progress: + type: number + example: 0 + total: + type: number + example: 100 + currentLibrary: + $ref: '#/components/schemas/JellyfinLibrary' + libraries: + type: array + items: + $ref: '#/components/schemas/JellyfinLibrary' + post: + summary: Start full Jellyfin library sync + description: Runs a full Jellyfin library sync and returns the progress in a JSON array. + tags: + - settings + requestBody: + content: + application/json: + schema: + type: object + properties: + cancel: + type: boolean + example: false + start: + type: boolean + example: false + responses: + '200': + description: Status of Jellyfin sync + content: + application/json: + schema: + type: object + properties: + running: + type: boolean + example: false + progress: + type: number + example: 0 + total: + type: number + example: 100 + currentLibrary: + $ref: '#/components/schemas/JellyfinLibrary' + libraries: + type: array + items: + $ref: '#/components/schemas/JellyfinLibrary' /settings/plex: get: summary: Get Plex settings @@ -2638,6 +2815,36 @@ paths: type: string required: - authToken + /auth/jellyfin: + post: + summary: Sign in using a Jellyfin username and password + description: Takes the user's username and password to log the user in. Generates a session cookie for use in further requests. If the user does not exist, and there are no other users, then a user will be created with full admin privileges. If a user logs in with access to the main Plex server, they will also have an account created, but without any permissions. + security: [] + tags: + - auth + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/User' + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + username: + type: string + password: + type: string + hostname: + type: string + required: + - username + - password /auth/local: post: summary: Sign in using a local account diff --git a/server/index.ts b/server/index.ts index cb6d2332c..08e82481e 100644 --- a/server/index.ts +++ b/server/index.ts @@ -120,8 +120,7 @@ app }).connect(sessionRespository) as Store, }) ); - //const apiDocs = YAML.load(API_SPEC_PATH); - /* + const apiDocs = YAML.load(API_SPEC_PATH); server.use('/api-docs', swaggerUi.serve, swaggerUi.setup(apiDocs)); server.use( OpenApiValidator.middleware({ @@ -134,7 +133,7 @@ app * OpenAPI validator. Otherwise, they are treated as objects instead of strings * and response validation will fail */ - /* + server.use((_req, res, next) => { const original = res.json; res.json = function jsonp(json) { @@ -142,7 +141,6 @@ app }; next(); }); - */ server.use('/api/v1', routes); server.get('*', (req, res) => handle(req, res)); server.use( diff --git a/server/job/jellyfinsync/index.ts b/server/job/jellyfinsync/index.ts index b1a7e44fa..35d0f75ba 100644 --- a/server/job/jellyfinsync/index.ts +++ b/server/job/jellyfinsync/index.ts @@ -127,7 +127,7 @@ class JobJellyfinSync { (hasOtherResolution || (has4k && !this.enable4kMovie)) && existing.jellyfinMediaID !== metadata.Id ) { - existing.jellyfinMediaID !== metadata.Id; + existing.jellyfinMediaID = metadata.Id; changedExisting = true; } diff --git a/server/routes/settings/index.ts b/server/routes/settings/index.ts index 8f51b721b..b48162b77 100644 --- a/server/routes/settings/index.ts +++ b/server/routes/settings/index.ts @@ -227,7 +227,9 @@ settingsRoutes.post('/plex/sync', (req, res) => { settingsRoutes.get('/jellyfin', (_req, res) => { const settings = getSettings(); - res.status(200).json(settings.jellyfin); + + //DO NOT RETURN ADMIN USER CREDENTIALS!! + res.status(200).json(omit(settings.jellyfin, ['adminUser', 'adminPass'])); }); settingsRoutes.post('/jellyfin', (req, res) => {