qbittorrent

> updating info
This commit is contained in:
2023-11-28 14:18:27 -08:00
parent 90f0ec70ca
commit 304ce26b62
2 changed files with 70 additions and 19 deletions

View File

@@ -1,22 +1,29 @@
#!/usr/lib/python3
#!/usr/bin/python3
#
# qBittorrent-api:
# https://qbittorrent-api.readthedocs.io/en/v2023.4.47/introduction.html
#
#
#
# Make sure to set the folling variables.
# <USERNAME>
# <SERVER IP ADDRESS>
# <PORT>
#
#
import re
import sys
import qbittorrentapi
# User access info
qbitt_username = '<username>'
qbitt_password = '<password>'
# qbittorrent webui login crendentials.
qbitt_username = '<USERNAME>'
qbitt_password = '<PASSWORD>'
# qbittorrent webui address.
#url = 'http://192.168.1.59:8080'
url = 'http://<ip_address>:<port>'
url = 'http://<SERVER IP ADDRESS>:<PORT>'
# The categories to use for matching torrents
# The categories to use for matching torrents. Change as needed.
category_1080_shows = "1080+ | Shows"
category_1080_movies = "1080+ | Movies"
@@ -31,22 +38,24 @@ torrents = qb.torrents_info()
# loop through the torrents
for torrent in torrents:
#print(torrent['name'])
#print(torrent['hash'])
# Get the name of the completed torrent from the command line arguments inside qbittorrent
torrent_name = sys.argv[1] # Name of the added torrent as defined by "%N" in qbittorrent settings.
torrent_hash = sys.argv[2] # Hash of the added torrent as defined by "%I" in qbittorrent settings.
#print(torrent_name)
#print(torrent_hash)
# Checking to see if added torrent is by YTS and is 1080p or 4k.
if "1080p" in torrent_name or "2160p" in torrent_name and "YTS.MX" in torrent_name:
# Define the regular expression pattern for 'SxxExx' or 'sxxexx' format.
pattern = r"[Ss]\d{2}[Ee]\d{2}"
# Set the category of the torrent.
# Check for 'SxxExx' or 'sxxexx' episode pattern and '1080p' or '2160p'
# If so, assign 1080 show category.
if re.search(pattern, torrent_name) and ("1080p" in torrent_name or "2160p" in torrent_name):
qb.torrents_set_category(category=category_1080_shows, hashes=torrent_hash)
qb.torrents_set_auto_management(hashes=torrent_hash, enable=True)
# Then check for movies criteria.
elif ("1080p" in torrent_name or "2160p" in torrent_name) and "YTS.MX" in torrent_name:
qb.torrents_set_category(category=category_1080_movies, hashes=torrent_hash)
# Set torrent to auto management to update the save path.
qb.torrents_set_auto_management(hashes=torrent_hash, enable=True)
qb.torrents_set_auto_management(hashes=torrent_hash, enable=True)
# Disconnect from the qBittorrent API
qb.auth_log_out()