Skip to content

Commit

Permalink
🔀 ⚗️ Extended Platform Support - Experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
ThijmenGThN authored Mar 19, 2024
2 parents 47fedd7 + 1a1fde6 commit 53144e0
Show file tree
Hide file tree
Showing 8 changed files with 323 additions and 236 deletions.
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@ WORKDIR /swaparr
COPY src ./src
COPY Cargo* ./

# Add OpenSSL dependency to cargo. (Required in musl build.)
RUN echo "openssl = { version = \"0.10\", features = [\"vendored\"] }" >> Cargo.toml

# Install buildtools.
RUN apt update
RUN apt install -y libssl-dev musl-tools

# Add musl target.
RUN rustup target add x86_64-unknown-linux-musl

RUN echo "openssl = { version = \"0.10\", features = [\"vendored\"] }" >> Cargo.toml

# Build Swaparr.
RUN cargo build --release --target x86_64-unknown-linux-musl


# ----- Package Stage -----
FROM scratch

# Copy Swaparr binary to scratch image.
COPY --from=build /swaparr/target/x86_64-unknown-linux-musl/release/swaparr /swaparr

CMD ["/swaparr"]
227 changes: 135 additions & 92 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Swaparr

Radarr and Sonarr currently lack a built-in mechanism to handle stalled torrents, this project aims to solve that.
Radarr, Sonarr and the other Starrs currently lack a built-in mechanism to handle stalled torrents, this project aims to solve that.

> Swaparr is inspired by a Reddit thread ["I wrote a script that replaces slow/dead torrents automatically"](https://www.reddit.com/r/radarr/comments/101q31k/i_wrote_a_script_that_replaces_slowdead_torrents/) from [Douglas96](https://www.reddit.com/user/Douglas96/).
Expand All @@ -9,17 +9,9 @@ Radarr and Sonarr currently lack a built-in mechanism to handle stalled torrents
</p>


## Disclaimer
#### ⭐ Show Your Support for Open Source!

As Swaparr is not yet at its 1.0.0 stage, expect significant changes and occasional unpredictability until then.

#### Supported Platforms

- [X] Radarr
- [X] Sonarr
- [ ] Lidarr
- [ ] Readarr
- [ ] Arm64 binaries for Raspberry Pi
If Swaparr has been helpful to you and you appreciate the power of open-source software, please consider giving this repository a star. Your gesture will greatly support our efforts and help others discover Swaparr!

## What is Swaparr?

Expand All @@ -31,6 +23,8 @@ Swaparr quietly operates in the background, offering full customization options
- **Strike System:** Identified torrents are given a strike, and this evaluation cycle repeats periodically. If a torrent accumulates the maximum allowed strikes, Swaparr automatically removes it from your instance.
- **Customization:** Swaparr offers customization options such as time and size thresholds, strike thresholds, and the ability to toggle aggressive strike behavior.

> Beware: Swaparr is still in beta, things might change before reaching version ` 1.0.0 `
## Getting Started

In this section, we'll deploy Swaparr using Docker and its compose plugin.
Expand All @@ -50,7 +44,7 @@ services:
environment:
- BASEURL=http://127.0.0.1:7878 # IP or FQDN (Required)
- APIKEY=7f3a8..cbc07 # Radarr API Key (Required)
- PLATFORM=radarr # "radarr" or "sonarr" (Optional) default: radarr
- PLATFORM=radarr # "radarr", "sonarr".. (Optional) default: radarr
- TIME_THRESHOLD=2h # 1d, 6h, 30m, etc.. (Optional) default: 2h
- SIZE_THRESHOLD=25GB # 1TB, 1GB, 1MB, etc.. (Optional) default: 25GB
- CHECK_INTERVAL=10m # 1d, 6h, 30m, etc.. (Optional) default: 10m
Expand All @@ -65,143 +59,192 @@ services:
environment:
- BASEURL=http://127.0.0.1:8989 # IP or FQDN (Required)
- APIKEY=7f3a8..cbc07 # Sonarr API Key (Required)
- PLATFORM=sonarr # "radarr" or "sonarr" (Optional) default: radarr
- PLATFORM=sonarr # "radarr", "sonarr".. (Optional) default: radarr
- TIME_THRESHOLD=2h # 1d, 6h, 30m, etc.. (Optional) default: 2h
- SIZE_THRESHOLD=25GB # 1TB, 1GB, 1MB, etc.. (Optional) default: 25GB
- CHECK_INTERVAL=10m # 1d, 6h, 30m, etc.. (Optional) default: 10m
- STRIKE_THRESHOLD=3 # Positive number (Optional) default: 3
- AGGRESSIVE_STRIKES=false # Boolean (Optional) default: false
```
<details>
<summary>
<strong>Starting Swaparr</strong>
</summary>
To start Swaparr, run the following command:
```sh
```
docker compose up -d
```

</details>


<details>
<summary>
<strong>Observing Swaparr</strong>
<strong>Basic Controls</strong>
</summary>

The following example will output logs of Swaparr's Radarr service.
### Monitor

```sh
docker compose logs radarr
```
You can monitor Swaparr's activities and track the processing of torrents by executing the following command. Omit the ` <platform> ` parameter to view logs for all platforms:

_[It should output something similar to this.](#swaparr)_
```
docker compose logs <platform>
```

</details>
### Shutdown

To shut down Swaparr, execute the following command:

```
docker compose down
```
</details>

<details>
<summary>
<strong>Stopping Swaparr</strong>
<strong>We also support Lidarr, Readarr and Whisparr</strong> (Experimental)
</summary>

To stop Swaparr, run the following command:

```sh
docker compose down
```

```yml
version: '3'
services:

radarr:
image: ghcr.io/thijmengthn/swaparr:latest
container_name: swaparr-radarr
restart: unless-stopped
environment:
- BASEURL=http://127.0.0.1:7878 # IP or FQDN (Required)
- APIKEY=7f3a8..cbc07 # Radarr API Key (Required)
- PLATFORM=radarr # "radarr", "sonarr".. (Optional) default: radarr
- TIME_THRESHOLD=2h # 1d, 6h, 30m, etc.. (Optional) default: 2h
- SIZE_THRESHOLD=25GB # 1TB, 1GB, 1MB, etc.. (Optional) default: 25GB
- CHECK_INTERVAL=10m # 1d, 6h, 30m, etc.. (Optional) default: 10m
- STRIKE_THRESHOLD=3 # Positive number (Optional) default: 3
- AGGRESSIVE_STRIKES=false # Boolean (Optional) default: false

# -- (Optional)
sonarr:
image: ghcr.io/thijmengthn/swaparr:latest
container_name: swaparr-sonarr
restart: unless-stopped
environment:
- BASEURL=http://127.0.0.1:8989 # IP or FQDN (Required)
- APIKEY=7f3a8..cbc07 # Sonarr API Key (Required)
- PLATFORM=sonarr # "radarr", "sonarr".. (Optional) default: radarr
- TIME_THRESHOLD=2h # 1d, 6h, 30m, etc.. (Optional) default: 2h
- SIZE_THRESHOLD=25GB # 1TB, 1GB, 1MB, etc.. (Optional) default: 25GB
- CHECK_INTERVAL=10m # 1d, 6h, 30m, etc.. (Optional) default: 10m
- STRIKE_THRESHOLD=3 # Positive number (Optional) default: 3
- AGGRESSIVE_STRIKES=false # Boolean (Optional) default: false

# -- (Optional)
lidarr:
image: ghcr.io/thijmengthn/swaparr:latest
container_name: swaparr-lidarr
restart: unless-stopped
environment:
- BASEURL=http://127.0.0.1:8989 # IP or FQDN (Required)
- APIKEY=7f3a8..cbc07 # Lidarr API Key (Required)
- PLATFORM=lidarr # "radarr", "sonarr".. (Optional) default: radarr
- TIME_THRESHOLD=2h # 1d, 6h, 30m, etc.. (Optional) default: 2h
- SIZE_THRESHOLD=25GB # 1TB, 1GB, 1MB, etc.. (Optional) default: 25GB
- CHECK_INTERVAL=10m # 1d, 6h, 30m, etc.. (Optional) default: 10m
- STRIKE_THRESHOLD=3 # Positive number (Optional) default: 3
- AGGRESSIVE_STRIKES=false # Boolean (Optional) default: false

# -- (Optional)
readarr:
image: ghcr.io/thijmengthn/swaparr:latest
container_name: swaparr-readarr
restart: unless-stopped
environment:
- BASEURL=http://127.0.0.1:8989 # IP or FQDN (Required)
- APIKEY=7f3a8..cbc07 # Readarr API Key (Required)
- PLATFORM=readarr # "radarr", "sonarr".. (Optional) default: radarr
- TIME_THRESHOLD=2h # 1d, 6h, 30m, etc.. (Optional) default: 2h
- SIZE_THRESHOLD=25GB # 1TB, 1GB, 1MB, etc.. (Optional) default: 25GB
- CHECK_INTERVAL=10m # 1d, 6h, 30m, etc.. (Optional) default: 10m
- STRIKE_THRESHOLD=3 # Positive number (Optional) default: 3
- AGGRESSIVE_STRIKES=false # Boolean (Optional) default: false

# -- (Optional)
whisparr:
image: ghcr.io/thijmengthn/swaparr:latest
container_name: swaparr-whisparr
restart: unless-stopped
environment:
- BASEURL=http://127.0.0.1:8989 # IP or FQDN (Required)
- APIKEY=7f3a8..cbc07 # Whisparr API Key (Required)
- PLATFORM=whisparr # "radarr", "sonarr".. (Optional) default: radarr
- TIME_THRESHOLD=2h # 1d, 6h, 30m, etc.. (Optional) default: 2h
- SIZE_THRESHOLD=25GB # 1TB, 1GB, 1MB, etc.. (Optional) default: 25GB
- CHECK_INTERVAL=10m # 1d, 6h, 30m, etc.. (Optional) default: 10m
- STRIKE_THRESHOLD=3 # Positive number (Optional) default: 3
- AGGRESSIVE_STRIKES=false # Boolean (Optional) default: false
```
</details>

## Useful Information
A brief rundown to shed light on a couple of things for you:
<details>
<summary>
<strong>Environment Variables</strong>
</summary>
| Name | Default | Description |
|-------------------|----------------------|-------------------------------------------------------------------------------------------------|
| BASEURL | `http://127.0.0.1:7878` | The URL of either a Sonarr or Radarr instance. |
| APIKEY | `7f3a8..cbc07` | The API key required for accessing the Radarr or Sonarr instance. |
| PLATFORM | `radarr` | Indicates the platform with which Swaparr interacts, either `radarr` or `sonarr`. |
| TIME_THRESHOLD | `2h` | The duration threshold for torrents to be considered stalled; torrents exceeding this limit will be removed. |
| SIZE_THRESHOLD | `25GB` | The size limit for torrents to be ignored; torrents exceeding this limit will not be processed. |
| CHECK_INTERVAL | `10m` | The interval at which Swaparr monitors torrents. |
| STRIKE_THRESHOLD | `3` | The number of strikes a torrent needs to reach before it is subject to removal. |
| AGGRESSIVE_STRIKES| `false` | Enables the removal of stalled torrents and those stuck fetching metadata. |

| Name | Default | Description |
|-------------------|----------------------| -------------------------------------------------------------------------------------------------|
| BASEURL | `http://127.0.0.1:7878` | The URL of either a Sonarr or Radarr instance. |
| APIKEY | `7f3a8..cbc07` | The API key required for accessing the Radarr or Sonarr instance. |
| PLATFORM | `radarr` | Indicates the platform with which Swaparr interacts, either `radarr`, `sonarr`, `lidarr`, `readarr` and `whisparr`.|
| TIME_THRESHOLD | `2h` | The duration threshold for torrents to be considered stalled; torrents exceeding this limit will be removed. |
| SIZE_THRESHOLD | `25GB` | The size limit for torrents to be ignored; torrents exceeding this limit will not be processed. |
| CHECK_INTERVAL | `10m` | The interval at which Swaparr monitors torrents. |
| STRIKE_THRESHOLD | `3` | The number of strikes a torrent needs to reach before it is subject to removal. |
| AGGRESSIVE_STRIKES| `false` | Enables the removal of stalled torrents and those stuck fetching metadata. |
</details>



<details>
<summary>
<strong>Status-Types Explained</strong>
</summary>

| Type | Meaning |
| --- | --- |
| `Normal` | Not stalled or slow, will not be striked. |
| `Pending` | Fetching metadata or stalled (can be bypassed with `aggressive_strikes`). |
| `Striked` | Flagged as slow or stalled, pending removal. |
| `Removed` | Removed from Radarr / Sonarr. |
| `Ignored` | Outside of threshold bounds. |

| Type | Meaning |
| --- | --- |
| `Normal` | Not stalled or slow, will not be striked. |
| `Pending` | Fetching metadata or stalled (can be bypassed with `aggressive_strikes`). |
| `Striked` | Flagged as slow or stalled, pending removal. |
| `Removed` | Removed from Radarr / Sonarr. |
| `Ignored` | Outside of threshold bounds. |
</details>



<details>
<summary>
<strong>Getting Started</strong> (without Docker)
</summary>

#### Prerequisites
#### Prerequisites

To begin, [download the executable](https://github.com/ThijmenGThN/swaparr/releases) compatible with your operating system.
To begin, [download the executable](https://github.com/ThijmenGThN/swaparr/releases) compatible with your operating system.

Before running Swaparr, manually set the required [environment variables](#environment-variables).
Before running Swaparr, manually set the required [environment variables](#environment-variables).

> Note: You do not need to define every environment variable; only the ones you need and those that are required.
> Note: You do not need to define every environment variable; only the ones you need and those that are required.

#### Powershell
#### Powershell

```
$Env:<variable>="<value>"
```

#### Shell
```
$Env:<variable>="<value>"
```
```
export <variable>="<value>"
```
#### Shell
#### Run Swaparr
```
export <variable>="<value>"
```
You should now be able to run Swaparr directly from the binary file.
#### Run Swaparr
You should now be able to run Swaparr directly from the binary file.
</details>
## ✨ Swaparr is for everyone!

## Need Help?

If you need assistance or have suggestions for improvement, please don't hesitate to [open an issue](https://github.com/ThijmenGThN/swaparr/issues). Your feedback is valuable.



## Feature Requests, Bug Reports

Your feedback, bug reports and suggestions are very welcome, you can do so by [opening an issue](https://github.com/ThijmenGThN/swaparr/issues).



## Contributions

Feel free to [open an issue](https://github.com/ThijmenGThN/swaparr/issues) or PR if you want to contribute to this project.
Whether you need help, want to pitch in, or found a bug that needs fixing, just [open an issue](https://github.com/ThijmenGThN/swaparr/issues). We're all ears and ready to collaborate with you!
Loading

0 comments on commit 53144e0

Please sign in to comment.