From a017ce408accb0f518820f7da8dd77037effffb2 Mon Sep 17 00:00:00 2001 From: Jorenn92 Date: Sun, 7 Jan 2024 19:02:31 +0100 Subject: [PATCH] refactor(rules): Added season & episode code to the 'labels' rule --- .../src/modules/rules/getter/plex-getter.service.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/server/src/modules/rules/getter/plex-getter.service.ts b/server/src/modules/rules/getter/plex-getter.service.ts index 87af5122..7d947498 100644 --- a/server/src/modules/rules/getter/plex-getter.service.ts +++ b/server/src/modules/rules/getter/plex-getter.service.ts @@ -78,7 +78,18 @@ export class PlexGetterService { return count ? count.length : 0; } case 'labels': { - return metadata.Label ? metadata.Label.map(l => l.tag) : [] + const item = + libItem.type === 'episode' + ? ((await this.plexApi.getMetadata( + libItem.grandparentRatingKey, + )) as unknown as PlexLibraryItem) + : libItem.type === 'season' + ? ((await this.plexApi.getMetadata( + libItem.parentRatingKey, + )) as unknown as PlexLibraryItem) + : metadata; + + return item.Label ? item.Label.map(l => l.tag) : [] } case 'collections': { // fetch metadata because collections in plexLibrary object are wrong