diff --git a/server/src/modules/api/lib/plexApi.ts b/server/src/modules/api/lib/plexApi.ts index a3f2467a..dc07d5ea 100644 --- a/server/src/modules/api/lib/plexApi.ts +++ b/server/src/modules/api/lib/plexApi.ts @@ -13,8 +13,8 @@ class PlexApi extends NodePlexAPI { this.cache = cacheManager.getCache('plexguid'); } - async query(options): Promise { - return this.queryWithCache(options, true); + async query(options, docache: boolean = true): Promise { + return this.queryWithCache(options, docache); } /** @@ -68,7 +68,7 @@ class PlexApi extends NodePlexAPI { return result as unknown as T; } - async queryWithCache(options, doCache: boolean): Promise { + async queryWithCache(options, doCache: boolean = true): Promise { if (typeof options === 'string') { options = { uri: options, diff --git a/server/src/modules/api/plex-api/plex-api.service.ts b/server/src/modules/api/plex-api/plex-api.service.ts index 47bf0b7f..52826825 100644 --- a/server/src/modules/api/plex-api/plex-api.service.ts +++ b/server/src/modules/api/plex-api/plex-api.service.ts @@ -30,6 +30,7 @@ import { EPlexDataType } from './enums/plex-data-type-enum'; import axios from 'axios'; import PlexApi from '../lib/plexApi'; import PlexTvApi from '../lib/plextvApi'; +import cacheManager from '../../api/lib/cache'; @Injectable() export class PlexApiService { @@ -237,6 +238,7 @@ export class PlexApiService { public async getMetadata( key: string, options: { includeChildren?: boolean } = {}, + useCache: boolean = true, ): Promise { try { const response = await this.plexClient.query( @@ -245,6 +247,7 @@ export class PlexApiService { ? '?includeChildren=1&includeExternalMedia=1&asyncAugmentMetadata=1&asyncCheckFiles=1&asyncRefreshAnalysis=1' : '' }`, + useCache, ); if (response) { return response.MediaContainer.Metadata[0]; @@ -260,6 +263,14 @@ export class PlexApiService { } } + public resetMetadataCache(mediaId: string) { + cacheManager.getCache('plexguid').data.del( + JSON.stringify({ + uri: `/library/metadata/${mediaId}`, + }), + ); + } + public async getDiscoverDataUserState( metaDataRatingKey: string, ): Promise { diff --git a/server/src/modules/rules/getter/plex-getter.service.ts b/server/src/modules/rules/getter/plex-getter.service.ts index f7ec2311..56427c56 100644 --- a/server/src/modules/rules/getter/plex-getter.service.ts +++ b/server/src/modules/rules/getter/plex-getter.service.ts @@ -100,8 +100,8 @@ export class PlexGetterService { ? metadata.Collection.filter( (el) => el.tag.toLowerCase().trim() !== - (ruleGroup.manualCollectionName - ? ruleGroup.manualCollectionName + (ruleGroup?.collection?.manualCollection + ? ruleGroup.collection.manualCollectionName : ruleGroup.name ) .toLowerCase() diff --git a/server/src/modules/rules/rules.service.ts b/server/src/modules/rules/rules.service.ts index 3c5b9fa5..72b310da 100644 --- a/server/src/modules/rules/rules.service.ts +++ b/server/src/modules/rules/rules.service.ts @@ -939,6 +939,7 @@ export class RulesService { rulegroupId: number, mediaId: string, ): Promise { + this.plexApi.resetMetadataCache(mediaId); const mediaResp = await this.plexApi.getMetadata(mediaId); const group = await this.getRuleGroupById(rulegroupId); if (group && mediaResp) {