/unpackerr

Extracts downloads for Radarr, Sonarr, Lidarr - Deletes extracted files after import

Primary LanguageGoMIT LicenseMIT

  • formerly unpacker-poller
  • formerly deluge-unpacker

About

This application runs as a daemon on your download host. It checks for completed downloads and extracts them so Radarr, Lidarr, Sonarr, and Readarr may import them. There are a handful of options out there for extracting and deleting files after your client downloads them. I just didn't care for any of them, so I wrote my own. I wanted a small single-binary with reasonable logging that can extract downloaded archives and clean up the mess after they've been imported.

Installation

  • Note: Requires access to your download location. Make sure you set the path variables correctly in the configuration. Even if they're set incorrectly this app makes a best effort attempt to locate your downloads.

Docker

This project builds automatically in Docker Cloud and creates ready-to-use multi-architecture images. The latest tag is always a tagged release in GitHub. The master tag corresponds to the master branch in GitHub and may be broken.

Use the methods below to install using Docker.

unRAID (Docker)

Docker Config File

  • Copy the example config file from this repo.
  • Then grab the image from docker hub and run it using an overlay for the config file.
docker pull golift/unpackerr
docker run -d -v /mnt/HostDownloads:/downloads -v /your/config/unpackerr.conf:/etc/unpackerr/unpackerr.conf golift/unpackerr
docker logs <container id from docker run>

Docker Env Variables

  • Instead of a config file, you may configure the docker container with environment variables.
  • Any variable not provided takes the default.
  • Must provide URL and API key for Sonarr or Radarr or Lidarr or any combination.
  • You may provide multiple sonarr, radarr or lidarr instances using UN_SONARR_1_URL, UN_SONARR_2_URL, etc.
Config Name Variable Name Default / Note
debug UN_DEBUG false / Turns on more logs
log_file UN_LOG_FILE None by default. Optionally provide a file path to write logs
log_files UN_LOG_FILES 10 / Log files to keep after rotating. 0 disables rotation
log_file_mb UN_LOG_FILE_MB 10 / Max size of log files in megabytes
interval UN_INTERVAL 2m / How often apps are polled, recommend 1m to 5m
timeout UN_TIMEOUT 10s / Global API Timeouts (all apps default)
delete_delay UN_DELETE_DELAY 5m / Extracts are deleted this long after import
start_delay UN_START_DELAY 1m / Files are queued at least this long before extraction
retry_delay UN_RETRY_DELAY 5m / Failed extractions are retried after at least this long
max_retries UN_MAX_RETRIES 3 / Times to retry failed extractions. 0 = unlimited.
parallel UN_PARALLEL 1 / Concurrent extractions, only recommend 1
file_mode UN_FILE_MODE 0644 / Extracted files are written with this mode
dir_mode UN_DIR_MODE 0755 / Extracted folders are written with this mode
Sonarr
Config Name Variable Name Default / Note
sonarr.url UN_SONARR_0_URL No Default. Something like: http://localhost:8989
sonarr.api_key UN_SONARR_0_API_KEY No Default. Provide URL and API key if you use Sonarr
sonarr.paths UN_SONARR_0_PATHS_0 /downloads List of paths where content is downloaded for Sonarr
sonarr.protocols UN_SONARR_0_PROTOCOLS torrent Protocols to process. Alt: torrent,usenet
Radarr
Config Name Variable Name Default / Note
radarr.url UN_RADARR_0_URL No Default. Something like: http://localhost:7878
radarr.api_key UN_RADARR_0_API_KEY No Default. Provide URL and API key if you use Radarr
radarr.paths UN_RADARR_0_PATHS_0 /downloads List of paths where content is downloaded for Radarr
radarr.protocols UN_RADARR_0_PROTOCOLS torrent Protocols to process. Alt: torrent,usenet
Lidarr
Config Name Variable Name Default / Note
lidarr.url UN_LIDARR_0_URL No Default. Something like: http://localhost:8686
lidarr.api_key UN_LIDARR_0_API_KEY No Default. Provide URL and API key if you use Lidarr
lidarr.paths UN_LIDARR_0_PATHS_0 /downloads List of paths where content is downloaded for Lidarr
lidarr.protocols UN_LIDARR_0_PROTOCOLS torrent Protocols to process. Alt: torrent,usenet
Readarr
Config Name Variable Name Default / Note
readarr.url UN_READARR_0_URL No Default. Something like: http://localhost:8787
readarr.api_key UN_READARR_0_API_KEY No Default. Provide URL and API key if you use Readarr
readarr.paths UN_READARR_0_PATHS_0 /downloads List of paths where content is downloaded for Readarr
readarr.protocols UN_READARR_0_PROTOCOLS torrent Protocols to process. Alt: torrent,usenet
Folder

Folders are a way to watch a folder for things to extract. You can use this to monitor your download client's "move to" path if you're not using it with an *arr app.

Config Name Variable Name Default / Note
folder.path UN_FOLDER_0_PATH No Default; folder to watch for archives. Not for Starr apps
folder.delete_after UN_FOLDER_0_DELETE_AFTER 10m Delete extracted files and/or archives after this duration; 0 disables
folder.delete_original UN_FOLDER_0_DELETE_ORIGINAL false Delete archives after successful extraction
folder.delete_fils UN_FOLDER_0_DELETE_FILES false Delete extracted files after successful extraction
folder.move_back UN_FOLDER_0_MOVE_BACK false Move extracted items back into original folder
Webhooks

This application can send a POST webhook to a URL when an extraction begins, and again when it finishes. Configure 1 or more webhook URLs with the parameters below. Works great with discordnotifier.com. You can use requestbin.com to test and see the payload.

Config Name Variable Name Default / Note
webhook.url UN_WEBHOOK_0_URL No Default; URL to send POST webhook to
webhook.name UN_WEBHOOK_0_NAME Defaults to URL; provide an optional name to hide the URL in logs
webhook.timeout UN_WEBHOOK_0_TIMEOUT Defaults to global timeout, usually 10s
webhook.silent UN_WEBHOOK_0_SILENT false / Hide successful POSTs from logs
webhook.ignore_ssl UN_WEBHOOK_0_IGNORE_SSL false / Ignore invalid SSL certificates
webhook.exclude UN_WEBHOOK_0_EXCLUDE [] / List of apps to exclude: radarr, sonarr, folders, etc
webhook.events UN_WEBHOOK_0_EVENTS [0] / List of event IDs to send (shown below)

Event IDs (not all of these are used in webhooks): 0 = all, 1 = queued, 2 = extracting, 3 = extract failed, 4 = extracted, 5 = imported, 6 = deleting, 7 = delete failed, 8 = deleted

Example Usage
docker pull golift/unpackerr
docker run -d -v /mnt/HostDownloads:/downloads -e "UN_SONARR_0_URL=http://localhost:8989" -e "UN_SONARR_0_API_KEY=kjsdkasjdaksdj" golift/unpackerr
docker logs <container id from docker run>

More Dockers!

If you want a container that has a bit more to it, you can try a third party option. The container provided by golift is from scratch so it has nothing more than a binary and a config file (with our defaults).

Linux and FreeBSD Install

  • Download a package from the Releases page.
  • Install it, edit config, start it.

Example of the above in shell form:

wget -qO- https://golift.io/unpackerr/raw/master/scripts/install.sh | sudo bash

nano /etc/unpackerr/unpackerr.conf         # linux
vi /usr/local/etc/unpackerr/unpackerr.conf # freebsd

sudo systemctl restart unpackerr    # linux
service unpackerr start             # freebsd

On Linux, unpackerr runs as user:group unpackerr:unpackerr. You will need to give that user or group read and write access to your archives. That may mean adding the unpackerr user, for example, to the debian-transmission group.

On FreeBSD the app runs as nobody. That's not very good and will probably change in the future.

macOS Install

  • Use homebrew.
  • Edit config file at /usr/local/etc/unpackerr/unpackerr.conf
  • Start it.
  • Like this:
brew install golift/mugs/unpackerr
vi /usr/local/etc/unpackerr/unpackerr.conf
brew services start unpackerr

Windows Install

  • Create this folder: C:\ProgramData\unpackerr\
  • Extract a .exe.zip file from the Releases page into C:\ProgramData\unpackerr\
  • Edit the example config file from the zip file to suit your system. Rename the example to unpackerr.conf.
  • Run the unpackerr.amd64.exe binary. This starts the app prints out what it's doing.
  • Better directions, nor an automated installer are currently available. Sorry. Tracking here.

Troubleshooting

Make sure your Downloads location matches on all your applications! Find help on Discord.

Log files:

  • Linux: /var/log/messages or /var/log/syslog (w/ default syslog)
  • FreeBSD: /var/log/syslog (w/ default syslog)
  • macOS: /usr/local/var/log/unpackerr.log

If transfers are in a Warning or Error state they will not be extracted. Try the Force Recheck option if you use Deluge.

Still having problems? Let me know!

Logic

The application polls radarr, sonarr and lidarr at the interval configured. The queued items are inspected for completeness. The interval of these pollers is set in the config file. 1-10 minutes is generally sufficient.

When Unpackerr finds an item in Sonarr or Radarr or Lidarr the download location is checked for a .rar file. If an extractable archive exists, and Sonarr/Radarr/Lidarr has status=Completed from your download client Unpackerr will extract the file. Files are extracted to a temporary folder, and then moved back into the download location for Completed Download Handling to import them. When the item falls out of the (Radarr/Sonarr/Lidarr) queue, the extracted files are deleted.

Contributing

Yes, please.

License

MIT - Copyright (c) 2018 David Newhall II