diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..4fae6dc --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.jpg filter=lfs diff=lfs merge=lfs -text diff --git a/README.md b/README.md index 576c717..83c831f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1 @@ # test - diff --git a/assign_category.py b/assign_category.py new file mode 100644 index 0000000..ea58dae --- /dev/null +++ b/assign_category.py @@ -0,0 +1,52 @@ +#!/usr/lib/python3 +# +# qBittorrent-api: +# https://qbittorrent-api.readthedocs.io/en/v2023.4.47/introduction.html +# +# +# +import sys +import qbittorrentapi + +# User access info +qbitt_username = '' +qbitt_password = '' + +# qbittorrent webui address. +#url = 'http://192.168.1.59:8080' +url = 'http://:' + +# The categories to use for matching torrents +category_1080_shows = "1080+ | Shows" +category_1080_movies = "1080+ | Movies" + +# Connect to the qBittorrent API +qb = qbittorrentapi.Client(host=url) + +# Log in qbittorrent API +qb.auth_log_in(username=qbitt_username, password=qbitt_password) + +# Get information about all torrents in the download queue +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: + + # Set the category of the torrent. + 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) + +# Disconnect from the qBittorrent API +qb.auth_log_out()