Various scripts used for managing my media server setup.
Go to file
Alex Thomassen 32dfc69be0
[qBitTorrent] Don't forget to require the helpers
2024-04-18 20:29:58 +00:00
config [qBitTorrent] Add script for updating tracker URLs 2024-04-16 08:23:08 +00:00
lib [qBitTorrent] Don't forget to require the helpers 2024-04-18 20:29:58 +00:00
output Update dead trackers script to add tag to torrents 2023-03-05 13:29:50 +00:00
.editorconfig [Refactor] Move some functions into helper class 2024-04-15 19:43:50 +00:00
.env.example [qBitTorrent] Add script for updating tracker URLs 2024-04-16 08:23:08 +00:00
.gitignore Add qBitTorrent files from DevScripts repo 2023-02-04 16:31:19 +00:00
README.md [Refactor] Move some functions into helper class 2024-04-15 19:43:50 +00:00
common.php Update dead trackers script to add tag to torrents 2023-03-05 13:29:50 +00:00
composer.json Add qBitTorrent files from DevScripts repo 2023-02-04 16:31:19 +00:00
composer.lock Add qBitTorrent files from DevScripts repo 2023-02-04 16:31:19 +00:00
qBitTorrentDumpBasicTorrentInfo.php Add qBitTorrent files from DevScripts repo 2023-02-04 16:31:19 +00:00
qBitTorrentRecheckErrored.php Add qBitTorrent files from DevScripts repo 2023-02-04 16:31:19 +00:00
qBitTorrentSearchDeadTrackers.php Update dead trackers script to add tag to torrents 2023-03-05 13:29:50 +00:00
qBitTorrentTagPublic.php Fix public tag tracker script 2023-10-24 09:46:02 +00:00
qBitTorrentTagTrackers.php [Refactor] Move some functions into helper class 2024-04-15 19:43:50 +00:00
qBitTorrentUpdateTrackerURLs.php [qBitTorrent] Add script for updating tracker URLs 2024-04-16 08:23:08 +00:00

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

  1. Copy .env.example to .env and fill in the values.
  2. Run composer install to install dependencies.
  3. 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.
  • 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 than QBITTORRENT_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.
  • 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 of QBITTORRENT_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.