Skip to content

Commit db5533f

Browse files
authored
Merge pull request #11 from varthe/filter-by-status
Ability to filter by 4k/non-4k only
2 parents d1e33b8 + 23870b6 commit db5533f

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ Define your Radarr and Sonarr instances in this section. You can name the instan
8383
Define your request filters in this section.
8484
8585
- **`media_type`**: Specifies the type of media, either `"movie"` or `"tv"`.
86+
- **`is_not_4k`**: Should only apply to non-4k requests
87+
- **`is_4k`**: Should only apply to 4k requests
8688
- **`conditions`**: A set of fields and values used to filter requests. Refer to [testData.js](https://github.com/varthe/Redirecterr/blob/main/testData.js) for examples of request objects. Each field within `conditions` can be:
8789
- A **single value**: Matches if the value is present in the request.
8890
- A **list of values**: Matches if any value in the list is present in the request.

configBuilder.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ const schema = {
5555
type: "string",
5656
enum: ["movie", "tv"],
5757
},
58+
is_not_4k: {
59+
type: "boolean",
60+
},
61+
is_4k: {
62+
type: "boolean",
63+
},
5864
conditions: {
5965
type: "object",
6066
additionalProperties: {

main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,12 @@ const matchValue = (filterValue, dataValue) => {
9090

9191
const findMatchingInstances = (webhook, data, filters) => {
9292
try {
93-
const matchingFilter = filters.find(({ media_type, conditions }) => {
93+
const matchingFilter = filters.find(({ media_type, is_not_4k, is_4k, conditions }) => {
9494
if (media_type !== webhook.media?.media_type) return false
9595

96+
if (is_not_4k && webhook.media?.status !== "PENDING") return false
97+
if (is_4k && webhook.media?.status4k !== "PENDING") return false
98+
9699
for (const [key, value] of Object.entries(conditions || {})) {
97100
const requestValue = data[key] || webhook.request?.[key]
98101
if (!requestValue) {

0 commit comments

Comments
 (0)