Skip to content

Instantly share code, notes, and snippets.

@cobrce
Created March 14, 2021 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cobrce/f5a2f70291f5beef801c547fedf0b11e to your computer and use it in GitHub Desktop.
Save cobrce/f5a2f70291f5beef801c547fedf0b11e to your computer and use it in GitHub Desktop.
Script for qbittorrent, monitors a category of torrents (in this case tv-sonarr) and put them at the top of the queue, it uses python-qbittorrent module
from time import sleep
from qbittorrent import Client #pip3 install python-qbittorrent
link = "http://127.0.0.1:8080"
username = "admin"
password = "admin"
category = "tv-sonarr"
def main():
while True:
try:
qb = Client(link)
qb.login(username,password)
while True:
torrents =qb.torrents(category=category)
hash_priority = {t["hash"]:t["priority"] for t in torrents if t['progress']!=1.0}
if not hash_priority or (1 in hash_priority.values()):
break
qb.increase_priority(list(hash_priority.keys()))
sleep(0.5)
qb.logout()
except:
pass
sleep(30)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment