Adds Automatic Torrent Management. #66

This commit is contained in:
bobokun 2021-12-26 17:19:17 -05:00
parent 4cafdf1772
commit b42ef3328c
No known key found for this signature in database
GPG key ID: 9665BA6CF5DC2671
3 changed files with 22 additions and 3 deletions

View file

@ -7,6 +7,9 @@ qbt:
user: "username"
pass: "password"
settings:
force_auto_tmm: False #Will force qBittorrent to enable Automatic Torrent Managment for each torrent.
directory:
# Do not remove these
# Cross-seed var: </your/path/here/> # Output directory of cross-seed

View file

@ -32,7 +32,12 @@ class Config:
yaml.YAML().allow_duplicate_keys = True
try:
new_config, _, _ = yaml.util.load_yaml_guess_indent(open(self.config_path, encoding="utf-8"))
if "settings" not in new_config: new_config["settings"] = {}
if "cat" not in new_config: new_config["cat"] = {}
if "tracker" not in new_config: new_config["tracker"] = {}
if "qbt" in new_config: new_config["qbt"] = new_config.pop("qbt")
if "settings" in new_config: new_config["settings"] = new_config.pop("settings")
if "directory" in new_config: new_config["directory"] = new_config.pop("directory")
if "cat" in new_config: new_config["cat"] = new_config.pop("cat")
if "tracker" in new_config: new_config["tracker"] = new_config.pop("tracker")
@ -71,8 +76,10 @@ class Config:
raise Failed(f"YAML Error: {e}")
self.session = requests.Session()
if self.data["cat"] is None: self.data["cat"] = {}
if self.data["tracker"] is None: self.data["tracker"] = {}
self.settings = {
"force_auto_tmm": self.util.check_for_attribute(self.data, "force_auto_tmm", parent="settings", var_type="bool", default=False),
}
default_function = {'cross_seed':None,'recheck':None,'cat_update':None,'tag_update':None,'rem_unregistered':None,'rem_orphaned':None,'tag_nohardlinks':None,'empty_recyclebin':None}
self.webhooks = {

View file

@ -42,13 +42,22 @@ class Qbt:
# is_complete = Returns the state of torrent (Returns True if at least one of the torrent with the State is categorized as Complete.)
# first_hash = Returns the hash number of the original torrent (Assuming the torrent list is sorted by date added (Asc))
def get_torrent_info(torrent_list):
dry_run = self.config.args['dry_run']
loglevel = 'DRYRUN' if dry_run else 'INFO'
torrentdict = {}
t_obj_unreg = []
t_obj_valid = []
settings = self.config.settings
separator(f"Checking Settings", space=False, border=False)
if settings['force_auto_tmm']:
print_line(f'force_auto_tmm set to True. Will force Auto Torrent Management for all torrents.',loglevel)
separator(f"Gathering Torrent Information", space=True, border=True)
for torrent in alive_it(torrent_list):
is_complete = False
msg = None
status = None
if torrent.auto_tmm == False and settings['force_auto_tmm'] and not dry_run:
torrent.set_auto_management(True)
try:
torrent_name = torrent.name
torrent_hash = torrent.hash
@ -346,7 +355,7 @@ class Qbt:
'UNREGISTERED',
'TORRENT NOT FOUND',
'TORRENT IS NOT FOUND',
'NOT REGISTERED',
'NOT REGISTERED',
'HTTPS://BEYOND-HD.ME/TORRENTS',
'NOT EXIST',
'UNKNOWN TORRENT',