Merge pull request #273 from StuffAnThings/develop

3.6.2
This commit is contained in:
bobokun 2023-04-24 20:18:44 -04:00 committed by GitHub
commit 1fa74bff68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 109 additions and 106 deletions

View file

@ -1,8 +1,6 @@
# Requirements Updated
- Updates qbitorrent api to 2023.4.47
# Bug Fixes # Bug Fixes
- Fixes bug in not removing empty directories (Thanks to @buthed010203 #266) - Fixes bug in cross_seed (Fixes #270)
- Speed up remove_orphan by using multiprocessing (Thanks to @buthed010203 #266) - Bug causing RecycleBin not to be created when full path is defined. (Fixes #271)
- Fixes Uncaught exception while emptying recycle bin (Fixes #272)
**Full Changelog**: https://github.com/StuffAnThings/qbit_manage/compare/v3.6.0...v3.6.1 **Full Changelog**: https://github.com/StuffAnThings/qbit_manage/compare/v3.6.1...v3.6.2

View file

@ -1 +1 @@
3.6.1 3.6.2

View file

@ -96,8 +96,6 @@ class Config:
self.data["cat_change"] = self.data.pop("cat_change") self.data["cat_change"] = self.data.pop("cat_change")
if "tracker" in self.data: if "tracker" in self.data:
self.data["tracker"] = self.data.pop("tracker") self.data["tracker"] = self.data.pop("tracker")
elif "tags" in self.data:
self.data["tracker"] = self.data.pop("tags")
else: else:
self.data["tracker"] = {} self.data["tracker"] = {}
if "nohardlinks" in self.data: if "nohardlinks" in self.data:
@ -521,6 +519,7 @@ class Config:
for name in files for name in files
] ]
location_files = sorted(location_files) location_files = sorted(location_files)
logger.trace(f"location_files: {location_files}")
if location_files: if location_files:
body = [] body = []
logger.separator(f"Emptying {location} (Files > {empty_after_x_days} days)", space=True, border=True) logger.separator(f"Emptying {location} (Files > {empty_after_x_days} days)", space=True, border=True)
@ -529,9 +528,16 @@ class Config:
folder = re.search(f".*{os.path.basename(location_path.rstrip(os.sep))}", file).group(0) folder = re.search(f".*{os.path.basename(location_path.rstrip(os.sep))}", file).group(0)
if folder != prevfolder: if folder != prevfolder:
body += logger.separator(f"Searching: {folder}", space=False, border=False) body += logger.separator(f"Searching: {folder}", space=False, border=False)
fileStats = os.stat(file) try:
filename = os.path.basename(file) fileStats = os.stat(file)
last_modified = fileStats[stat.ST_MTIME] # in seconds (last modified time) filename = os.path.basename(file)
last_modified = fileStats[stat.ST_MTIME] # in seconds (last modified time)
except FileNotFoundError:
ex = logger.print_line(
f"{location} Warning - FileNotFound: No such file or directory: {file} ", "WARNING"
)
self.config.notify(ex, "Cleanup Dirs", False)
continue
now = time.time() # in seconds now = time.time() # in seconds
days = (now - last_modified) / (60 * 60 * 24) days = (now - last_modified) / (60 * 60 * 24)
if empty_after_x_days <= days: if empty_after_x_days <= days:

View file

@ -39,7 +39,7 @@ class CrossSeed:
dest = os.path.join(self.qbt.torrentinfo[t_name]["save_path"], "") dest = os.path.join(self.qbt.torrentinfo[t_name]["save_path"], "")
src = os.path.join(dir_cs, file) src = os.path.join(dir_cs, file)
dir_cs_out = os.path.join(dir_cs, "qbit_manage_added", file) dir_cs_out = os.path.join(dir_cs, "qbit_manage_added", file)
category = self.qbt.global_max_ratioget_category(dest) category = self.qbt.get_category(dest)
# Only add cross-seed torrent if original torrent is complete # Only add cross-seed torrent if original torrent is complete
if self.qbt.torrentinfo[t_name]["is_complete"]: if self.qbt.torrentinfo[t_name]["is_complete"]:
categories.append(category) categories.append(category)

View file

@ -364,102 +364,92 @@ class Qbt:
except IndexError as e: except IndexError as e:
logger.debug(f"Tracker Url:{url}") logger.debug(f"Tracker Url:{url}")
logger.debug(e) logger.debug(e)
# Tracker Format 1 deprecated. tracker["tag"] = self.config.util.check_for_attribute(
if isinstance(tag_details, str): self.config.data, "tag", parent="tracker", subparent=tag_url, default=tag_url, var_type="list"
e = ( )
"Config Error: Tracker format invalid. Please see config.yml.sample for correct format and fix " if tracker["tag"] == [tag_url]:
f"`{tag_details}` in the Tracker section of the config." self.config.data["tracker"][tag_url]["tag"] = [tag_url]
if isinstance(tracker["tag"], str):
tracker["tag"] = [tracker["tag"]]
is_max_ratio_defined = self.config.data["tracker"].get("max_ratio")
is_max_seeding_time_defined = self.config.data["tracker"].get("max_seeding_time")
if is_max_ratio_defined or is_max_seeding_time_defined:
tracker["max_ratio"] = self.config.util.check_for_attribute(
self.config.data,
"max_ratio",
parent="tracker",
subparent=tag_url,
var_type="float",
min_int=-2,
do_print=False,
default=-1,
save=False,
)
tracker["max_seeding_time"] = self.config.util.check_for_attribute(
self.config.data,
"max_seeding_time",
parent="tracker",
subparent=tag_url,
var_type="int",
min_int=-2,
do_print=False,
default=-1,
save=False,
) )
self.config.notify(e, "Config")
raise Failed(e)
# Using new Format
else: else:
tracker["tag"] = self.config.util.check_for_attribute( tracker["max_ratio"] = self.config.util.check_for_attribute(
self.config.data, "tag", parent="tracker", subparent=tag_url, default=tag_url, var_type="list"
)
if tracker["tag"] == [tag_url]:
self.config.data["tracker"][tag_url]["tag"] = [tag_url]
if isinstance(tracker["tag"], str):
tracker["tag"] = [tracker["tag"]]
is_max_ratio_defined = self.config.data["tracker"].get("max_ratio")
is_max_seeding_time_defined = self.config.data["tracker"].get("max_seeding_time")
if is_max_ratio_defined or is_max_seeding_time_defined:
tracker["max_ratio"] = self.config.util.check_for_attribute(
self.config.data,
"max_ratio",
parent="tracker",
subparent=tag_url,
var_type="float",
min_int=-2,
do_print=False,
default=-1,
save=False,
)
tracker["max_seeding_time"] = self.config.util.check_for_attribute(
self.config.data,
"max_seeding_time",
parent="tracker",
subparent=tag_url,
var_type="int",
min_int=-2,
do_print=False,
default=-1,
save=False,
)
else:
tracker["max_ratio"] = self.config.util.check_for_attribute(
self.config.data,
"max_ratio",
parent="tracker",
subparent=tag_url,
var_type="float",
min_int=-2,
do_print=False,
default_is_none=True,
save=False,
)
tracker["max_seeding_time"] = self.config.util.check_for_attribute(
self.config.data,
"max_seeding_time",
parent="tracker",
subparent=tag_url,
var_type="int",
min_int=-2,
do_print=False,
default_is_none=True,
save=False,
)
tracker["min_seeding_time"] = self.config.util.check_for_attribute(
self.config.data, self.config.data,
"min_seeding_time", "max_ratio",
parent="tracker", parent="tracker",
subparent=tag_url, subparent=tag_url,
var_type="int", var_type="float",
min_int=0, min_int=-2,
do_print=False, do_print=False,
default=0,
save=False,
)
tracker["limit_upload_speed"] = self.config.util.check_for_attribute(
self.config.data,
"limit_upload_speed",
parent="tracker",
subparent=tag_url,
var_type="int",
min_int=-1,
do_print=False,
default=0,
save=False,
)
tracker["notifiarr"] = self.config.util.check_for_attribute(
self.config.data,
"notifiarr",
parent="tracker",
subparent=tag_url,
default_is_none=True, default_is_none=True,
do_print=False,
save=False, save=False,
) )
tracker["max_seeding_time"] = self.config.util.check_for_attribute(
self.config.data,
"max_seeding_time",
parent="tracker",
subparent=tag_url,
var_type="int",
min_int=-2,
do_print=False,
default_is_none=True,
save=False,
)
tracker["min_seeding_time"] = self.config.util.check_for_attribute(
self.config.data,
"min_seeding_time",
parent="tracker",
subparent=tag_url,
var_type="int",
min_int=0,
do_print=False,
default=0,
save=False,
)
tracker["limit_upload_speed"] = self.config.util.check_for_attribute(
self.config.data,
"limit_upload_speed",
parent="tracker",
subparent=tag_url,
var_type="int",
min_int=-1,
do_print=False,
default=0,
save=False,
)
tracker["notifiarr"] = self.config.util.check_for_attribute(
self.config.data,
"notifiarr",
parent="tracker",
subparent=tag_url,
default_is_none=True,
do_print=False,
save=False,
)
return tracker return tracker
if tracker_other_tag: if tracker_other_tag:
tracker["tag"] = tracker_other_tag tracker["tag"] = tracker_other_tag

View file

@ -182,7 +182,14 @@ class check:
if os.path.exists(os.path.abspath(data[attribute])): if os.path.exists(os.path.abspath(data[attribute])):
return os.path.join(data[attribute], "") return os.path.join(data[attribute], "")
else: else:
message = f"Path {os.path.abspath(data[attribute])} does not exist" if make_dirs:
try:
os.makedirs(data[attribute], exist_ok=True)
return os.path.join(data[attribute], "")
except OSError:
message = f"Path {os.path.abspath(data[attribute])} does not exist and can't be created"
else:
message = f"Path {os.path.abspath(data[attribute])} does not exist"
elif var_type == "list": elif var_type == "list":
return get_list(data[attribute], split=False) return get_list(data[attribute], split=False)
elif var_type == "list_path": elif var_type == "list_path":
@ -197,11 +204,13 @@ class check:
return data[attribute] return data[attribute]
else: else:
message = f"{text}: {data[attribute]} is an invalid input" message = f"{text}: {data[attribute]} is an invalid input"
if var_type == "path" and default and os.path.exists(os.path.abspath(default)): if var_type == "path" and default:
return os.path.join(default, "") default_path = os.path.abspath(default)
elif var_type == "path" and default and make_dirs: if make_dirs and not os.path.exists(default_path):
os.makedirs(default, exist_ok=True) os.makedirs(default, exist_ok=True)
return os.path.join(default, "") if os.path.exists(default_path):
default = os.path.join(default, "")
message = message + f", using {default} as default"
elif var_type == "path" and default: elif var_type == "path" and default:
if data and attribute in data and data[attribute]: if data and attribute in data and data[attribute]:
message = f"neither {data[attribute]} or the default path {default} could be found" message = f"neither {data[attribute]} or the default path {default} could be found"