Skip to content

Commit

Permalink
4.1.4 (#553)
Browse files Browse the repository at this point in the history
* 4.1.4-develop1

* Fixes #545

* Fixes #546

* oops forgot to check if group_tag is enabled

* (fix) blu unregistered torrent message (#547)

InfoHash not found.

* fix broken tags check

* Fixes MinSeedTimeNotReached not being applied correctly #548

* Bump pre-commit from 3.7.0 to 3.7.1 (#549)

Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 3.7.0 to 3.7.1.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md)
- [Commits](pre-commit/pre-commit@v3.7.0...v3.7.1)

---
updated-dependencies:
- dependency-name: pre-commit
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Fixes exclude directory of recently deleted torrents from rem_orphaned #550

* minor debug comment update

* Fixes exclude directory of recently deleted torrents from rem_orphaned #550 for those that don't use recycle bin

* Fixes cross-seed bug introduced in v6 with cross-seed-data

* optimize remove_empty_dirs and remove empty folders in orphaned_data

* Additional blutopia unregistered_torrent status, do not delete orphaned_data root folder if it's empty

* Adds additional logging for cleaning up empty folders

* 4.1.4

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: bakerboy448 <55419169+bakerboy448@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored May 18, 2024
1 parent f4dcc39 commit 3696f91
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 115 deletions.
26 changes: 7 additions & 19 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
# Requirements Added
- croniter==2.0.5
- humanize==4.9.0
- pytimeparse2==1.7.1

# New Updates
- Adds support for [cron scheduling](https://crontab.guru/examples.html) via QBT_SCHEDULE / `--schedule`
- Supports [time parsing](https://github.com/onegreyonewhite/pytimeparse2?tab=readme-ov-file#pytimeparse2-time-expression-parser) in `max_seeding_time`, `min_seeding_time`, and `last_active` config variables.
Example:
- `32m`
- `2h32m`
- `3d2h32m`
- `1w3d2h32m`
- Removes the config option `ignoreTags_OnUpdate`, and `force_retag_all` option (These config options are no longer used, the tag-update function will now automatically update all torents if the tracker tag is missing)
- Better trace logs for share limits (Closes #533)
- Adds new config option `ignore_root_dir` [#538 - NoHardlinking detection outside of root directory](https://github.com/StuffAnThings/qbit_manage/issues/538)

- Adds additional remove unregistered logic for Blutopia

# Bug Fixes
- Fixes [#540](https://github.com/StuffAnThings/qbit_manage/issues/540)

- Fixes [#545](https://github.com/StuffAnThings/qbit_manage/issues/545)
- Fixes [#546](https://github.com/StuffAnThings/qbit_manage/issues/546)
- Fixes [#548](https://github.com/StuffAnThings/qbit_manage/issues/548)
- Fixes [#550](https://github.com/StuffAnThings/qbit_manage/issues/550)
- Optimizes Remove Empty Directories and remove empty folders in orphaned_data

**Full Changelog**: https://github.com/StuffAnThings/qbit_manage/compare/v4.1.2...v4.1.3
**Full Changelog**: https://github.com/StuffAnThings/qbit_manage/compare/v4.1.3...v4.1.4
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1.3
4.1.4
4 changes: 3 additions & 1 deletion modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,9 @@ def cleanup_dirs(self, location):
if not self.dry_run:
for path in location_path_list:
if path != location_path:
util.remove_empty_directories(path, "**/*", self.qbt.get_category_save_paths())
util.remove_empty_directories(path, self.qbt.get_category_save_paths())
# Delete empty folders inside the location_path
util.remove_empty_directories(location_path, [location_path])
body += logger.print_line(
f"{'Did not delete' if self.dry_run else 'Deleted'} {num_del} files "
f"({util.human_readable_size(size_bytes)}) from the {location}.",
Expand Down
2 changes: 1 addition & 1 deletion modules/core/cross_seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def cross_seed(self):
logger.warning(f"Unable to find hash {torrent_hash} in qbt: {e}")
if torrent_info:
torrent = torrent_info[0]
self.qbt.add_torrent_files(torrent.hash, torrent.files)
self.qbt.add_torrent_files(torrent.hash, torrent.files, torrent.save_path)
self.qbt.torrentvalid.append(torrent)
self.qbt.torrentinfo[t_name]["torrents"].append(torrent)
self.qbt.torrent_list.append(torrent)
Expand Down
4 changes: 2 additions & 2 deletions modules/core/recheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ def recheck(self):
logger.debug("DEBUG: Torrent to see if torrent meets AutoTorrentManagement Criteria")
logger.debug(logger.insert_space(f"- Torrent Name: {t_name}", 2))
logger.debug(
logger.insert_space(f"-- Ratio vs Max Ratio: {torrent.ratio:.2f} < {torrent.max_ratio:.2f}", 4)
logger.insert_space(f"-- Ratio vs Max Ratio: {torrent.ratio:.2f} vs {torrent.max_ratio:.2f}", 4)
)
logger.debug(
logger.insert_space(
f"-- Seeding Time vs Max Seed Time: {str(timedelta(seconds=torrent.seeding_time))} < "
f"-- Seeding Time vs Max Seed Time: {str(timedelta(seconds=torrent.seeding_time))} vs "
f"{str(timedelta(minutes=torrent.max_seeding_time))}",
4,
)
Expand Down
2 changes: 1 addition & 1 deletion modules/core/remove_orphaned.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def rem_orphaned(self):
orphaned_parent_path = set(self.executor.map(self.move_orphan, orphaned_files))
logger.print_line("Removing newly empty directories", self.config.loglevel)
self.executor.map(
lambda dir: util.remove_empty_directories(dir, "**/*", self.qbt.get_category_save_paths()),
lambda directory: util.remove_empty_directories(directory, self.qbt.get_category_save_paths()),
orphaned_parent_path,
)

Expand Down
57 changes: 27 additions & 30 deletions modules/core/share_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ def update_share_limits_for_group(self, group_name, group_config, torrents):
share_limits_not_yet_tagged = (
True if self.group_tag and not is_tag_in_torrent(self.group_tag, torrent.tags) else False
)
check_multiple_share_limits_tag = (
self.group_tag and len(is_tag_in_torrent(self.share_limits_tag, torrent.tags, exact=False)) > 1
)
logger.trace(f"Torrent: {t_name} [Hash: {t_hash}]")
logger.trace(f"Torrent Category: {torrent.category}")
logger.trace(f"Torrent Tags: {torrent.tags}")
Expand Down Expand Up @@ -227,6 +230,9 @@ def update_share_limits_for_group(self, group_name, group_config, torrents):
logger.trace(f"check_limit_upload_speed: {check_limit_upload_speed}")
logger.trace(f"hash_not_prev_checked: {hash_not_prev_checked}")
logger.trace(f"share_limits_not_yet_tagged: {share_limits_not_yet_tagged}")
logger.trace(
f"check_multiple_share_limits_tag: {is_tag_in_torrent(self.share_limits_tag, torrent.tags, exact=False)}"
)

tor_reached_seed_limit = self.has_reached_seed_limit(
torrent=torrent,
Expand All @@ -241,13 +247,21 @@ def update_share_limits_for_group(self, group_name, group_config, torrents):
# Get updated torrent after checking if the torrent has reached seed limits
torrent = self.qbt.get_torrents({"torrent_hashes": t_hash})[0]
if (
check_max_ratio or check_max_seeding_time or check_limit_upload_speed or share_limits_not_yet_tagged
check_max_ratio
or check_max_seeding_time
or check_limit_upload_speed
or share_limits_not_yet_tagged
or check_multiple_share_limits_tag
) and hash_not_prev_checked:
if (
not is_tag_in_torrent(self.min_seeding_time_tag, torrent.tags)
and not is_tag_in_torrent(self.min_num_seeds_tag, torrent.tags)
and not is_tag_in_torrent(self.last_active_tag, torrent.tags)
) or share_limits_not_yet_tagged:
(
not is_tag_in_torrent(self.min_seeding_time_tag, torrent.tags)
and not is_tag_in_torrent(self.min_num_seeds_tag, torrent.tags)
and not is_tag_in_torrent(self.last_active_tag, torrent.tags)
)
or share_limits_not_yet_tagged
or check_multiple_share_limits_tag
):
logger.print_line(logger.insert_space(f"Torrent Name: {t_name}", 3), self.config.loglevel)
logger.print_line(logger.insert_space(f'Tracker: {tracker["url"]}', 8), self.config.loglevel)
if self.group_tag:
Expand Down Expand Up @@ -344,44 +358,26 @@ def set_tags_and_limits(self, torrent, max_ratio, max_seeding_time, limit_upload
if limit_upload_speed is not None:
if limit_upload_speed != -1:
msg = logger.insert_space(f"Limit UL Speed: {limit_upload_speed} kB/s", 1)
if do_print:
body += logger.print_line(msg, self.config.loglevel)
else:
body.append(msg)
body.append(msg)
if max_ratio is not None or max_seeding_time is not None:
if max_ratio == -2 and max_seeding_time == -2:
msg = logger.insert_space("Share Limit: Use Global Share Limit", 4)
if do_print:
body += logger.print_line(msg, self.config.loglevel)
else:
body.append(msg)
body.append(msg)
elif max_ratio == -1 and max_seeding_time == -1:
msg = logger.insert_space("Share Limit: Set No Share Limit", 4)
if do_print:
body += logger.print_line(msg, self.config.loglevel)
else:
body.append(msg)
body.append(msg)
else:
if max_ratio != torrent.max_ratio and (max_seeding_time is None or max_seeding_time < 0):
msg = logger.insert_space(f"Share Limit: Max Ratio = {max_ratio}", 4)
if do_print:
body += logger.print_line(msg, self.config.loglevel)
else:
body.append(msg)
body.append(msg)
elif max_seeding_time != torrent.max_seeding_time and (max_ratio is None or max_ratio < 0):
msg = logger.insert_space(f"Share Limit: Max Seed Time = {str(timedelta(minutes=max_seeding_time))}", 4)
if do_print:
body += logger.print_line(msg, self.config.loglevel)
else:
body.append(msg)
body.append(msg)
elif max_ratio != torrent.max_ratio or max_seeding_time != torrent.max_seeding_time:
msg = logger.insert_space(
f"Share Limit: Max Ratio = {max_ratio}, Max Seed Time = {str(timedelta(minutes=max_seeding_time))}", 4
)
if do_print:
body += logger.print_line(msg, self.config.loglevel)
else:
body.append(msg)
body.append(msg)
# Update Torrents
if not self.config.dry_run:
if tags:
Expand All @@ -403,6 +399,7 @@ def set_tags_and_limits(self, torrent, max_ratio, max_seeding_time, limit_upload
if is_tag_in_torrent(self.last_active_tag, torrent.tags):
return []
torrent.set_share_limits(ratio_limit=max_ratio, seeding_time_limit=max_seeding_time, inactive_seeding_time_limit=-2)
[logger.print_line(msg, self.config.loglevel) for msg in body if do_print]
return body

def has_reached_seed_limit(
Expand Down Expand Up @@ -527,7 +524,7 @@ def _has_reached_seeding_time_limit():
_remove_min_seeding_time_tag()
return False
if seeding_time_limit:
if _has_reached_min_seeding_time_limit() and (torrent.seeding_time >= seeding_time_limit * 60):
if (torrent.seeding_time >= seeding_time_limit * 60) and _has_reached_min_seeding_time_limit():
body += logger.insert_space(
f"Seeding Time vs Max Seed Time: {str(timedelta(seconds=torrent.seeding_time))} >= "
f"{str(timedelta(minutes=seeding_time_limit))}",
Expand Down
Loading

0 comments on commit 3696f91

Please sign in to comment.