{
  "title": "Seerr",
  "icon": "film.stack",
  "sources": {
    "waiting": {
      "url": "http://192.0.2.50:5055",
      "secret": "seerr",
      "auth": {
        "type": "header",
        "name": "X-Api-Key"
      },
      "every": "2m",
      "requests": {
        "pending": "/api/v1/request?filter=pending&take=20&sort=added",
        "titles": {
          "path": "/api/v1/{media.mediaType}/{media.tmdbId}",
          "each_row": {
            "from": "pending.results",
            "key": "id",
            "max": 20,
            "pick": [
              "title",
              "name",
              "releaseDate",
              "firstAirDate",
              "posterPath"
            ],
            "keep": "6h"
          }
        },
        "public": "/api/v1/settings/public"
      },
      "derive": [
        {
          "name": "posters",
          "value": {
            "if": {
              "all": [
                {
                  "path": "public.cacheImages",
                  "not": true
                },
                {
                  "path": "public.hideBlocklisted",
                  "exists": true
                }
              ]
            },
            "then": {
              "template": "off"
            },
            "else": {
              "template": "on"
            }
          }
        },
        {
          "name": "all_rows",
          "value": {
            "each": "pending.results",
            "lookup": {
              "from": "titles",
              "by": "key",
              "on": "id",
              "as": "t"
            },
            "sort": {
              "by": [
                "createdAt",
                "id"
              ]
            },
            "fields": {
              "id": "id",
              "type": "type",
              "status": "status",
              "title": {
                "if": {
                  "path": "type",
                  "equals": "tv"
                },
                "then": "t.answer.name",
                "else": "t.answer.title"
              },
              "year": {
                "if": {
                  "path": "type",
                  "equals": "tv"
                },
                "then": {
                  "path": "t.answer.firstAirDate",
                  "match": "^([0-9]{4})"
                },
                "else": {
                  "path": "t.answer.releaseDate",
                  "match": "^([0-9]{4})"
                }
              },
              "who": {
                "path": "requestedBy.displayName",
                "default": "Someone"
              },
              "when": {
                "template": "{createdAt|ago}"
              },
              "hd4k": {
                "path": "is4k",
                "values": {
                  "true": "4K"
                },
                "default": ""
              },
              "seasons": {
                "join": "seasonNumber",
                "of": "seasons",
                "separator": ", "
              },
              "season_count": {
                "count": "seasons"
              },
              "media": {
                "if": {
                  "path": "is4k",
                  "equals": true
                },
                "then": {
                  "path": "media.status4k",
                  "values": {
                    "2": "Approved",
                    "3": "Processing",
                    "4": "Partly available",
                    "5": "Available"
                  },
                  "default": "Approved"
                },
                "else": {
                  "path": "media.status",
                  "values": {
                    "2": "Approved",
                    "3": "Processing",
                    "4": "Partly available",
                    "5": "Available"
                  },
                  "default": "Approved"
                }
              },
              "poster": {
                "if": {
                  "path": "t.answer.posterPath",
                  "exists": true
                },
                "then": {
                  "template": "/imageproxy/tmdb/t/p/w300_and_h450_face{t.answer.posterPath}"
                },
                "else": {
                  "template": ""
                }
              },
              "icon": {
                "if": {
                  "path": "type",
                  "equals": "tv"
                },
                "then": {
                  "template": "tv"
                },
                "else": {
                  "template": "film"
                }
              },
              "art": {
                "template": "on"
              },
              "no_art": {
                "template": "off"
              }
            }
          }
        },
        {
          "name": "rows_art",
          "value": {
            "each": "all_rows",
            "where": {
              "path": "art",
              "equals": {
                "answer": "posters"
              }
            },
            "fields": {
              "id": "id",
              "type": "type",
              "status": "status",
              "title": "title",
              "year": "year",
              "who": "who",
              "when": "when",
              "hd4k": "hd4k",
              "seasons": "seasons",
              "season_count": "season_count",
              "media": "media",
              "icon": "icon",
              "image": "poster"
            }
          }
        },
        {
          "name": "rows_plain",
          "value": {
            "each": "all_rows",
            "where": {
              "path": "no_art",
              "equals": {
                "answer": "posters"
              }
            },
            "fields": {
              "id": "id",
              "type": "type",
              "status": "status",
              "title": "title",
              "year": "year",
              "who": "who",
              "when": "when",
              "hd4k": "hd4k",
              "seasons": "seasons",
              "season_count": "season_count",
              "media": "media",
              "icon": "icon",
              "image": {
                "template": ""
              }
            }
          }
        },
        {
          "name": "rows_shown",
          "value": {
            "count": "all_rows"
          }
        }
      ]
    },
    "server": {
      "url": "http://192.0.2.50:5055",
      "secret": "seerr",
      "auth": {
        "type": "header",
        "name": "X-Api-Key"
      },
      "every": "5m",
      "requests": {
        "count": "/api/v1/request/count",
        "issues": "/api/v1/issue/count",
        "status": "/api/v1/status",
        "public": "/api/v1/settings/public",
        "recent": "/api/v1/request?filter=all&take=20&sort=modified",
        "recent_titles": {
          "path": "/api/v1/{media.mediaType}/{media.tmdbId}",
          "each_row": {
            "from": "recent.results",
            "key": "id",
            "max": 20,
            "pick": [
              "title",
              "name",
              "releaseDate",
              "firstAirDate",
              "posterPath"
            ],
            "keep": "6h"
          }
        }
      },
      "derive": [
        {
          "name": "posters",
          "value": {
            "if": {
              "all": [
                {
                  "path": "public.cacheImages",
                  "not": true
                },
                {
                  "path": "public.hideBlocklisted",
                  "exists": true
                }
              ]
            },
            "then": {
              "template": "off"
            },
            "else": {
              "template": "on"
            }
          }
        },
        {
          "name": "all_rows",
          "value": {
            "each": "recent.results",
            "lookup": {
              "from": "recent_titles",
              "by": "key",
              "on": "id",
              "as": "t"
            },
            "where": {
              "path": "status",
              "not": 1
            },
            "limit": 4,
            "fields": {
              "id": "id",
              "type": "type",
              "status": "status",
              "title": {
                "if": {
                  "path": "type",
                  "equals": "tv"
                },
                "then": "t.answer.name",
                "else": "t.answer.title"
              },
              "year": {
                "if": {
                  "path": "type",
                  "equals": "tv"
                },
                "then": {
                  "path": "t.answer.firstAirDate",
                  "match": "^([0-9]{4})"
                },
                "else": {
                  "path": "t.answer.releaseDate",
                  "match": "^([0-9]{4})"
                }
              },
              "who": {
                "path": "requestedBy.displayName",
                "default": "Someone"
              },
              "when": {
                "template": "{updatedAt|ago}"
              },
              "hd4k": {
                "path": "is4k",
                "values": {
                  "true": "4K"
                },
                "default": ""
              },
              "seasons": {
                "join": "seasonNumber",
                "of": "seasons",
                "separator": ", "
              },
              "season_count": {
                "count": "seasons"
              },
              "media": {
                "if": {
                  "path": "is4k",
                  "equals": true
                },
                "then": {
                  "path": "media.status4k",
                  "values": {
                    "2": "Approved",
                    "3": "Processing",
                    "4": "Partly available",
                    "5": "Available"
                  },
                  "default": "Approved"
                },
                "else": {
                  "path": "media.status",
                  "values": {
                    "2": "Approved",
                    "3": "Processing",
                    "4": "Partly available",
                    "5": "Available"
                  },
                  "default": "Approved"
                }
              },
              "poster": {
                "if": {
                  "path": "t.answer.posterPath",
                  "exists": true
                },
                "then": {
                  "template": "/imageproxy/tmdb/t/p/w300_and_h450_face{t.answer.posterPath}"
                },
                "else": {
                  "template": ""
                }
              },
              "icon": {
                "if": {
                  "path": "type",
                  "equals": "tv"
                },
                "then": {
                  "template": "tv"
                },
                "else": {
                  "template": "film"
                }
              },
              "art": {
                "template": "on"
              },
              "no_art": {
                "template": "off"
              }
            }
          }
        },
        {
          "name": "rows_art",
          "value": {
            "each": "all_rows",
            "where": {
              "path": "art",
              "equals": {
                "answer": "posters"
              }
            },
            "fields": {
              "id": "id",
              "type": "type",
              "status": "status",
              "title": "title",
              "year": "year",
              "who": "who",
              "when": "when",
              "hd4k": "hd4k",
              "seasons": "seasons",
              "season_count": "season_count",
              "media": "media",
              "icon": "icon",
              "image": "poster"
            }
          }
        },
        {
          "name": "rows_plain",
          "value": {
            "each": "all_rows",
            "where": {
              "path": "no_art",
              "equals": {
                "answer": "posters"
              }
            },
            "fields": {
              "id": "id",
              "type": "type",
              "status": "status",
              "title": "title",
              "year": "year",
              "who": "who",
              "when": "when",
              "hd4k": "hd4k",
              "seasons": "seasons",
              "season_count": "season_count",
              "media": "media",
              "icon": "icon",
              "image": {
                "template": ""
              }
            }
          }
        },
        {
          "name": "rows_shown",
          "value": {
            "count": "all_rows"
          }
        }
      ]
    }
  },
  "cards": [
    {
      "id": "waiting",
      "type": "list",
      "label": "Waiting",
      "max_items": 7,
      "image_shape": "poster",
      "items": [],
      "source": {
        "ref": "waiting",
        "empty": {
          "text": "No requests waiting",
          "when": {
            "path": "pending.pageInfo.results",
            "equals": 0
          }
        },
        "map": {
          "label": {
            "if": {
              "path": "pending.pageInfo.results",
              "gt": 20
            },
            "then": {
              "template": "{rows_shown} of {pending.pageInfo.results} waiting"
            },
            "else": {
              "if": {
                "path": "pending.pageInfo.results",
                "gt": 0
              },
              "then": {
                "template": "{pending.pageInfo.results} waiting"
              },
              "else": {
                "template": "Waiting"
              }
            }
          },
          "items": {
            "each": [
              "rows_art",
              "rows_plain"
            ],
            "fields": {
              "key": "id",
              "text": {
                "if": {
                  "path": "title",
                  "exists": true
                },
                "then": {
                  "if": {
                    "path": "year",
                    "exists": true
                  },
                  "then": {
                    "template": "{title} ({year|raw})"
                  },
                  "else": {
                    "template": "{title}"
                  }
                },
                "else": {
                  "if": {
                    "path": "type",
                    "equals": "tv"
                  },
                  "then": {
                    "template": "A show"
                  },
                  "else": {
                    "template": "A movie"
                  }
                }
              },
              "subtitle": {
                "template": "{who} · {when}"
              },
              "detail": {
                "if": {
                  "path": "hd4k",
                  "equals": "4K"
                },
                "then": {
                  "if": {
                    "path": "season_count",
                    "gt": 3
                  },
                  "then": {
                    "template": "4K · {season_count} seasons"
                  },
                  "else": {
                    "if": {
                      "path": "season_count",
                      "gt": 1
                    },
                    "then": {
                      "template": "4K · Seasons {seasons}"
                    },
                    "else": {
                      "if": {
                        "path": "season_count",
                        "equals": 1
                      },
                      "then": {
                        "template": "4K · Season {seasons}"
                      },
                      "else": {
                        "template": "4K"
                      }
                    }
                  }
                },
                "else": {
                  "if": {
                    "path": "season_count",
                    "gt": 3
                  },
                  "then": {
                    "template": "{season_count} seasons"
                  },
                  "else": {
                    "if": {
                      "path": "season_count",
                      "gt": 1
                    },
                    "then": {
                      "template": "Seasons {seasons}"
                    },
                    "else": {
                      "if": {
                        "path": "season_count",
                        "equals": 1
                      },
                      "then": {
                        "template": "Season {seasons}"
                      }
                    }
                  }
                }
              },
              "image": "image",
              "icon": "icon"
            }
          }
        }
      },
      "row_actions": [
        {
          "label": "Approve",
          "icon": "checkmark",
          "method": "POST",
          "path": "/api/v1/request/{id}/approve",
          "when": {
            "path": "title",
            "exists": true
          }
        },
        {
          "label": "Decline",
          "icon": "xmark",
          "method": "POST",
          "path": "/api/v1/request/{id}/decline",
          "confirm": {
            "message": "Decline {title} for {who}?",
            "button": "Decline"
          },
          "when": {
            "path": "title",
            "exists": true
          }
        }
      ]
    },
    {
      "id": "requests",
      "type": "facts",
      "label": "Requests",
      "source": {
        "ref": "server",
        "map": {
          "items[0].value": {
            "template": "{count.processing}"
          },
          "items[1].value": {
            "if": {
              "path": "status.updateAvailable",
              "equals": true
            },
            "then": {
              "template": "{status.version} · Update available"
            },
            "else": {
              "template": "{status.version}"
            }
          },
          "items[2].value": {
            "template": "{issues.open}"
          },
          "items[3].value": {
            "add": [
              "count.available",
              {
                "path": "count.completed",
                "default": 0
              }
            ]
          },
          "items[4].value": {
            "template": "{count.declined}"
          }
        }
      },
      "items": [
        {
          "key": "Processing",
          "value": "—"
        },
        {
          "key": "Version",
          "value": "—"
        },
        {
          "key": "Open issues",
          "value": "—"
        },
        {
          "key": "Available",
          "value": "—"
        },
        {
          "key": "Declined",
          "value": "—"
        }
      ]
    },
    {
      "id": "recent",
      "type": "list",
      "label": "Recent",
      "max_items": 4,
      "image_shape": "poster",
      "items": [],
      "source": {
        "ref": "server",
        "empty": {
          "text": "No other recent requests",
          "when": {
            "path": "rows_shown",
            "equals": 0
          }
        },
        "map": {
          "items": {
            "each": [
              "rows_art",
              "rows_plain"
            ],
            "fields": {
              "key": "id",
              "text": {
                "if": {
                  "path": "title",
                  "exists": true
                },
                "then": {
                  "if": {
                    "path": "year",
                    "exists": true
                  },
                  "then": {
                    "template": "{title} ({year|raw})"
                  },
                  "else": {
                    "template": "{title}"
                  }
                },
                "else": {
                  "if": {
                    "path": "type",
                    "equals": "tv"
                  },
                  "then": {
                    "template": "A show"
                  },
                  "else": {
                    "template": "A movie"
                  }
                }
              },
              "subtitle": {
                "template": "{who} · {when}"
              },
              "detail": {
                "path": "status",
                "values": {
                  "1": "Waiting",
                  "3": "Declined",
                  "4": "Failed"
                },
                "default": {
                  "template": "{media}"
                }
              },
              "image": "image",
              "icon": "icon"
            }
          }
        }
      },
      "row_actions": [
        {
          "label": "Retry",
          "icon": "arrow.uturn.forward",
          "method": "POST",
          "path": "/api/v1/request/{id}/retry",
          "when": {
            "path": "status",
            "equals": 4
          }
        }
      ]
    },
    {
      "id": "credit",
      "type": "facts",
      "items": [
        {
          "key": "Titles and posters",
          "value": "TMDB",
          "icon": "si:themoviedatabase",
          "url": "https://www.themoviedb.org"
        }
      ]
    }
  ]
}
