Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rules): Introduced Radarr & Sonarr rules to retrieve file locations #814

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/3-using-maintainerr/1-rules/Glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, this will be the path inside the container.

- Key: Radarr.filePath
- Availability: movies
- Type: text

### Sonarr

#### Date added
Expand Down Expand Up @@ -418,6 +426,15 @@ 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, this will be the path inside the container.

- Key: Sonarr.filePath
- Availability: movies, seasons, episodes
- Type: text

### Overseerr

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export interface RadarrMovieFile {
quality: RadarrQualityContainer;
size: number;
mediaInfo: RadarrMediaInfo;
path: string;
}

export interface RadarrQualityContainer {
Expand Down
14 changes: 14 additions & 0 deletions server/src/modules/rules/constants/rules.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
},
{
Expand Down Expand Up @@ -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,
],
},
{
Expand Down
9 changes: 7 additions & 2 deletions server/src/modules/rules/getter/radarr-getter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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];
Expand Down
11 changes: 7 additions & 4 deletions server/src/modules/rules/getter/sonarr-getter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
}
Loading