config | ||
lib | ||
output | ||
.editorconfig | ||
.env.example | ||
.gitignore | ||
common.php | ||
composer.json | ||
composer.lock | ||
qBitTorrentDumpBasicTorrentInfo.php | ||
qBitTorrentRecheckErrored.php | ||
qBitTorrentSearchDeadTrackers.php | ||
qBitTorrentTagPublic.php | ||
qBitTorrentTagTrackers.php | ||
qBitTorrentUpdateTrackerURLs.php | ||
README.md |
MediaServerScripts
Various scripts I've written to help manage my media server.
Requirements
- PHP 8.1+
- Composer for PHP
- qBitTorrent with web UI enabled and accessible from where you are planning to run the scripts.
Setup
- Copy
.env.example
to.env
and fill in the values. - Run
composer install
to install dependencies. - Run a test using
php qBitTorrentDumpBasicTorrentInfo.php
to make sure your authentication will succeed.
Apps
qBitTorrent
Dump Basic Torrent Info
This script will dump basic information about all torrents loaded into your qBitTorrent instance. It will output a JSON file for each torrent in the output
folder. The script will print the full path to the written file.
Recheck Errored
For any torrents in qBitTorrent that have status "errored" and 0% progress, this will trigger a force recheck.
I don't use this often, pretty much only when I've been doing updates to qBitTorrent without stopping the process properly first - or the server has crashed.
Search Dead Trackers
Named somewhat poorly. This script does the following:
- Checks all torrents to see if all trackers are 'dead'. Meaning that all trackers on a torrent is either unresponsive, or returning some form of error.
- If all trackers are dead, it will tag the torrent with a currently hardcoded tag:
dead-trackers
- TODO: Add it to
.env
and make it configurable.
- TODO: Add it to
- Writes a JSON file with some basic torrent information into the
output
folder. The script will print the full path to the written file.
The idea for this script was to make it easier to clean up torrents of individual episodes and replace them with season packs (if wanted).
Tag Public
- Takes all torrents and checks if a torrent has 5 or more trackers attached to it.
- If the
-o
flag is used, it will filter away any torrents that have been "Added on" less thanQBITTORRENT_PUBLIC_OLDER_THAN_HOURS
(in.env
) hours ago.- Intention here is to use it with
-l
, so it seeds the public torrent at "full speed" for a while before limiting the speed.
- Intention here is to use it with
- If it does, it will tag the torrent with the tag that's specified as
QBITTORRENT_PUBLIC_TAG
in.env
. - If the
-l
flag is used, it will also limit the torrent speed to the value ofQBITTORRENT_PUBLIC_MAX_RATE
in.env
.
Tag Trackers
Note: This requires that the file specified as QBITTORRENT_TRACKERS_FILE
in .env
exists - where {DIR}
is the current directory of where the script is saved.
A sample file on how the structure should be can be found in config/qbittorrent-trackers.sample.json
.
This will also write a JSON file to cache the tracker information for torrents to a file located in {DIR}/output/torrent-trackers-cache.json
.
- Grabs all torrents and then fetches all trackers for each torrent, unless trackers have been cached for this torrent.
- On the first time this runs, if you have a lot of torrents loaded in qBitTorrent, it will take a while to run.
- For each tracker, it will check if any of the torrent's trackers is in the list of trackers specified in the
QBITTORRENT_TRACKERS_FILE
file. - If it is, it will tag the torrent with the corresponding tag.