Skip to content

Instantly share code, notes, and snippets.

@cutiepoka
Created April 13, 2024 12:02
Show Gist options
  • Save cutiepoka/aa9c7538ea333baee33faf9bac238482 to your computer and use it in GitHub Desktop.
Save cutiepoka/aa9c7538ea333baee33faf9bac238482 to your computer and use it in GitHub Desktop.
Restart web QBittorrent torrents that are stuck in the 'not contacted yet' state.
from qbittorrentapi import Client
# instantiate a Client using the appropriate WebUI configuration
client = Client(host='https://localhost:8080', username='YOUR_USERNAME', password='YOUR_PASSWORD',VERIFY_WEBUI_CERTIFICATE=False)
# Loop through all torrents
for torrent in client.torrents_info(status_filter='completed', category='named_category_that_is_an_issue'):
# Check if the tracker status is 'not contacted yet'
for tracker in torrent.trackers:
if tracker.status == 1:
print('restarted' + torrent.name)
# Pause and then restart the torrent
client.torrents_pause(torrent_hashes=torrent.hash)
client.torrents_resume(torrent_hashes=torrent.hash)
print('success')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment