From bd37d517295753a6ba1133f9b7387db470c06991 Mon Sep 17 00:00:00 2001 From: jorenn92 Date: Mon, 29 Jan 2024 18:24:51 +0100 Subject: [PATCH 1/2] feat(rules): Introduced Radarr & Sonarr rules to retrieve file locations --- docs/3-using-maintainerr/1-rules/Glossary.md | 16 ++++++++++++++++ .../servarr-api/interfaces/radarr.interface.ts | 1 + .../modules/rules/constants/rules.constants.ts | 14 ++++++++++++++ .../rules/getter/radarr-getter.service.ts | 9 +++++++-- .../rules/getter/sonarr-getter.service.ts | 11 +++++++---- 5 files changed, 45 insertions(+), 6 deletions(-) diff --git a/docs/3-using-maintainerr/1-rules/Glossary.md b/docs/3-using-maintainerr/1-rules/Glossary.md index d8470216..77a291dd 100644 --- a/docs/3-using-maintainerr/1-rules/Glossary.md +++ b/docs/3-using-maintainerr/1-rules/Glossary.md @@ -313,6 +313,14 @@ The key is used for identification in Yaml rule files. - Availability: movies - Type: number +#### File - file path + +> The path of the file associated with the Radarr item. When using docker Radarr, this will be the path in the Radarr container. + +- Key: Radarr.filePath +- Availability: movies +- Type: text + ### Sonarr #### Date added @@ -418,6 +426,14 @@ The key is used for identification in Yaml rule files. - Key: Sonarr.part_of_latest_season - Availability: seasons, episodes - Type: boolean +- +#### Base file path + +> The base path on disk of the file associated with the Radarr item. When using docker Sonarr, this will be the path in the Sonarr container. + +- Key: Sonarr.filePath +- Availability: movies, seasons, episodes +- Type: text ### Overseerr diff --git a/server/src/modules/api/servarr-api/interfaces/radarr.interface.ts b/server/src/modules/api/servarr-api/interfaces/radarr.interface.ts index 7b2e02b7..46976eaf 100644 --- a/server/src/modules/api/servarr-api/interfaces/radarr.interface.ts +++ b/server/src/modules/api/servarr-api/interfaces/radarr.interface.ts @@ -88,6 +88,7 @@ export interface RadarrMovieFile { quality: RadarrQualityContainer; size: number; mediaInfo: RadarrMediaInfo; + path: string; } export interface RadarrQualityContainer { diff --git a/server/src/modules/rules/constants/rules.constants.ts b/server/src/modules/rules/constants/rules.constants.ts index 6e11ec41..fd51874f 100644 --- a/server/src/modules/rules/constants/rules.constants.ts +++ b/server/src/modules/rules/constants/rules.constants.ts @@ -407,6 +407,13 @@ export class RuleConstants { mediaType: MediaType.MOVIE, type: RuleType.NUMBER, } as Property, + { + id: 12, + name: 'filePath', + humanName: 'File - file path', + mediaType: MediaType.MOVIE, + type: RuleType.TEXT, + } as Property, ], }, { @@ -525,6 +532,13 @@ export class RuleConstants { type: RuleType.BOOL, showType: [EPlexDataType.EPISODES, EPlexDataType.SEASONS], } as Property, + { + id: 14, + name: 'filePath', + humanName: 'Base file path', + mediaType: MediaType.SHOW, + type: RuleType.TEXT, + } as Property, ], }, { diff --git a/server/src/modules/rules/getter/radarr-getter.service.ts b/server/src/modules/rules/getter/radarr-getter.service.ts index fd6a2aaf..29cf5741 100644 --- a/server/src/modules/rules/getter/radarr-getter.service.ts +++ b/server/src/modules/rules/getter/radarr-getter.service.ts @@ -53,8 +53,13 @@ export class RadarrGetterService { ? new Date(movieResponse.movieFile.dateAdded) : null; } + case 'filePath': { + return movieResponse?.movieFile?.path + ? movieResponse.movieFile.path + : null; + } case 'fileQuality': { - return movieResponse?.movieFile.quality.quality.resolution + return movieResponse?.movieFile?.quality?.quality?.resolution ? movieResponse.movieFile.quality.quality.resolution : null; } @@ -64,7 +69,7 @@ export class RadarrGetterService { : null; } case 'runTime': { - if (movieResponse?.movieFile.mediaInfo.runTime) { + if (movieResponse?.movieFile?.mediaInfo?.runTime) { const hms = movieResponse.movieFile.mediaInfo.runTime; const splitted = hms.split(':'); return +splitted[0] * 60 + +splitted[1]; diff --git a/server/src/modules/rules/getter/sonarr-getter.service.ts b/server/src/modules/rules/getter/sonarr-getter.service.ts index d6f39120..0b19233d 100644 --- a/server/src/modules/rules/getter/sonarr-getter.service.ts +++ b/server/src/modules/rules/getter/sonarr-getter.service.ts @@ -112,6 +112,9 @@ export class SonarrGetterService { : null; } } + case 'filePath': { + return showResponse?.path ? showResponse.path : null; + } case 'tags': { const tagIds = showResponse.tags; return (await this.servarrService.SonarrApi.getTags()) @@ -275,8 +278,8 @@ export class SonarrGetterService { epResp[0] && epResp[0].airDate === undefined ? false : s.statistics?.nextAiring !== undefined - ? s.statistics.previousAiring !== undefined - : true; + ? s.statistics.previousAiring !== undefined + : true; if (resp) return s; } @@ -315,7 +318,7 @@ export class SonarrGetterService { return libItem.Guid ? +libItem.Guid.find((el) => el.id.includes(guiID))?.id?.split('://')[1] : libItem.guid.includes(guiID) - ? +libItem.guid.split('://')[1].split('?')[0] - : undefined; + ? +libItem.guid.split('://')[1].split('?')[0] + : undefined; } } From 68fe1733ecf6723dba34b3be1ee648479e3dc5d1 Mon Sep 17 00:00:00 2001 From: jorenn92 Date: Mon, 29 Jan 2024 18:32:41 +0100 Subject: [PATCH 2/2] refactor: Small glossary improvement --- docs/3-using-maintainerr/1-rules/Glossary.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/3-using-maintainerr/1-rules/Glossary.md b/docs/3-using-maintainerr/1-rules/Glossary.md index 77a291dd..d4d137c6 100644 --- a/docs/3-using-maintainerr/1-rules/Glossary.md +++ b/docs/3-using-maintainerr/1-rules/Glossary.md @@ -315,7 +315,7 @@ The key is used for identification in Yaml rule files. #### File - file path -> The path of the file associated with the Radarr item. When using docker Radarr, this will be the path in the Radarr container. +> The path of the file associated with the Radarr item. When using Docker, this will be the path inside the container. - Key: Radarr.filePath - Availability: movies @@ -426,10 +426,11 @@ The key is used for identification in Yaml rule files. - Key: Sonarr.part_of_latest_season - Availability: seasons, episodes - Type: boolean -- +- + #### Base file path -> The base path on disk of the file associated with the Radarr item. When using docker Sonarr, this will be the path in the Sonarr container. +> The base path on disk of the file associated with the Radarr item. When using Docker, this will be the path inside the container. - Key: Sonarr.filePath - Availability: movies, seasons, episodes