Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://gitlab.com/AlexKM/qbittools
https://gitlab.com/AlexKM/qbittools
Last synced: 4 days ago
JSON representation
- Host: gitlab.com
- URL: https://gitlab.com/AlexKM/qbittools
- Owner: AlexKM
- License: gpl-3.0+
- Created: 2021-01-07T19:15:07.225Z (almost 4 years ago)
- Default Branch: master
- Last Synced: 2024-08-02T14:06:02.241Z (3 months ago)
- Stars: 26
- Forks: 10
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-pt - qbittools
README
## Description
qbittools is a feature rich CLI for the management of torrents in qBittorrent.
## Donate
If you're feeling generous, you can support this project and me:
By renting a server with my affiliate link: https://my.hostingby.design/aff.php?aff=1008
USDT TRC20: `TUH5ySiTHYpG2vrPYu9uCT7ev6DLHDGzkG`
BUSD BEP20: `0xb8Eb3c011fB8549a67e8C2A33F55CEA2a5b152F3`
XMR: `44ow4aVdjJK7opDHpRsTiXV6hh5y1T7W81phsasJPBcARox7shnWCemDts6rC3icMA6AuBTV4cWR56dFujcLK7P2TYwBQZv`
BTC: `bc1q468wxv2uvy65ev5l7qlw5zcd0jd765hpncnayy`
BCH: `qpfspyeljf4d78jyw8p65jxcnxzmwjkk75kccnhuvf`
LTC: `ltc1qqtm7ss90t7cuzwrjzfwhjfjzt5rswjzftgz9ja`
ETH, USDT/BUSD ERC20: `0xb8Eb3c011fB8549a67e8C2A33F55CEA2a5b152F3`
Many thanks!
## Table of contents
- [Description](#description)
- [Donate](#donate)
- [Table of contents](#table-of-contents)
- [Requirements](#requirements)
- [Installation](#installation)
- [Binary version **(only Linux x86\_64)**](#binary-version-only-linux-x86_64)
- [Docker image](#docker-image)
- [Run as a python script](#run-as-a-python-script)
- [Building](#building)
- [Building binary manually with Docker (optional)](#building-binary-manually-with-docker-optional)
- [Configuration](#configuration)
- [Usage](#usage)
- [Help](#help)
- [Self-upgrade](#self-upgrade)
- [Subcommands](#subcommands)
- [Add](#add)
- [Operating system limits](#operating-system-limits)
- [ruTorrent / AutoDL](#rutorrent--autodl)
- [Unpause](#unpause)
- [Automatic unpause in qBittorrent](#automatic-unpause-in-qbittorrent)
- [Tagging](#tagging)
- [Automatic tagging with Cron](#automatic-tagging-with-cron)
- [Reannounce](#reannounce)
- [Reannounce with systemd](#reannounce-with-systemd)
- [Update passkey](#update-passkey)
- [Export](#export)
- [Mover](#mover)
- [Automatic moving with Cron](#automatic-moving-with-cron)
- [Orphaned](#orphaned)
- [FlexGet](#flexget)## Requirements
* Any usable Linux distribution (binary builds are built with musl and fully static starting from 0.4.0)
* ca-certificates (for connecting to https)* **binary builds are supported only for: Linux `x86_64` (limited by PyOxidizer support)**
* docker builds are supported for: Linux `amd64, arm64/v8, 386, arm/v6, arm/v7, ppc64le, s390x`, Windows and macOS with corresponding architectures, but which still use virtualization to launch Docker in a Linux VM.## Installation
### Binary version **(only Linux x86_64)**
Install the latest version with the install script to `/usr/local/bin/qbittools` (root privileges needed)
```bash
curl -Ls https://gitlab.com/AlexKM/qbittools/-/raw/master/install.sh | sudo bash
```Or at any path you want without any extra privileges, don't forget to add this path to `$PATH` for convenience:
```bash
mkdir -p ~/bin
curl -Ls https://gitlab.com/AlexKM/qbittools/-/raw/master/install.sh | bash -s -- -o ~/bin/qbittools
```The script creates a temporary directory, retrieves the latest git tag and downloads it's build artifacts that contains the resulting qbittools binary.
### Docker image
Run a container with access to host network:
```bash
docker run -it --rm --network host registry.gitlab.com/alexkm/qbittools tagging --unregistered -s 127.0.0.1:8080
```Connect to a qBittorrent container in the same Docker network:
```bash
docker run -it --rm --network mynetwork registry.gitlab.com/alexkm/qbittools tagging --unregistered -s qbittorrent:8080
```### Run as a python script
Click to expand```bash
# clone the repository
git clone https://gitlab.com/AlexKM/qbittools.git && cd qbittools
# create and activate virtual environment
virtualenv -p python3 venv
source venv/bin/activate
# install dependencies
pip3 install -r requirements.txt
# use qbittools.py
./qbittools.py tagging --unregistered -s 127.0.0.1:8080
```## Building
### Building binary manually with Docker (optional)
Click to expand```bash
# clone the repository
git clone https://gitlab.com/AlexKM/qbittools.git && cd qbittools
# build the image
docker buildx build --platform=linux/amd64 -t qbittools:latest -f Dockerfile.pyoxidizer --build-arg TARGET=x86_64-unknown-linux-musl --build-arg VERSION=0.0.0 --build-arg CACHE_DIR=linux_amd64 -o out/linux_amd64 .
```The resulting binary will be located at `out/linux_amd64/qbittools`.
## Configuration
qBittools doesn't have any configuration files currently. It parses host, port and username from the qBittorrent configuration file located by default at `~/.config/qBittorrent/qBittorrent.conf`, you can specify a different qBittorrent config with `-C` flag.
You also have to specify your password every time with `-P` flag unless you enable `Web UI -> Bypass authentication for clients on localhost` in qBittorrent's settings, because there is no way for qBittools to retrieve it in plaintext.
You also can specify host and username manually without a configuration file with `-s` and `-U` flags accordingly.
## Usage
### Help
All commands have extensive help with all available options:Click to expand
```bash
$ qbittools export -h
usage: qbittools export [-h] [-s 127.0.0.1] [-U username] [-P password] [-i ~/.local/share/qBittorrent/BT_backup] -o ~/export [-c mycategory] [-t [mytag ...]]optional arguments:
-h, --help show this help message and exit
-s 127.0.0.1, --server 127.0.0.1
host
-U username, --username username
-P password, --password password
-i ~/.local/share/qBittorrent/BT_backup, --input ~/.local/share/qBittorrent/BT_backup
Path to qBittorrent .torrent files
-o ~/export, --output ~/export
Path to where to save exported torrents
-c mycategory, --category mycategory
Filter by category
-t [mytag ...], --tags [mytag ...]
Filter by tags
```### Self-upgrade
Upgrading to the latest version is available with the `upgrade` command (use sudo if it's in a system path):
Click to expand
```bash
$ qbittools upgrade
07:24:14 PM INFO:Current version: 0.0.0
07:24:14 PM INFO:Latest version: 0.0.1
07:24:14 PM INFO:Update available, this will replace /usr/local/bin/qbittools with a new version.
OK to proceed [Y/N]? y
07:24:16 PM INFO:Downloading https://gitlab.com/AlexKM/qbittools/-/jobs/artifacts/0.0.1/download?job=release to /tmp/tmpapfpoqud/qbittools.zip
100%|██████████████████████████| 23.3M/23.3M [00:00<00:00, 107MiB/s]
07:24:17 PM INFO:Extracted binary to /tmp/tmpapfpoqud/qbittools
07:24:17 PM INFO:Replacing /usr/local/bin/qbittools with /tmp/tmpapfpoqud/qbittools
```### Subcommands
#### AddClick to expand
Add a single torrent with custom category
```bash
$ qbittools add /path/to/my.torrent -c mycategory
```Add a folder of torrents and assign multiple tags
```bash
$ qbittools add /path/to/folder -t mytag1 mytag2
```Add a torrent in paused state and skip hash checking
```bash
$ qbittools add /path/to/my.torrent --add-paused --skip-checking
```Don't add more torrents if there are more than 3 downloads active while ignoring downloads with speed under 1 MiB/s
```bash
$ qbittools add /path/to/my.torrent --max-downloads 3 --max-downloads-speed-ignore-limit 1024
```Pause all active torrents temporarily and mark them with `temp_paused` tag while ignoring active uploads with speed under 10 MiB/s (**You have** to configure unpause command in qBittorrent if you want these torrents to be unpaused automatically)
```bash
$ qbittools add /path/to/my.torrent --pause-active --pause-active-upspeed-ignore-limit 10240
```##### Operating system limits
If you encounter `too many open files` or `no file descriptors available` errors while adding a lot of torrents, you can try to bypass it with simple shell commands, this will add torrents one by one:
```bash
IFS=$'\n' find /path/to/your/torrents/ -maxdepth 1 -type f -name "*.torrent" -exec qbittools add {} --skip-checking \;
```##### ruTorrent / AutoDL
Adding torrents from autodl-irssi to qBittorrent using ruTorrent:
```
Action = Run Program
Command = /usr/local/bin/qbittools
Arguments = add $(TorrentPathName) -c music
```#### Unpause
Only useful if you pause torrents automatically with `--pause-active` parameters from add command.Resume all torrents with `temp_paused` tag if there are no active downloads while ignoring slow downloads under 10 MiB/s
```bash
$ qbittools unpause -d 10240
```##### Automatic unpause in qBittorrent
Check `Run external program on torrent completion` in the settings and use tool with an absolute path:
```
/usr/local/bin/qbittools unpause -d 10240
```#### Tagging
Create useful tags to group torrents by tracker domains, not working trackers, unregistered torrents and duplicates
```bash
$ qbittools tagging --duplicates --unregistered --not-working --added-on --trackers
```##### Automatic tagging with Cron
Execute every 10 minutes (`crontab -e` and add this entry)
```
*/10 * * * * /usr/local/bin/qbittools tagging --duplicates --unregistered --not-working --added-on --trackers
```#### Reannounce
Automatic reannounce on problematic trackers (run in screen/tmux to prevent it from closing when you end a ssh session):Click to expand
```bash
$ qbittools reannounce
07:40:40 PM --------------------------
07:40:40 PM [Movie.2020.2160p.WEB-DL.H264-GROUP] is not working, active for 1s, reannouncing...
07:41:20 PM --------------------------
07:41:20 PM [Movie.2020.2160p.WEB-DL.H264-GROUP] has no seeds, active for 78s, reannouncing...
07:41:25 PM --------------------------
07:41:25 PM [Movie.2020.2160p.WEB-DL.H264-GROUP] is active, progress: 0%
07:41:30 PM --------------------------
07:41:30 PM [Movie.2020.2160p.WEB-DL.H264-GROUP] is active, progress: 5.0%
07:41:35 PM --------------------------
07:41:35 PM [Movie.2020.2160p.WEB-DL.H264-GROUP] is active, progress: 11.1%
```##### Reannounce with systemd
Reannounce can be executed and restarted on problems automatically by systemd. Create a new service at `/etc/systemd/system/` with the following contents:Click to expand
```ini
[Unit]
Description=qbittools reannounce
After=qbittorrent@%i.service[Service]
User=%i
Group=%i
ExecStart=/usr/local/bin/qbittools reannounceRestart=always
RestartSec=3[Install]
WantedBy=multi-user.target
```Restart the daemon with `systemctl daemon-reload` and start the service with `systemctl start qbittools-reannounce@username` by replacing username with the user you want to run it from. Check service logs with `journalctl -u [email protected]` if necessary.
#### Update passkey
Update passkey in all matching torrents (all tracker urls that match `--old` parameter):
```bash
$ qbittools update_passkey --old 12345 --new v3rrjmnfxwq3gfrgs9m37dvnfkvdbqnqc
2021-01-08 21:38:45,301 INFO:Replaced [https://trackerurl.net/12345/announce] to [https://trackerurl.net/v3rrjmnfxwq3gfrgs9m37dvnfkvdbqnqc/announce] in 10 torrents
```#### Export
Export all matching .torrent files by category or tags:Click to expand
```bash
$ qbittools export -o ./export --category movies --tags tracker.org mytag
01:23:43 PM INFO:Matched 47 torrents
01:23:43 PM INFO:Exported [movies] Fatman.2020.BluRay.1080p.TrueHD.5.1.AVC.REMUX-FraMeSToR [fbef10dc89bf8dff21a401d9304f62b074ffd6af].torrent
01:23:43 PM INFO:Exported [movies] La.Haine.1995.UHD.BluRay.2160p.DTS-HD.MA.5.1.DV.HEVC.REMUX-FraMeSToR [ee5ff82613c7fcd2672e2b60fc64375486f976ba].torrent
01:23:43 PM INFO:Exported [movies] Ip.Man.3.2015.UHD.BluRay.2160p.TrueHD.Atmos.7.1.DV.HEVC.REMUX-FraMeSToR [07da008f9c64fe4927ee18ac5c94292f61098a69].torrent
01:23:43 PM INFO:Exported [movies] Brazil.1985.Director's.Cut.BluRay.1080p.FLAC.2.0.AVC.REMUX-FraMeSToR [988e8749a9d3f07e5d216001efc938b732579c16].torrent
```#### Mover
Useful for those who want to move torrents to different categories over time. Combined with enabled Automatic Torrent Management this will move files from one folder to another.Move torrents inactive for more than 60 seconds and completed more than 60 minutes ago from categories `tracker1` and `tracker2` to category `lts`
```bash
$ qbittools mover tracker1 tracker2 -d lts
```Move torrents inactive for more than 600 seconds and completed more than 30 minutes ago from category `racing` to category `lts`
```bash
$ qbittools mover racing -d lts --completion-threshold 30 --active-threshold 600
```##### Automatic moving with Cron
Execute every 10 minutes (`crontab -e` and add this entry)
```
*/10 * * * * /usr/local/bin/qbittools mover racing -d lts
```#### Orphaned
Find files no longer associated with any torrent, but still present in download folders (default download folder and folders from all categories). This command will remove orphaned files if you confirm it and also clean up all empty folders. _Be careful while removing a lot of files if you use these folders from other torrent client._
```bash
$ qbittools orphaned
```### FlexGet
qbittools can be used together with FlexGet via `exec` plugin, configuration example:
```yml
taskname:
rss:
url: https://site/feed.rss
all_entries: no
seen:
local: yes
accept_all: yes
download:
path: ~/torrents/rss/
overwrite: yes
exec:
auto_escape: yes
fail_entries: yes
on_output:
for_accepted:
- /usr/local/bin/qbittools add "{{location}}" -c books --rename "{{title}}" --content-layout Subfolder
```