From fc7b5d672c8aedd79709047efe15edec4a39963c Mon Sep 17 00:00:00 2001 From: craggles17 Date: Wed, 27 Dec 2023 11:14:45 +0000 Subject: [PATCH 03/16] Compiling to arm aswell --- .github/workflows/main.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1a92383..b2d1d09 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,8 +29,6 @@ jobs: # python3 -m pytest --import-mode=append tests/ build-main: - # if: github.ref == 'refs/heads/main' - # needs: unit-tests runs-on: ubuntu-latest defaults: run: @@ -39,6 +37,12 @@ jobs: - name: 'Checkout GitHub Action' uses: actions/checkout@main + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: 'Login to GitHub Container Registry' uses: docker/login-action@v1 with: @@ -62,16 +66,14 @@ jobs: IMAGE_NAME: ghcr.io/manimatter/decluttarr IMAGE_TAG: ${{ steps.setversion.outputs.new_tag }} run: | - docker build -f docker/Dockerfile -t $IMAGE_NAME:$IMAGE_TAG . - docker push $IMAGE_NAME:$IMAGE_TAG + docker buildx build --platform linux/amd64,linux/arm64 -t $IMAGE_NAME:$IMAGE_TAG -f docker/Dockerfile --push . - name: "Build, Tag, and push the Docker image" env: IMAGE_NAME: ghcr.io/manimatter/decluttarr IMAGE_TAG: latest run: | - docker build -f docker/Dockerfile -t $IMAGE_NAME:$IMAGE_TAG . - docker push $IMAGE_NAME:$IMAGE_TAG + docker buildx build --platform linux/amd64,linux/arm64 -t $IMAGE_NAME:$IMAGE_TAG -f docker/Dockerfile --push . # build-dev: # if: github.ref == 'refs/heads/dev' From a8aa1756eaf1a43d0321c424b0dda28427f1f269 Mon Sep 17 00:00:00 2001 From: Fxsch Date: Fri, 2 Feb 2024 13:44:48 +0000 Subject: [PATCH 04/16] Allow manually running workflow --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b2d1d09..f9b9632 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,6 +6,7 @@ on: - closed branches: - main + workflow_dispatch: jobs: # unit-tests: From 6306f185bc14ca2d9729f7926d3b8176c2e984ca Mon Sep 17 00:00:00 2001 From: Fxsch Date: Fri, 2 Feb 2024 13:50:10 +0000 Subject: [PATCH 05/16] Push docker image to this repo --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f9b9632..360af2c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -64,14 +64,14 @@ jobs: - name: "Build, Tag, and push the Docker image" env: - IMAGE_NAME: ghcr.io/manimatter/decluttarr + IMAGE_NAME: ghcr.io/fxsch/decluttarr IMAGE_TAG: ${{ steps.setversion.outputs.new_tag }} run: | docker buildx build --platform linux/amd64,linux/arm64 -t $IMAGE_NAME:$IMAGE_TAG -f docker/Dockerfile --push . - name: "Build, Tag, and push the Docker image" env: - IMAGE_NAME: ghcr.io/manimatter/decluttarr + IMAGE_NAME: ghcr.io/fxsch/decluttarr IMAGE_TAG: latest run: | docker buildx build --platform linux/amd64,linux/arm64 -t $IMAGE_NAME:$IMAGE_TAG -f docker/Dockerfile --push . From aa171ae47880cf1e4a480816caaf8c4d3ac88c84 Mon Sep 17 00:00:00 2001 From: Nico Janzen Date: Sun, 4 Feb 2024 22:03:13 +0100 Subject: [PATCH 06/16] Updated Sample docker-compose.yml --- docker/Sample docker-compose.yml | 70 ++++++++++++++++---------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/docker/Sample docker-compose.yml b/docker/Sample docker-compose.yml index 4d2b494..1ec2a57 100644 --- a/docker/Sample docker-compose.yml +++ b/docker/Sample docker-compose.yml @@ -1,34 +1,36 @@ -# decluttarr - Keeps radarr and sonarr download queues free of stalled and redundant items - decluttarr: - image: ghcr.io/manimatter/decluttarr:latest - container_name: decluttarr - restart: always - environment: - TZ: Europe/Zurich - PUID: 1000 - PGID: 1000 - # General - LOG_LEVEL: INFO - #TEST_RUN: True - # Features - REMOVE_TIMER: 10 - REMOVE_FAILED: True - REMOVE_STALLED: True - REMOVE_METADATA_MISSING: True - REMOVE_ORPHANS: True - REMOVE_UNMONITORED: True - PERMITTED_ATTEMPTS: 3 - NO_STALLED_REMOVAL_QBIT_TAG: Don't Kill If Stalled - # Radarr - RADARR_URL: http://radarr:7878 - RADARR_KEY: $RADARR_API_KEY - # Sonarr - SONARR_URL: http://sonarr:8989 - SONARR_KEY: $SONARR_API_KEY - # Lidarr - LIDARR_URL: http://lidarr:8686 - LIDARR_KEY: $LIDARR_KEY - # qBitorrent - QBITTORRENT_URL: http://qbittorrent:8080 - #QBITTORRENT_USERNAME: Your Name - #QBITTORRENT_PASSWORD: Your Password \ No newline at end of file +version: "3.3" +services: + decluttarr: + image: "ghcr.io/fxsch/decluttarr:latest" + container_name: decluttarr + restart: unless-stopped + network_mode: "host" + environment: + - TZ=Europe/Berlin + - PUID=1000 + - PGID=1000 + # General + - LOG_LEVEL=INFO + #- TEST_RUN=True + # Features + - REMOVE_TIMER=10 + - REMOVE_FAILED=True + - REMOVE_STALLED=True + - REMOVE_METADATA_MISSING=True + - REMOVE_ORPHANS=True + - REMOVE_UNMONITORED=True + - PERMITTED_ATTEMPTS=3 + - NO_STALLED_REMOVAL_QBIT_TAG=Don't Kill If Stalled + # Radarr + - RADARR_URL=http://localhost:7878 + - RADARR_KEY=$RADARR_API_KEY + # Sonarr + - SONARR_URL=http://localhost:8989 + - SONARR_KEY=$SONARR_API_KEY + # Lidarr + - LIDARR_URL=http://localhost:8686 + - LIDARR_KEY=$LIDARR_API_KEY + # qBittorrent + - QBITTORRENT_URL=http://localhost:8080 + #- QBITTORRENT_USERNAME=Your Name + #- QBITTORRENT_PASSWORD=Your Password \ No newline at end of file From 08b994a74eb8a3c7e3c7c08c329516d4054f57ac Mon Sep 17 00:00:00 2001 From: Nico Janzen Date: Sun, 4 Feb 2024 22:05:04 +0100 Subject: [PATCH 07/16] Updated config.conf-Example for consistency --- config/config.conf-Example | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/config.conf-Example b/config/config.conf-Example index bd324aa..145c56e 100644 --- a/config/config.conf-Example +++ b/config/config.conf-Example @@ -14,15 +14,15 @@ NO_STALLED_REMOVAL_QBIT_TAG = Don't Kill If Stalled [radarr] RADARR_URL = http://radarr:7878 -RADARR_KEY = $RADARR_KEY +RADARR_KEY = $RADARR_API_KEY [sonarr] SONARR_URL = http://sonarr:8989 -SONARR_KEY = $SONARR_KEY +SONARR_KEY = $SONARR_API_KEY [lidarr] LIDARR_URL = http://lidarr:8686 -LIDARR_KEY = $LIDARR_KEY +LIDARR_KEY = $LIDARR_API_KEY [qbittorrent] QBITTORRENT_URL = http://qbittorrent:8080 From 67112203c6a2ba10b55553a2bb3fd3bedf98f628 Mon Sep 17 00:00:00 2001 From: Nico Janzen Date: Sun, 4 Feb 2024 22:27:13 +0100 Subject: [PATCH 08/16] Updated README.md --- README.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index cb7e67b..ccd3da9 100644 --- a/README.md +++ b/README.md @@ -8,25 +8,27 @@ Feature overview: - Automatically delete failed downloads (& trigger download from another source) - Automatically delete downloads belonging to Movies/TV shows/Music requests that have been deleted in the meantime ('Orphan downloads') - Automatically delete stalled downloads, after they have been found to be stalled multiple times in a row -- Automatically delete downloads belonging to Movies/TV/Music requests shows that are unmonitored +- Automatically delete downloads belonging to Movies/TV shows/Music that are unmonitored -You may run this locally by launch main.py, or by pulling the docker image. -A sample docker-compose.yml is included. +You may run this locally by launching main.py, or by pulling the docker image. +You can find a sample docker-compose.yml in the docker folder. ## Getting started If you want to run in docker: -1) Adapt the sample docker-compose to your own needs -2) Study the config file to understand the settings -3) Have fun +1) Use `docker/Sample docker-compose.yml` to make your `docker-compose.yml` file +2) Look at `config/config.conf-Explained` for an explanation of the different settings +3) Run `sudo docker-compose up -d` in the directory where your `docker-compose.yml` is located to create the docker container +4) Have fun If you want to run locally: -1) Pull decluttarr into whatever location you want -2) Study the config file to understand the settings -3) Edit the config file to your liking -4) run main.py +1) Pull decluttarr into whatever location you want with `git clone https://github.com/Fxsch/decluttarr.git` +3) Use `config/config.conf-Example` to make your `config.conf` file (needs to be located in the same folder as `main.py`) +2) Look at `config/config.conf-Explained` for an explanation of the different settings +4) run `main.py` 5) Enjoy ## Credits +- ManiMatter for making this, I just forked it to fix some stuff - Script for detecting stalled downloads expanded on code by MattDGTL/sonarr-radarr-queue-cleaner - Script to read out config expanded on code by syncarr/syncarr - SONARR/RADARR team & contributors for their great product, API documenation, and guidance in their Discord channel @@ -34,4 +36,3 @@ If you want to run locally: ## Disclaimer This script comes free of any warranty, and you are using it at your own risk. -I do not intend to maintain this repo, feel free to fork & create PRs if you want to expand it for your own use From 0aff90a13090b4f1a62919c245303c38ac1a00d2 Mon Sep 17 00:00:00 2001 From: Nico Janzen Date: Sun, 4 Feb 2024 22:29:11 +0100 Subject: [PATCH 09/16] Updated Dockerfile to reference this repo instead of the one this was forked from --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index e584110..aeeab1b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,6 +1,6 @@ #FROM python:3.9-slim-buster FROM python:3.10.13-slim -LABEL org.opencontainers.image.source="https://github.com/ManiMatter/decluttarr" +LABEL org.opencontainers.image.source="https://github.com/Fxsch/decluttarr" ENV IS_IN_DOCKER 1 From fb7925126420c2f88bcbff68ae2be5db8b108f01 Mon Sep 17 00:00:00 2001 From: Nico Janzen Date: Sun, 4 Feb 2024 22:31:55 +0100 Subject: [PATCH 10/16] Updated dev.yml workflow to use this repo instead of the one this was forked from --- .github/workflows/dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 97197e6..d95c604 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -44,7 +44,7 @@ jobs: - name: "Build, Tag, and push the Docker image" env: - IMAGE_NAME: ghcr.io/manimatter/decluttarr + IMAGE_NAME: ghcr.io/fxsch/decluttarr IMAGE_TAG: dev run: | docker build -f docker/Dockerfile -t $IMAGE_NAME:$IMAGE_TAG . From 14dd059c3abd4de4bb4326d454035faadece6860 Mon Sep 17 00:00:00 2001 From: Nico Janzen Date: Sun, 4 Feb 2024 22:52:52 +0100 Subject: [PATCH 11/16] Updated config.conf-Explained to fix typos, make it more consistent and easier to understand --- config/config.conf-Explained | 83 +++++++++++++++++------------------- 1 file changed, 39 insertions(+), 44 deletions(-) diff --git a/config/config.conf-Explained b/config/config.conf-Explained index 506b1ce..bdb9257 100644 --- a/config/config.conf-Explained +++ b/config/config.conf-Explained @@ -1,13 +1,10 @@ -# The config file is only relevant when running main.py locally. -# When running within docker, all settings are to be set via the docker-compose.yml, and this config.conf file will be ignored - ################################# GENERAL SECTION ################################# # General parameters such as log level / test run [general] ###### LOG_LEVEL ###### -# Sets the level at which logging will take place. -# INFO will only show changes applied to Radarr/Sonarr +# Sets the level at which logging will take place +# INFO will only show changes applied to sonarr/radarr # VERBOSE will show when script runs (even if it results in no change) # Type: String # Permissible Values: CRITICAL, ERROR, WARNING, INFO, VERBOSE, DEBUG @@ -27,7 +24,7 @@ TEST_RUN = False [features] ###### REMOVE_TIMER ###### -# Sets the frequency how often the queue is cleaned form orphan and stalled downloads +# Sets the frequency of how often the queue is checked for orphan and stalled downloads # Type: Integer # Unit: Minutes # Is Mandatory: No (Defaults to 10) @@ -35,96 +32,94 @@ REMOVE_TIMER = 10 ###### REMOVE_FAILED ###### # Steers whether failed downloads with no connections are removed from the queue -# Failed downloads are not added to the blocklist +# These downloads are not added to the blocklist # Type: Boolean # Permissible Values: True, False # Is Mandatory: No (Defaults to False) -REMOVE_FAILED = False +REMOVE_FAILED = False ###### REMOVE_STALLED ###### # Steers whether stalled downloads with no connections are removed from the queue -# Stalled downloads are added to the blocklist, so that they are not re-requested in the future +# These downloads are added to the blocklist, so that they are not re-requested in the future # A new download from another source is automatically added by sonarr/radarr (if available) # Type: Boolean # Permissible Values: True, False # Is Mandatory: No (Defaults to False) -REMOVE_STALLED = False +REMOVE_STALLED = False ###### REMOVE_METADATA_MISSING ###### -# Steers whether downloads stuck obtaining meta data are removed from the queue -# These downloads are added the blocklist, so that they are not re-requested in the future +# Steers whether downloads stuck obtaining metadata are removed from the queue +# These downloads are added to the blocklist, so that they are not re-requested in the future # A new download from another source is automatically added by sonarr/radarr (if available) # Type: Boolean # Permissible Values: True, False # Is Mandatory: No (Defaults to False) -REMOVE_METADATA_MISSING = False +REMOVE_METADATA_MISSING = False ###### REMOVE_ORPHANS ###### # Steers whether orphan downloads are removed from the queue -# Orphan downloads those that do not belong to any movie/tvshow anymore (since the movie/TV show was deleted post request) -# Orphan downloads are not added to the block list +# Orphan downloads are those that do not belong to any movie/TV show anymore (Since the movie/TV show was removed from sonarr/radarr after the download started) +# These downloads are not added to the blocklist # Type: Boolean # Permissible Values: True, False # Is Mandatory: No (Defaults to False) -REMOVE_ORPHANS = False +REMOVE_ORPHANS = False ###### REMOVE_UNMONITORED ###### # Steers whether downloads belonging to unmonitored movies/TV shows are removed from the queue # Note: Will only remove from queue if all tv shows depending on the same download are unmonitored -# Unmonitored downloads are not added to the block list -# Note: Since Sonarr does not support multi-season packs, if you download one you should protect it with the below NO_STALLED_REMOVAL_QBIT_TAG. +# These downloads are not added to the blocklist +# Note: Since sonarr does not support multi-season packs, if you download one you should protect it with the below NO_STALLED_REMOVAL_QBIT_TAG. # Type: Boolean # Permissible Values: True, False # Is Mandatory: No (Defaults to False) -REMOVE_UNMONITORED = False +REMOVE_UNMONITORED = False ###### PERMITTED_ATTEMPTS ###### # Defines how many times a download has to be caught as stalled or stuck downloading metadata before it is removed # Type: Integer # Unit: Number of scans # Is Mandatory: No (Defaults to 3) -PERMITTED_ATTEMPTS= 3 +PERMITTED_ATTEMPTS = 3 ###### NO_STALLED_REMOVAL_QBIT_TAG ###### # Downloads in qBittorrent tagged with this tag will not be killed even if they are stalled -# Tag is automatically created in qBittorrent (required qBittorrent is reachable on QBITTORRENT_URL ) +# Tag is automatically created in qBittorrent (required qBittorrent is reachable on QBITTORRENT_URL) # Also protects unmonitored downloads from being removed (relevant for multi-season packs) # Type: String # Is Mandatory: No (Defaults to "Don't Kill If Stalled") -NO_STALLED_REMOVAL_QBIT_TAG= Don't Kill If Stalled +NO_STALLED_REMOVAL_QBIT_TAG = Don't Kill If Stalled ################################# RADARR SECTION ################################# [radarr] # Defines radarr instance on which download queue should be decluttered -# RADARR_URL : URL under which the instance can be reached. If not defined, this instance will not be monitored. -# RADARR_KEY : API Key (mandatory if RADARR_URL is specifidd) -RADARR_URL = http://radarrA:7878 -RADARR_KEY = XXXXX +# RADARR_URL: URL under which the instance can be reached, if not defined, this instance will not be monitored +# RADARR_KEY: Your API key for radarr +RADARR_URL = http://localhost:7878 +RADARR_KEY = $RADARR_API_KEY ################################# SONARR SECTION ################################# [sonarr] -# Please see the documentation under the RADARR section - the explanations the same. -SONARR_URL = http://sonarr:8989 -SONARR_KEY = XXXXX +# Defines sonarr instance on which download queue should be decluttered +# SONARR_URL: URL under which the instance can be reached, if not defined, this instance will not be monitored +# SONARR_KEY: Your API key for sonarr +SONARR_URL = http://localhost:8989 +SONARR_KEY = $SONARR_API_KEY -################################# SONARR SECTION ################################# -[sonarr] -# Please see the documentation under the RADARR section - the explanations the same. -SONARR_URL = http://sonarr:8989 -SONARR_KEY = XXXXX - -################################# SONARR SECTION ################################# +################################# LIDARR SECTION ################################# [lidarr] -# Please see the documentation under the RADARR section - the explanations the same. -LIDARR_URL = http://lidarr:8686 -LIDARR_KEY = XXXXX +# Defines lidarr instance on which download queue should be decluttered +# LIDARR_URL: URL under which the instance can be reached, if not defined, this instance will not be monitored +# LIDARR_KEY: Your API key for lidarr +LIDARR_URL = http://lidarr:8686 +LIDARR_KEY = $LIDARR_API_KEY ################################# QBITTORRENT SECTION ################################# [qbittorrent] # Defines settings to connect with qBittorrent -# QBITTORRENT_URL : URL under which the instance can be reached. If not defined, the NO_STALLED_REMOVAL_QBIT_TAG takes no effect -# QBITTORRENT_USERNAME: Optional; particularly not needed if authentication bypassing on qBittorrent is enabled (for instance for local connections) +# QBITTORRENT_URL : URL under which the instance can be reached, if not defined, the NO_STALLED_REMOVAL_QBIT_TAG takes no effect +# QBITTORRENT_USERNAME: Optional; not needed if authentication bypassing on qBittorrent is enabled (for instance for local connections) # QBITTORRENT_PASSWORD: Optional; same reason as above -QBITTORRENT_URL = http://qbittorrent:8080 -QBITTORRENT_USERNAME = Your Name (or empty) -QBITTORRENT_PASSWORD = Your Password (or empty) \ No newline at end of file +QBITTORRENT_URL = http://localhost:8080 +QBITTORRENT_USERNAME = Your Name (or empty) +QBITTORRENT_PASSWORD = Your Password (or empty) \ No newline at end of file From e6959e031e0a9023db919e0964bb7b88c6514e29 Mon Sep 17 00:00:00 2001 From: Nico Janzen Date: Sun, 4 Feb 2024 22:55:25 +0100 Subject: [PATCH 12/16] Fixed typo in config.conf-Explained and updated config.conf-Example to make it more consistent --- config/config.conf-Example | 14 +++++++------- config/config.conf-Explained | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config/config.conf-Example b/config/config.conf-Example index 145c56e..e6934ae 100644 --- a/config/config.conf-Example +++ b/config/config.conf-Example @@ -1,6 +1,6 @@ [general] -LOG_LEVEL = VERBOSE -TEST_RUN = True +LOG_LEVEL = VERBOSE +TEST_RUN = True [features] REMOVE_TIMER = 10 @@ -13,18 +13,18 @@ PERMITTED_ATTEMPTS = 3 NO_STALLED_REMOVAL_QBIT_TAG = Don't Kill If Stalled [radarr] -RADARR_URL = http://radarr:7878 +RADARR_URL = http://localhost:7878 RADARR_KEY = $RADARR_API_KEY [sonarr] -SONARR_URL = http://sonarr:8989 +SONARR_URL = http://localhost:8989 SONARR_KEY = $SONARR_API_KEY [lidarr] -LIDARR_URL = http://lidarr:8686 +LIDARR_URL = http://localhost:8686 LIDARR_KEY = $LIDARR_API_KEY [qbittorrent] QBITTORRENT_URL = http://qbittorrent:8080 -QBITTORRENT_USERNAME = YourName or Empty -QBITTORRENT_PASSWORD = YourPassword or Empty \ No newline at end of file +QBITTORRENT_USERNAME = Your name (or empty) +QBITTORRENT_PASSWORD = Your password (or empty) \ No newline at end of file diff --git a/config/config.conf-Explained b/config/config.conf-Explained index bdb9257..d700819 100644 --- a/config/config.conf-Explained +++ b/config/config.conf-Explained @@ -121,5 +121,5 @@ LIDARR_KEY = $LIDARR_API_KEY # QBITTORRENT_USERNAME: Optional; not needed if authentication bypassing on qBittorrent is enabled (for instance for local connections) # QBITTORRENT_PASSWORD: Optional; same reason as above QBITTORRENT_URL = http://localhost:8080 -QBITTORRENT_USERNAME = Your Name (or empty) -QBITTORRENT_PASSWORD = Your Password (or empty) \ No newline at end of file +QBITTORRENT_USERNAME = Your name (or empty) +QBITTORRENT_PASSWORD = Your password (or empty) \ No newline at end of file From 6e986b5d526906b61bd9d2208a7987ad5d7af1f9 Mon Sep 17 00:00:00 2001 From: Nico Janzen Date: Sun, 4 Feb 2024 22:56:14 +0100 Subject: [PATCH 13/16] Fixed typo in Sample docker-compose.yml --- docker/Sample docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Sample docker-compose.yml b/docker/Sample docker-compose.yml index 1ec2a57..e1db41d 100644 --- a/docker/Sample docker-compose.yml +++ b/docker/Sample docker-compose.yml @@ -32,5 +32,5 @@ services: - LIDARR_KEY=$LIDARR_API_KEY # qBittorrent - QBITTORRENT_URL=http://localhost:8080 - #- QBITTORRENT_USERNAME=Your Name - #- QBITTORRENT_PASSWORD=Your Password \ No newline at end of file + #- QBITTORRENT_USERNAME=Your name + #- QBITTORRENT_PASSWORD=Your password \ No newline at end of file From 1fa331bfce9e362e5365ca85cbd302cf2198fdcb Mon Sep 17 00:00:00 2001 From: Nico Janzen Date: Sun, 4 Feb 2024 22:57:46 +0100 Subject: [PATCH 14/16] Fixed consistency in config.conf-Example that I missed --- config/config.conf-Example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.conf-Example b/config/config.conf-Example index e6934ae..6cc626a 100644 --- a/config/config.conf-Example +++ b/config/config.conf-Example @@ -25,6 +25,6 @@ LIDARR_URL = http://localhost:8686 LIDARR_KEY = $LIDARR_API_KEY [qbittorrent] -QBITTORRENT_URL = http://qbittorrent:8080 +QBITTORRENT_URL = http://localhost:8080 QBITTORRENT_USERNAME = Your name (or empty) QBITTORRENT_PASSWORD = Your password (or empty) \ No newline at end of file From 9b9e58e4245ca69c72c5f2cf0867f8567abd4fc4 Mon Sep 17 00:00:00 2001 From: Nico Janzen Date: Mon, 5 Feb 2024 10:28:12 +0100 Subject: [PATCH 15/16] Moved Sample docker-compose and config.conf-Explained into the README and moved config.conf-Example to where the actual config.conf file should be --- README.md | 196 ++++++++++++++++++++-- config/config.conf-Example => config.conf | 0 config/config.conf-Explained | 125 -------------- docker/Sample docker-compose.yml | 36 ---- 4 files changed, 185 insertions(+), 172 deletions(-) rename config/config.conf-Example => config.conf (100%) delete mode 100644 config/config.conf-Explained delete mode 100644 docker/Sample docker-compose.yml diff --git a/README.md b/README.md index ccd3da9..5772847 100644 --- a/README.md +++ b/README.md @@ -14,18 +14,192 @@ You may run this locally by launching main.py, or by pulling the docker image. You can find a sample docker-compose.yml in the docker folder. ## Getting started -If you want to run in docker: -1) Use `docker/Sample docker-compose.yml` to make your `docker-compose.yml` file -2) Look at `config/config.conf-Explained` for an explanation of the different settings -3) Run `sudo docker-compose up -d` in the directory where your `docker-compose.yml` is located to create the docker container -4) Have fun +There's two ways to run this: +- As a docker container with docker-compose +- By cloning the repository and running the script manually -If you want to run locally: -1) Pull decluttarr into whatever location you want with `git clone https://github.com/Fxsch/decluttarr.git` -3) Use `config/config.conf-Example` to make your `config.conf` file (needs to be located in the same folder as `main.py`) -2) Look at `config/config.conf-Explained` for an explanation of the different settings -4) run `main.py` -5) Enjoy +Both ways are explained below and there's an explanation for the different settings below that + +## Docker +1) Make a `docker-compose.yml` file +2) Use the following as a base for that and tweak the settings to your needs +``` +version: "3.3" +services: + decluttarr: + image: "ghcr.io/fxsch/decluttarr:latest" + container_name: decluttarr + restart: unless-stopped + network_mode: "host" + environment: + - TZ=Europe/Berlin + - PUID=1000 + - PGID=1000 + # General + - LOG_LEVEL=INFO + #- TEST_RUN=True + # Features + - REMOVE_TIMER=10 + - REMOVE_FAILED=True + - REMOVE_STALLED=True + - REMOVE_METADATA_MISSING=True + - REMOVE_ORPHANS=True + - REMOVE_UNMONITORED=True + - PERMITTED_ATTEMPTS=3 + - NO_STALLED_REMOVAL_QBIT_TAG=Don't Kill If Stalled + # Radarr + - RADARR_URL=http://localhost:7878 + - RADARR_KEY=$RADARR_API_KEY + # Sonarr + - SONARR_URL=http://localhost:8989 + - SONARR_KEY=$SONARR_API_KEY + # Lidarr + - LIDARR_URL=http://localhost:8686 + - LIDARR_KEY=$LIDARR_API_KEY + # qBittorrent + - QBITTORRENT_URL=http://localhost:8080 + #- QBITTORRENT_USERNAME=Your name + #- QBITTORRENT_PASSWORD=Your password +``` +3) Run `docker-compose up -d` in the directory where the file is located to create the docker container + +## Running manually +1) Clone the repository with `git clone https://github.com/Fxsch/decluttarr.git` +2) Tweak the `config.conf` file to your needs +3) Run the script with `python3 main.py` + +## Explanation of the settings +**LOG_LEVEL** +- Sets the level at which logging will take place +- `INFO` will only show changes applied to radarr/sonarr/lidarr +- `VERBOSE` will show when script runs (even if it results in no change) +- Type: String +- Permissible Values: CRITICAL, ERROR, WARNING, INFO, VERBOSE, DEBUG +- Is Mandatory: No (Defaults to INFO) + +**TEST_RUN** +- Allows you to safely try out this tool. If active, downloads will not be removed. +- Type: Boolean +- Permissible Values: True, False +- Is Mandatory: No (Defaults to False) + +--- + +### **Features settings** +- Steers which type of cleaning is applied to the downloads queue +- Requires `QUEUE_CLEANING` to be set to `True` to take effect + +**REMOVE_TIMER** +- Sets the frequency of how often the queue is checked for orphan and stalled downloads +- Type: Integer +- Unit: Minutes +- Is Mandatory: No (Defaults to 10) + +**REMOVE_FAILED** +- Steers whether failed downloads with no connections are removed from the queue +- These downloads are not added to the blocklist +- Type: Boolean +- Permissible Values: True, False +- Is Mandatory: No (Defaults to False) + +**REMOVE_STALLED** +- Steers whether stalled downloads with no connections are removed from the queue +- These downloads are added to the blocklist, so that they are not re-requested in the future +- A new download from another source is automatically added by radarr/sonarr/lidarr (if available) +- Type: Boolean +- Permissible Values: True, False +- Is Mandatory: No (Defaults to False) + +**REMOVE_METADATA_MISSING** +- Steers whether downloads stuck obtaining metadata are removed from the queue +- These downloads are added to the blocklist, so that they are not re-requested +- A new download from another source is automatically added by radarr/sonarr/lidarr (if available) +- Type: Boolean +- Permissible Values: True, False +- Is Mandatory: No (Defaults to False) + +**REMOVE_ORPHANS** +- Steers whether orphan downloads are removed from the queue +- Orphan downloads are those that do not belong to any requested media anymore (Since the media was removed from radarr/sonarr/lidarr after the download started) +- These downloads are not added to the blocklist +- Type: Boolean +- Permissible Values: True, False +- Is Mandatory: No (Defaults to False) + +**REMOVE_UNMONITORED** +- Steers whether downloads belonging to unmonitored media are removed from the queue +- Note: Will only remove from queue if all TV shows depending on the same download are unmonitored +- These downloads are not added to the blocklist +- Note: Since sonarr does not support multi-season packs, if you download one you should protect it with `NO_STALLED_REMOVAL_QBIT_TAG` that is explained further down +- Type: Boolean +- Permissible Values: True, False +- Is Mandatory: No (Defaults to False) + +**PERMITTED_ATTEMPTS** +- Defines how many times a download has to be caught as stalled or stuck downloading metadata before it is removed +- Type: Integer +- Unit: Number of scans +- Is Mandatory: No (Defaults to 3) + +**NO_STALLED_REMOVAL_QBIT_TAG** +- Downloads in qBittorrent tagged with this tag will not be killed even if they are stalled +- Tag is automatically created in qBittorrent (required qBittorrent is reachable on `QBITTORRENT_URL`) +- Also protects unmonitored downloads from being removed (relevant for multi-season packs) +- Type: String +- Is Mandatory: No (Defaults to `Don't Kill If Stalled`) + +--- + +### **Radarr section** +- Defines radarr instance on which download queue should be decluttered + +**RADARR_URL** +- URL under which the instance can be reached +- If not defined, this instance will not be monitored + +**RADARR_KEY** +- Your API key for radarr + +--- + +### **Sonarr section** +- Defines sonarr instance on which download queue should be decluttered + +**SONARR_URL** +- URL under which the instance can be reached +- If not defined, this instance will not be monitored + +**SONARR_KEY** +- Your API key for sonarr + +--- + +### **Lidarr section** +- Defines lidarr instance on which download queue should be decluttered + +**LIDARR_URL** +- URL under which the instance can be reached +- If not defined, this instance will not be monitored + +**LIDARR_KEY** +- Your API key for lidarr + +--- + +### **qBittorrent section** +- Defines settings to connect with qBittorrent + +**QBITTORRENT_URL** +- URL under which the instance can be reached +- If not defined, the NO_STALLED_REMOVAL_QBIT_TAG takes no effect + +**QBITTORRENT_USERNAME** +- Username used to log in to qBittorrent +- Optional; not needed if authentication bypassing on qBittorrent is enabled (for instance for local connections) + +**QBITTORRENT_PASSWORD** +- Password used to log in to qBittorrent +- Optional; not needed if authentication bypassing on qBittorrent is enabled (for instance for local connections) ## Credits - ManiMatter for making this, I just forked it to fix some stuff diff --git a/config/config.conf-Example b/config.conf similarity index 100% rename from config/config.conf-Example rename to config.conf diff --git a/config/config.conf-Explained b/config/config.conf-Explained deleted file mode 100644 index d700819..0000000 --- a/config/config.conf-Explained +++ /dev/null @@ -1,125 +0,0 @@ -################################# GENERAL SECTION ################################# -# General parameters such as log level / test run -[general] - -###### LOG_LEVEL ###### -# Sets the level at which logging will take place -# INFO will only show changes applied to sonarr/radarr -# VERBOSE will show when script runs (even if it results in no change) -# Type: String -# Permissible Values: CRITICAL, ERROR, WARNING, INFO, VERBOSE, DEBUG -# Is Mandatory: No (Defaults to INFO) -LOG_LEVEL = INFO - -###### TEST_RUN ###### -# Allows you to safely try out this tool. If active, downloads will not be removed. -# Type: Boolean -# Permissible Values: True, False -# Is Mandatory: No (Defaults to False) -TEST_RUN = False - -################################# FEATURES SETTINGS ################################# -# Steers which type of cleaning is applied to the downloads queue. -# Requires QUEUE_CLEANING to be set to True to take effect. -[features] - -###### REMOVE_TIMER ###### -# Sets the frequency of how often the queue is checked for orphan and stalled downloads -# Type: Integer -# Unit: Minutes -# Is Mandatory: No (Defaults to 10) -REMOVE_TIMER = 10 - -###### REMOVE_FAILED ###### -# Steers whether failed downloads with no connections are removed from the queue -# These downloads are not added to the blocklist -# Type: Boolean -# Permissible Values: True, False -# Is Mandatory: No (Defaults to False) -REMOVE_FAILED = False - -###### REMOVE_STALLED ###### -# Steers whether stalled downloads with no connections are removed from the queue -# These downloads are added to the blocklist, so that they are not re-requested in the future -# A new download from another source is automatically added by sonarr/radarr (if available) -# Type: Boolean -# Permissible Values: True, False -# Is Mandatory: No (Defaults to False) -REMOVE_STALLED = False - -###### REMOVE_METADATA_MISSING ###### -# Steers whether downloads stuck obtaining metadata are removed from the queue -# These downloads are added to the blocklist, so that they are not re-requested in the future -# A new download from another source is automatically added by sonarr/radarr (if available) -# Type: Boolean -# Permissible Values: True, False -# Is Mandatory: No (Defaults to False) -REMOVE_METADATA_MISSING = False - -###### REMOVE_ORPHANS ###### -# Steers whether orphan downloads are removed from the queue -# Orphan downloads are those that do not belong to any movie/TV show anymore (Since the movie/TV show was removed from sonarr/radarr after the download started) -# These downloads are not added to the blocklist -# Type: Boolean -# Permissible Values: True, False -# Is Mandatory: No (Defaults to False) -REMOVE_ORPHANS = False - -###### REMOVE_UNMONITORED ###### -# Steers whether downloads belonging to unmonitored movies/TV shows are removed from the queue -# Note: Will only remove from queue if all tv shows depending on the same download are unmonitored -# These downloads are not added to the blocklist -# Note: Since sonarr does not support multi-season packs, if you download one you should protect it with the below NO_STALLED_REMOVAL_QBIT_TAG. -# Type: Boolean -# Permissible Values: True, False -# Is Mandatory: No (Defaults to False) -REMOVE_UNMONITORED = False - -###### PERMITTED_ATTEMPTS ###### -# Defines how many times a download has to be caught as stalled or stuck downloading metadata before it is removed -# Type: Integer -# Unit: Number of scans -# Is Mandatory: No (Defaults to 3) -PERMITTED_ATTEMPTS = 3 - -###### NO_STALLED_REMOVAL_QBIT_TAG ###### -# Downloads in qBittorrent tagged with this tag will not be killed even if they are stalled -# Tag is automatically created in qBittorrent (required qBittorrent is reachable on QBITTORRENT_URL) -# Also protects unmonitored downloads from being removed (relevant for multi-season packs) -# Type: String -# Is Mandatory: No (Defaults to "Don't Kill If Stalled") -NO_STALLED_REMOVAL_QBIT_TAG = Don't Kill If Stalled - -################################# RADARR SECTION ################################# -[radarr] -# Defines radarr instance on which download queue should be decluttered -# RADARR_URL: URL under which the instance can be reached, if not defined, this instance will not be monitored -# RADARR_KEY: Your API key for radarr -RADARR_URL = http://localhost:7878 -RADARR_KEY = $RADARR_API_KEY - -################################# SONARR SECTION ################################# -[sonarr] -# Defines sonarr instance on which download queue should be decluttered -# SONARR_URL: URL under which the instance can be reached, if not defined, this instance will not be monitored -# SONARR_KEY: Your API key for sonarr -SONARR_URL = http://localhost:8989 -SONARR_KEY = $SONARR_API_KEY - -################################# LIDARR SECTION ################################# -[lidarr] -# Defines lidarr instance on which download queue should be decluttered -# LIDARR_URL: URL under which the instance can be reached, if not defined, this instance will not be monitored -# LIDARR_KEY: Your API key for lidarr -LIDARR_URL = http://lidarr:8686 -LIDARR_KEY = $LIDARR_API_KEY - -################################# QBITTORRENT SECTION ################################# -[qbittorrent] -# Defines settings to connect with qBittorrent -# QBITTORRENT_URL : URL under which the instance can be reached, if not defined, the NO_STALLED_REMOVAL_QBIT_TAG takes no effect -# QBITTORRENT_USERNAME: Optional; not needed if authentication bypassing on qBittorrent is enabled (for instance for local connections) -# QBITTORRENT_PASSWORD: Optional; same reason as above -QBITTORRENT_URL = http://localhost:8080 -QBITTORRENT_USERNAME = Your name (or empty) -QBITTORRENT_PASSWORD = Your password (or empty) \ No newline at end of file diff --git a/docker/Sample docker-compose.yml b/docker/Sample docker-compose.yml deleted file mode 100644 index e1db41d..0000000 --- a/docker/Sample docker-compose.yml +++ /dev/null @@ -1,36 +0,0 @@ -version: "3.3" -services: - decluttarr: - image: "ghcr.io/fxsch/decluttarr:latest" - container_name: decluttarr - restart: unless-stopped - network_mode: "host" - environment: - - TZ=Europe/Berlin - - PUID=1000 - - PGID=1000 - # General - - LOG_LEVEL=INFO - #- TEST_RUN=True - # Features - - REMOVE_TIMER=10 - - REMOVE_FAILED=True - - REMOVE_STALLED=True - - REMOVE_METADATA_MISSING=True - - REMOVE_ORPHANS=True - - REMOVE_UNMONITORED=True - - PERMITTED_ATTEMPTS=3 - - NO_STALLED_REMOVAL_QBIT_TAG=Don't Kill If Stalled - # Radarr - - RADARR_URL=http://localhost:7878 - - RADARR_KEY=$RADARR_API_KEY - # Sonarr - - SONARR_URL=http://localhost:8989 - - SONARR_KEY=$SONARR_API_KEY - # Lidarr - - LIDARR_URL=http://localhost:8686 - - LIDARR_KEY=$LIDARR_API_KEY - # qBittorrent - - QBITTORRENT_URL=http://localhost:8080 - #- QBITTORRENT_USERNAME=Your name - #- QBITTORRENT_PASSWORD=Your password \ No newline at end of file From a9013142747c81ce8004bf57470c5edd88c5b6de Mon Sep 17 00:00:00 2001 From: Benjamin Harder Date: Sat, 17 Feb 2024 14:43:16 +0100 Subject: [PATCH 16/16] Review + Merge of ARM Support and Readme Cleanup (contributions by craggles17 and Fxsch) --- .github/workflows/dev.yml | 2 +- .github/workflows/main.yml | 49 ++------------------------------------ README.md | 12 +++++----- config/config.conf-Example | 30 +++++++++++++++++++++++ docker/Dockerfile | 2 +- 5 files changed, 40 insertions(+), 55 deletions(-) create mode 100644 config/config.conf-Example diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index d95c604..97197e6 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -44,7 +44,7 @@ jobs: - name: "Build, Tag, and push the Docker image" env: - IMAGE_NAME: ghcr.io/fxsch/decluttarr + IMAGE_NAME: ghcr.io/manimatter/decluttarr IMAGE_TAG: dev run: | docker build -f docker/Dockerfile -t $IMAGE_NAME:$IMAGE_TAG . diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 360af2c..ff0d17d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,26 +9,6 @@ on: workflow_dispatch: jobs: - # unit-tests: - # runs-on: ubuntu-latest - # defaults: - # run: - # working-directory: '.' - # steps: - # - uses: actions/checkout@v4 - - # - name: Set up Python - # uses: actions/setup-python@v4 - # with: - # python-version: '3.x' - # - name: Install pip and pytest - # run: | - # python -m pip install --upgrade pip - # pip install -r docker/requirements.txt - # - name: Test with pytest - # run: | - # python3 -m pytest --import-mode=append tests/ - build-main: runs-on: ubuntu-latest defaults: @@ -64,40 +44,15 @@ jobs: - name: "Build, Tag, and push the Docker image" env: - IMAGE_NAME: ghcr.io/fxsch/decluttarr + IMAGE_NAME: ghcr.io/manimatter/decluttarr IMAGE_TAG: ${{ steps.setversion.outputs.new_tag }} run: | docker buildx build --platform linux/amd64,linux/arm64 -t $IMAGE_NAME:$IMAGE_TAG -f docker/Dockerfile --push . - name: "Build, Tag, and push the Docker image" env: - IMAGE_NAME: ghcr.io/fxsch/decluttarr + IMAGE_NAME: ghcr.io/manimatter/decluttarr IMAGE_TAG: latest run: | docker buildx build --platform linux/amd64,linux/arm64 -t $IMAGE_NAME:$IMAGE_TAG -f docker/Dockerfile --push . - # build-dev: - # if: github.ref == 'refs/heads/dev' - # needs: unit-tests - # runs-on: ubuntu-latest - # defaults: - # run: - # working-directory: '.' - # steps: - # - name: 'Checkout GitHub Action' - # uses: actions/checkout@main - - # - name: 'Login to GitHub Container Registry' - # uses: docker/login-action@v1 - # with: - # registry: ghcr.io - # username: ${{github.actor}} - # password: ${{secrets.GITHUB_TOKEN}} - - # - name: "Build, Tag, and push the Docker image" - # env: - # IMAGE_NAME: ghcr.io/manimatter/decluttarr - # IMAGE_TAG: dev - # run: | - # docker build -f docker/Dockerfile -t $IMAGE_NAME:$IMAGE_TAG . - # docker push $IMAGE_NAME:$IMAGE_TAG diff --git a/README.md b/README.md index 2f15a7c..ca5044e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Feature overview: - Automatically delete failed downloads (& trigger download from another source) - Automatically delete downloads belonging to Movies/TV shows/Music requests that have been deleted in the meantime ('Orphan downloads') - Automatically delete stalled downloads, after they have been found to be stalled multiple times in a row -- Automatically delete downloads belonging to Movies/TV shows/Music that are unmonitored +- Automatically delete downloads belonging to Movies/TV shows/Music requests that are unmonitored You may run this locally by launching main.py, or by pulling the docker image. You can find a sample docker-compose.yml in the docker folder. @@ -27,12 +27,11 @@ Both ways are explained below and there's an explanation for the different setti version: "3.3" services: decluttarr: - image: "ghcr.io/fxsch/decluttarr:latest" + image: ghcr.io/manimatter/decluttarr:latest container_name: decluttarr - restart: unless-stopped - network_mode: "host" + restart: always environment: - - TZ=Europe/Berlin + - TZ=Europe/Zurich - PUID=1000 - PGID=1000 # General @@ -206,11 +205,12 @@ Use Sonarr v4 & Radarr v5 (currently 'nightly' tag instead of 'latest'), else ce Use latest version of qBittorrent. ## Credits -- ManiMatter for making this, I just forked it to fix some stuff - Script for detecting stalled downloads expanded on code by MattDGTL/sonarr-radarr-queue-cleaner - Script to read out config expanded on code by syncarr/syncarr - SONARR/RADARR team & contributors for their great product, API documenation, and guidance in their Discord channel - Particular thanks to them for adding an additional flag to their API that allowed this script detect downloads stuck finding metadata +- craggles17 for arm compatibility +- Fxsch for improved documentation / ReadMe ## Disclaimer This script comes free of any warranty, and you are using it at your own risk. diff --git a/config/config.conf-Example b/config/config.conf-Example new file mode 100644 index 0000000..ecd0f17 --- /dev/null +++ b/config/config.conf-Example @@ -0,0 +1,30 @@ +[general] +LOG_LEVEL = VERBOSE +TEST_RUN = True + +[features] +REMOVE_TIMER = 10 +REMOVE_FAILED = True +REMOVE_STALLED = True +REMOVE_METADATA_MISSING = True +REMOVE_ORPHANS = True +REMOVE_UNMONITORED = True +PERMITTED_ATTEMPTS = 3 +NO_STALLED_REMOVAL_QBIT_TAG = Don't Kill If Stalled + +[radarr] +RADARR_URL = http://radarr:7878 +RADARR_KEY = $RADARR_KEY + +[sonarr] +SONARR_URL = http://sonarr:8989 +SONARR_KEY = $SONARR_KEY + +[lidarr] +LIDARR_URL = http://lidarr:8686 +LIDARR_KEY = $LIDARR_KEY + +[qbittorrent] +QBITTORRENT_URL = http://qbittorrent:8080 +QBITTORRENT_USERNAME = Your name (or empty) +QBITTORRENT_PASSWORD = Your password (or empty) \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index aeeab1b..e584110 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,6 +1,6 @@ #FROM python:3.9-slim-buster FROM python:3.10.13-slim -LABEL org.opencontainers.image.source="https://github.com/Fxsch/decluttarr" +LABEL org.opencontainers.image.source="https://github.com/ManiMatter/decluttarr" ENV IS_IN_DOCKER 1