windarr 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- windarr-0.1.1/LICENSE +21 -0
- windarr-0.1.1/MANIFEST.in +4 -0
- windarr-0.1.1/PKG-INFO +360 -0
- windarr-0.1.1/README.md +336 -0
- windarr-0.1.1/config.example.toml +77 -0
- windarr-0.1.1/examples/notify-on-fail +26 -0
- windarr-0.1.1/examples/windarr.plist +36 -0
- windarr-0.1.1/examples/windarr.service +14 -0
- windarr-0.1.1/examples/windarr.timer +10 -0
- windarr-0.1.1/pyproject.toml +37 -0
- windarr-0.1.1/setup.cfg +4 -0
- windarr-0.1.1/src/windarr/__init__.py +3 -0
- windarr-0.1.1/src/windarr/__main__.py +5 -0
- windarr-0.1.1/src/windarr/apps.py +211 -0
- windarr-0.1.1/src/windarr/checks.py +153 -0
- windarr-0.1.1/src/windarr/cli.py +410 -0
- windarr-0.1.1/src/windarr/clients/__init__.py +95 -0
- windarr-0.1.1/src/windarr/clients/qbittorrent.py +84 -0
- windarr-0.1.1/src/windarr/clients/sabnzbd.py +89 -0
- windarr-0.1.1/src/windarr/downloads.py +679 -0
- windarr-0.1.1/src/windarr/notifiers/__init__.py +64 -0
- windarr-0.1.1/src/windarr/notifiers/ntfy.py +27 -0
- windarr-0.1.1/src/windarr/settings.py +261 -0
- windarr-0.1.1/src/windarr/state.py +23 -0
- windarr-0.1.1/src/windarr/titles.py +422 -0
- windarr-0.1.1/src/windarr/util.py +310 -0
- windarr-0.1.1/src/windarr/window.py +936 -0
- windarr-0.1.1/src/windarr.egg-info/PKG-INFO +360 -0
- windarr-0.1.1/src/windarr.egg-info/SOURCES.txt +32 -0
- windarr-0.1.1/src/windarr.egg-info/dependency_links.txt +1 -0
- windarr-0.1.1/src/windarr.egg-info/entry_points.txt +2 -0
- windarr-0.1.1/src/windarr.egg-info/top_level.txt +1 -0
- windarr-0.1.1/tests/namecheck.py +63 -0
- windarr-0.1.1/tests/test_windarr.py +2343 -0
windarr-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Maxime Imperatori
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
windarr-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: windarr
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Keeps every user's TV a few episodes ahead in Sonarr, within the space on their own volume
|
|
5
|
+
Author: Maxime Imperatori
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://gitlab.com/mimperatori/windarr
|
|
8
|
+
Project-URL: Repository, https://gitlab.com/mimperatori/windarr
|
|
9
|
+
Project-URL: GitHub mirror, https://github.com/maximeimperatori/windarr
|
|
10
|
+
Project-URL: Issues, https://gitlab.com/mimperatori/windarr/-/issues
|
|
11
|
+
Project-URL: Releases, https://gitlab.com/mimperatori/windarr/-/releases
|
|
12
|
+
Keywords: sonarr,radarr,seerr,jellyfin,emby,media-server
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Operating System :: MacOS
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Topic :: Multimedia :: Video
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# windarr
|
|
26
|
+
|
|
27
|
+
windarr makes Sonarr download each user's shows a few episodes at a time, in order, within that
|
|
28
|
+
user's own space: a volume of their own, or a folder with a size cap. Movies requested in Radarr
|
|
29
|
+
get the room that's left after every show's next episodes. It's meant for a small home media
|
|
30
|
+
server shared by a few people, each with their own Jellyfin (or Emby) account and Seerr
|
|
31
|
+
requests. It runs on macOS and Linux.
|
|
32
|
+
|
|
33
|
+
**The problem it solves.** Sonarr downloads everything that's monitored, as soon as it can. With
|
|
34
|
+
limited space, one big request fills the disk, and a season pack lands where only one episode
|
|
35
|
+
was wanted. Meanwhile seeding copies of watched episodes keep taking up room.
|
|
36
|
+
|
|
37
|
+
**What windarr does instead.** It runs every minute and decides what Sonarr may download right
|
|
38
|
+
now: the next few unwatched episodes of every show you're watching, and the movies you
|
|
39
|
+
requested, as long as they fit. As you watch, the next episodes come in.
|
|
40
|
+
|
|
41
|
+
## How it works
|
|
42
|
+
|
|
43
|
+
- **A window per user.** Every show keeps its next 3 unwatched episodes ready, on disk or
|
|
44
|
+
downloading. Each show gets its next episode before any show gets two, so a new request can't
|
|
45
|
+
push out a show someone is in the middle of. The next season joins once the current one is
|
|
46
|
+
nearly done. Nothing past the window is downloaded, so free space stays free.
|
|
47
|
+
- **Monitoring is the switch.** windarr monitors episodes once they're in the window, and
|
|
48
|
+
searches for each one once when it enters. It unmonitors the rest and remembers them. They
|
|
49
|
+
come back as you watch.
|
|
50
|
+
- **Seerr requests decide what's wanted.** The seasons someone requested are fetched, and new
|
|
51
|
+
seasons too if they asked for all of them. Shows nobody requested follow Sonarr's own
|
|
52
|
+
monitoring. Requested movies get space right after every show's next episodes, and are
|
|
53
|
+
searched once there's room.
|
|
54
|
+
- **Watched means played in Jellyfin or Emby.** windarr never deletes watched episodes itself.
|
|
55
|
+
Something else has to, such as the [Media Cleaner](https://github.com/shemanaev/jellyfin-plugin-media-cleaner)
|
|
56
|
+
plugin for Jellyfin, or the space never comes back.
|
|
57
|
+
- **Dropped shows.** If someone deletes everything a show has on disk while some of it is still
|
|
58
|
+
unwatched, windarr treats the show as dropped and fetches nothing more of it.
|
|
59
|
+
`windarr --undrop TITLE` undoes that.
|
|
60
|
+
- **Housekeeping.**
|
|
61
|
+
- With qBittorrent, it removes finished torrents once the library copy is gone (watched and
|
|
62
|
+
deleted).
|
|
63
|
+
- It imports downloads that Sonarr/Radarr refuse only because of their free-space check. That
|
|
64
|
+
check is pointless for a hardlink, which takes no extra space.
|
|
65
|
+
- It handles re-grabs that Sonarr/Radarr won't import (see [Download clients](#download-clients)).
|
|
66
|
+
- It removes titles that stayed empty for a week from Sonarr/Radarr, and clears them in Seerr.
|
|
67
|
+
- It keeps each title's tag in line with whose space the title is in.
|
|
68
|
+
- When someone requests a title that's in another user's library and has nothing on disk,
|
|
69
|
+
it moves the title to them.
|
|
70
|
+
- **Checks and pushes.** Every hour it checks the settings it relies on in the other apps (see
|
|
71
|
+
[Settings windarr checks](#settings-windarr-checks)). While one is wrong, it changes nothing,
|
|
72
|
+
and it sends a push about each problem once (see [Pushes](#pushes)).
|
|
73
|
+
|
|
74
|
+
`windarr --dry-run` shows every user's window and what windarr would do, without changing
|
|
75
|
+
anything:
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
alice: 120.0 GB free, 3.2 GB in Downloads, 0.0 GB other downloads queued; 140.0 GB usable for requested movies + series, window uses 46.1 GB
|
|
79
|
+
Some Show (fetching season 1, ~2.5 GB/ep): S1E4F S1E5Q S1E6M S1E7M- S1E8M- S1E9M-
|
|
80
|
+
Another Show (fetching season 2, ~1.4 GB/ep): S2E1F S2E2F S2E3F S2E4M-
|
|
81
|
+
(F on disk, Q queued, M missing; '-' = outside the window)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The full rules are described at the top of [`src/windarr/cli.py`](https://gitlab.com/mimperatori/windarr/-/blob/main/src/windarr/cli.py).
|
|
85
|
+
|
|
86
|
+
## What you need
|
|
87
|
+
|
|
88
|
+
- **macOS or Linux, with Python 3.11 or newer.** windarr uses only the standard library.
|
|
89
|
+
- **Sonarr v4, Radarr v5, or both.** The TV parts need Sonarr and the movie parts need Radarr.
|
|
90
|
+
- **[Seerr](https://github.com/seerr-team/seerr)** (or Jellyseerr), with a default server for
|
|
91
|
+
Sonarr, Radarr or both. windarr reads their addresses and API keys, and the media server's API
|
|
92
|
+
key, from Seerr's `settings.json`. So the machine running windarr must be able to read that
|
|
93
|
+
file.
|
|
94
|
+
- **Jellyfin or Emby**, with one account per user.
|
|
95
|
+
- **Something that deletes watched files**, such as Media Cleaner for Jellyfin.
|
|
96
|
+
- **Any download client** Sonarr/Radarr support. qBittorrent and SABnzbd get extras (see
|
|
97
|
+
[Download clients](#download-clients)).
|
|
98
|
+
- **A space of their own for each user**, holding that user's library and download folders.
|
|
99
|
+
Both must be on the same disk, because imports are hardlinks. The space is either:
|
|
100
|
+
- **a volume**: a disk, a partition, or an APFS volume with a quota. windarr uses its free
|
|
101
|
+
space.
|
|
102
|
+
- **a folder** on a disk shared with others, such as `/srv/media/alice/`, usually with a size
|
|
103
|
+
cap (`cap_gb`). windarr counts what's in the folder, a hardlinked file once, and uses what's
|
|
104
|
+
left under the cap, or the disk's free space if that's less.
|
|
105
|
+
|
|
106
|
+
## Install
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
pipx install windarr
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
[pipx](https://pipx.pypa.io) puts windarr in its own environment and links the `windarr` command
|
|
113
|
+
into `~/.local/bin`. To upgrade, use `pipx upgrade windarr`. You can also install the latest
|
|
114
|
+
code from the repository: `pipx install git+https://gitlab.com/mimperatori/windarr.git`.
|
|
115
|
+
|
|
116
|
+
The source is on [GitLab](https://gitlab.com/mimperatori/windarr), with a mirror on
|
|
117
|
+
[GitHub](https://github.com/maximeimperatori/windarr).
|
|
118
|
+
|
|
119
|
+
## Set up the other apps
|
|
120
|
+
|
|
121
|
+
windarr only steers Sonarr and Radarr. Each user's downloads still have to land in that user's
|
|
122
|
+
space, which is set up in the apps themselves:
|
|
123
|
+
|
|
124
|
+
1. **Spaces.** Each user gets a volume or folder, with a library folder in it (as a
|
|
125
|
+
Sonarr/Radarr root folder) and one or more download folders.
|
|
126
|
+
2. **Tags.** In Sonarr and Radarr, create a tag named after each user. A user's titles are the
|
|
127
|
+
ones that carry their tag and are stored in their space.
|
|
128
|
+
3. **Download clients.** Give each user a download client, or a category in a shared one, that
|
|
129
|
+
saves to their download folders and carries their tag in Sonarr/Radarr. A user without
|
|
130
|
+
download clients of their own uses the untagged ones.
|
|
131
|
+
4. **Seerr.** Add override rules that give each user's requests their root folder, quality
|
|
132
|
+
profile and tag. Admins skip override rules, so give each person a normal (non-admin) Seerr
|
|
133
|
+
account. Turn off "Enable Automatic Search" for Sonarr in Seerr, because windarr does the
|
|
134
|
+
searching.
|
|
135
|
+
5. **Deleting watched files.** Set up Media Cleaner (or similar) to delete what each user has
|
|
136
|
+
watched in their space.
|
|
137
|
+
|
|
138
|
+
### Settings windarr checks
|
|
139
|
+
|
|
140
|
+
windarr checks these settings every hour, and stops changing anything while one is wrong:
|
|
141
|
+
|
|
142
|
+
- In Sonarr/Radarr: "Use Hardlinks instead of Copy", "Unmonitor Deleted Episodes/Movies" and
|
|
143
|
+
"Completed Download Handling" are on.
|
|
144
|
+
- In Seerr: "Enable Automatic Search" is off for Sonarr, and each user's `seerr_id` is the Seerr
|
|
145
|
+
account of their Jellyfin user.
|
|
146
|
+
- For qBittorrent and SABnzbd: each category's folder is in its user's download folders. For
|
|
147
|
+
qBittorrent, "Use Category paths in Manual Mode" is on too.
|
|
148
|
+
|
|
149
|
+
Separately, windarr sends a push once about each queued download that isn't in its user's
|
|
150
|
+
download folders, since it counts against the wrong space and may be copied instead of
|
|
151
|
+
hardlinked. That one doesn't stop it.
|
|
152
|
+
|
|
153
|
+
## Configure
|
|
154
|
+
|
|
155
|
+
Copy [`config.example.toml`](https://gitlab.com/mimperatori/windarr/-/blob/main/config.example.toml)
|
|
156
|
+
to `~/.config/windarr/config.toml` and fill it in. Every option is documented in that file:
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
mkdir -p ~/.config/windarr
|
|
160
|
+
curl -o ~/.config/windarr/config.toml https://gitlab.com/mimperatori/windarr/-/raw/main/config.example.toml
|
|
161
|
+
``` Only the users and Seerr's `settings.json` are
|
|
162
|
+
required:
|
|
163
|
+
|
|
164
|
+
```toml
|
|
165
|
+
[users.alice] # named after alice's Sonarr/Radarr tag
|
|
166
|
+
volume = "/Volumes/Alice/" # a volume of her own
|
|
167
|
+
downloads = "/Volumes/Alice/Downloads/"
|
|
168
|
+
jellyfin_user = "alice"
|
|
169
|
+
seerr_id = 2
|
|
170
|
+
|
|
171
|
+
[users.bob]
|
|
172
|
+
folder = "/srv/media/bob/" # or a folder, here with a 500 GB cap
|
|
173
|
+
cap_gb = 500
|
|
174
|
+
downloads = "/srv/media/bob/downloads/"
|
|
175
|
+
jellyfin_user = "bob"
|
|
176
|
+
seerr_id = 3
|
|
177
|
+
|
|
178
|
+
[seerr]
|
|
179
|
+
settings = "~/.config/seerr/settings.json"
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
- Write paths exactly as Sonarr, Radarr and your download clients report them, letter case
|
|
183
|
+
included. windarr compares them as written.
|
|
184
|
+
- windarr reads the files at those paths too, and has no path mapping. If Sonarr, Radarr or a
|
|
185
|
+
download client runs in a container, mount the media at the same path everywhere, or run
|
|
186
|
+
windarr where those paths exist.
|
|
187
|
+
- windarr leaves a user alone while their space isn't there. On a drive that isn't mounted,
|
|
188
|
+
everything would look deleted and every show dropped. A volume has to be mounted. In a
|
|
189
|
+
folder, windarr makes an empty `.windarr` file the first time, once the Sonarr/Radarr root
|
|
190
|
+
folders in it exist, and remembers it. If that file is gone later, windarr stops for that
|
|
191
|
+
user. If the folder moved on purpose, put the file back (`touch <folder>/.windarr`).
|
|
192
|
+
- If the file holds your ntfy topic, make it readable only by you (`chmod 600`).
|
|
193
|
+
|
|
194
|
+
Then run `windarr --dry-run` and read what it would do.
|
|
195
|
+
|
|
196
|
+
## Run it every minute
|
|
197
|
+
|
|
198
|
+
windarr is meant to run every minute. A run prints only what it changes, so a log stays short.
|
|
199
|
+
|
|
200
|
+
windarr pushes the problems it finds itself (see [Pushes](#pushes)).
|
|
201
|
+
[`examples/notify-on-fail`](https://gitlab.com/mimperatori/windarr/-/blob/main/examples/notify-on-fail) is an optional safety net for when it can't.
|
|
202
|
+
It's a wrapper that sends an ntfy push when a run exits with an error. windarr only does that
|
|
203
|
+
when its own push didn't go out: it has no config, can't read it, has no working notifier, or
|
|
204
|
+
crashed. To use it, put it in `~/.local/bin`, and put `NTFY_URL=https://ntfy.sh/<your-topic>` in
|
|
205
|
+
`~/.config/notify-on-fail/config`:
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
curl -o ~/.local/bin/notify-on-fail https://gitlab.com/mimperatori/windarr/-/raw/main/examples/notify-on-fail
|
|
209
|
+
chmod 755 ~/.local/bin/notify-on-fail
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
windarr then uses the same topic for its own pushes, unless its config's `[notifiers.ntfy]`
|
|
213
|
+
section says otherwise. The other examples below are in the repository too: open one and
|
|
214
|
+
download it, or fetch its raw file with `curl -O`.
|
|
215
|
+
|
|
216
|
+
**macOS (launchd):** edit and load [`examples/windarr.plist`](https://gitlab.com/mimperatori/windarr/-/blob/main/examples/windarr.plist); its
|
|
217
|
+
comment says how. A launchd job may only read external volumes if the program itself was given
|
|
218
|
+
access to removable volumes. Here that program is the Python of windarr's pipx environment (a
|
|
219
|
+
link to the Python pipx used). If macOS shows a prompt on the Mac's screen, approve it; otherwise
|
|
220
|
+
grant access under System Settings > Privacy & Security (Files and Folders, or Full Disk Access).
|
|
221
|
+
|
|
222
|
+
**Linux (systemd):** copy [`examples/windarr.service`](https://gitlab.com/mimperatori/windarr/-/blob/main/examples/windarr.service) and
|
|
223
|
+
[`examples/windarr.timer`](https://gitlab.com/mimperatori/windarr/-/blob/main/examples/windarr.timer) to `~/.config/systemd/user/`, then:
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
systemctl --user daemon-reload
|
|
227
|
+
systemctl --user enable --now windarr.timer
|
|
228
|
+
loginctl enable-linger "$USER" # keep it running while you're logged out
|
|
229
|
+
journalctl --user -u windarr # its output
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
**cron** (either system):
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
* * * * * $HOME/.local/bin/notify-on-fail windarr $HOME/.local/bin/windarr >> $HOME/windarr.log 2>&1
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Usage
|
|
239
|
+
|
|
240
|
+
```
|
|
241
|
+
windarr normal run (prints only what it changes)
|
|
242
|
+
windarr --dry-run show the windows and what it would do; changes nothing
|
|
243
|
+
windarr -v a normal run that also prints the windows
|
|
244
|
+
windarr --release monitor everything it held back again, and forget it
|
|
245
|
+
windarr --undrop TITLE stop treating a show as dropped
|
|
246
|
+
windarr --config FILE another config file (or set $WINDARR_CONFIG)
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
- Tag a series or movie `no-window` in Sonarr/Radarr to keep windarr away from it.
|
|
250
|
+
- windarr keeps its state in `~/.local/state/windarr/state.json`. Deleting that file starts
|
|
251
|
+
over, but it also forgets what was held back, so run `windarr --release` first.
|
|
252
|
+
- To stop using windarr, run `windarr --release` and stop running it. Sonarr then downloads
|
|
253
|
+
everything that's monitored again.
|
|
254
|
+
- The exit code is 1 when a scheduled run hit a problem nobody was told about, because no
|
|
255
|
+
notifier got its push. A problem windarr pushed itself exits 0, so `notify-on-fail` doesn't
|
|
256
|
+
push it twice. A run by hand exits 1 for any problem, and prints it instead of pushing it.
|
|
257
|
+
|
|
258
|
+
## Pushes
|
|
259
|
+
|
|
260
|
+
windarr pushes only when something needs a look, and each problem once. That covers a setting
|
|
261
|
+
that's wrong, an app it can't reach for a while, a download that won't be imported, a request
|
|
262
|
+
for a title in someone else's library, or an error. Every notifier that's set up gets every
|
|
263
|
+
push.
|
|
264
|
+
|
|
265
|
+
- **ntfy** is built in: set `[notifiers.ntfy] url` in the config to your topic's URL, on
|
|
266
|
+
[ntfy.sh](https://ntfy.sh) or a server of your own (or set `$NTFY_URL`).
|
|
267
|
+
- **Other notifiers** can come from packages (see [Writing a plugin](#writing-a-plugin)), set
|
|
268
|
+
up in a `[notifiers.<name>]` section.
|
|
269
|
+
|
|
270
|
+
## Download clients
|
|
271
|
+
|
|
272
|
+
windarr works with any download client Sonarr and Radarr can use. It learns what it needs about
|
|
273
|
+
downloads from their queues. An adapter adds what only the client itself can do:
|
|
274
|
+
|
|
275
|
+
- **qBittorrent** (the instance at `[clients.QBittorrent] url`, with the Web UI's "Bypass authentication
|
|
276
|
+
for clients on localhost" on; another instance counts as a client without an adapter):
|
|
277
|
+
- removes seeding copies once the library copy is deleted, and downloads that were never
|
|
278
|
+
imported
|
|
279
|
+
- imports re-grabs Sonarr/Radarr won't import by themselves
|
|
280
|
+
- resumes torrents stuck after a full disk
|
|
281
|
+
- measures in-flight downloads exactly
|
|
282
|
+
- checks its category folders ahead of time
|
|
283
|
+
- **SABnzbd:** removes failed jobs' `_FAILED_` folders, and checks its category folders ahead of
|
|
284
|
+
time, read from `sabnzbd.ini` (see `[clients.Sabnzbd]` in the config).
|
|
285
|
+
|
|
286
|
+
**Re-grabs with another torrent client.** Sonarr/Radarr remember every download they've imported
|
|
287
|
+
until they restart, and a torrent of the same release has the same id. So when one is grabbed
|
|
288
|
+
again, they won't import it. Without an adapter, windarr sends a push about each such re-grab
|
|
289
|
+
once, so you can import it by hand. Usenet doesn't have this problem.
|
|
290
|
+
|
|
291
|
+
windarr uses one adapter per kind (torrent and usenet). With two torrent clients that both have
|
|
292
|
+
an adapter, the second one is handled like a client without an adapter.
|
|
293
|
+
|
|
294
|
+
## Writing a plugin
|
|
295
|
+
|
|
296
|
+
Download client adapters and notifiers are plugins: classes a separate package can add through
|
|
297
|
+
an entry point group. The built-in ones (qBittorrent, SABnzbd and ntfy) ship with windarr and
|
|
298
|
+
are set up in the same kind of section, such as `[clients.QBittorrent]` or `[notifiers.ntfy]`.
|
|
299
|
+
They show what's needed:
|
|
300
|
+
|
|
301
|
+
| plugin | entry point group | built in | the methods one needs | its config section |
|
|
302
|
+
| --- | --- | --- | --- | --- |
|
|
303
|
+
| download client adapter | `windarr.clients` | [`src/windarr/clients/`](https://gitlab.com/mimperatori/windarr/-/blob/main/src/windarr/clients/) | [`clients/__init__.py`](https://gitlab.com/mimperatori/windarr/-/blob/main/src/windarr/clients/__init__.py) | `[clients.<name>]` |
|
|
304
|
+
| notifier | `windarr.notifiers` | [`src/windarr/notifiers/`](https://gitlab.com/mimperatori/windarr/-/blob/main/src/windarr/notifiers/) | [`notifiers/__init__.py`](https://gitlab.com/mimperatori/windarr/-/blob/main/src/windarr/notifiers/__init__.py) | `[notifiers.<name>]` |
|
|
305
|
+
|
|
306
|
+
An adapter's entry point is named after the implementation name Sonarr/Radarr report for its
|
|
307
|
+
client. A notifier's is named after its config section:
|
|
308
|
+
|
|
309
|
+
```toml
|
|
310
|
+
# the plugin package's pyproject.toml
|
|
311
|
+
[project.entry-points."windarr.clients"]
|
|
312
|
+
Transmission = "windarr_transmission:Transmission"
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Install it into windarr's environment with `pipx inject windarr windarr-transmission`. Its
|
|
316
|
+
settings go in windarr's config and are passed to the plugin:
|
|
317
|
+
|
|
318
|
+
```toml
|
|
319
|
+
[clients.Transmission]
|
|
320
|
+
url = "http://localhost:9091"
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
windarr goes on without a plugin it can't load or that fails, and pushes once about it.
|
|
324
|
+
|
|
325
|
+
## Development
|
|
326
|
+
|
|
327
|
+
```
|
|
328
|
+
git clone https://gitlab.com/mimperatori/windarr.git && cd windarr
|
|
329
|
+
python3 tests/test_windarr.py # scenario tests against fake Sonarr/Radarr/qBittorrent/Jellyfin/Seerr
|
|
330
|
+
python3 tests/test_windarr.py --base REV # also run them on an older git revision, to see what a change fixes
|
|
331
|
+
python3 tests/namecheck.py # undefined names (what pyflakes would catch, standard library only)
|
|
332
|
+
pipx install --force . # install this checkout
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
The tests never touch a real app, config, state file or push.
|
|
336
|
+
|
|
337
|
+
The code is in [`src/windarr/`](https://gitlab.com/mimperatori/windarr/-/blob/main/src/windarr/):
|
|
338
|
+
|
|
339
|
+
| module | what's in it |
|
|
340
|
+
| --- | --- |
|
|
341
|
+
| `cli.py` | the command line, and a run from start to finish |
|
|
342
|
+
| `settings.py` | the config file and the constants |
|
|
343
|
+
| `apps.py` | connecting to Sonarr, Radarr, Seerr and Jellyfin, and what a run reads from them |
|
|
344
|
+
| `titles.py` | Seerr requests and seasons, shared titles, pruning empty titles |
|
|
345
|
+
| `window.py` | the windows: each user's next episodes, dropped shows, season packs, the report |
|
|
346
|
+
| `downloads.py` | queues and history, cleanup, re-grabs, imports refused for free space |
|
|
347
|
+
| `checks.py` | the hourly setup check |
|
|
348
|
+
| `clients/` | the download client adapters |
|
|
349
|
+
| `notifiers/` | where pushes go (ntfy built in) |
|
|
350
|
+
| `state.py`, `util.py` | the state file; logging, pushes, the API client |
|
|
351
|
+
|
|
352
|
+
GitLab CI runs the tests and the name check on Linux for every push, on Python 3.11 and the newest
|
|
353
|
+
Python. To release, set `__version__` in `src/windarr/__init__.py`, commit, then push a tag that names
|
|
354
|
+
it (`git tag -a v0.2.0 -m "windarr 0.2.0" && git push origin v0.2.0`). The tag's pipeline builds
|
|
355
|
+
windarr and publishes it to PyPI through [Trusted Publishing](https://docs.pypi.org/trusted-publishers/),
|
|
356
|
+
so no PyPI token is stored anywhere.
|
|
357
|
+
|
|
358
|
+
## License
|
|
359
|
+
|
|
360
|
+
MIT, see [LICENSE](https://gitlab.com/mimperatori/windarr/-/blob/main/LICENSE).
|