Skip to content

Commit

Permalink
Update mover.py: add optional arg --status-filter to allow fine tune …
Browse files Browse the repository at this point in the history
…which torrents to pauseUpdate mover.py: add optional arg --status-filter to allow fine tune which torrents to pause (#599)

* Update mover.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update mover.py: making the default behavior to only move `completed` torrents

This will leave 1) unfinished files 2) actively seeding files in `downloading` torrents in cache. This helps to keep write-heavy operation on Cache, not on hard drive.

Change this to "all" if you want this to always move everything every time.

* minor fixes in help description

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: bobokun <[email protected]>
  • Loading branch information
3 people authored Jul 1, 2024
1 parent b88a7b8 commit bde9d8a
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion scripts/mover.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,29 @@
action="store_true",
default=False,
)
parser.add_argument(
"--status-filter",
help="Define a status to limit which torrents to pause. Useful if you want to leave certain torrents unpaused.",
choices=[
"all",
"downloading",
"seeding",
"completed",
"paused",
"stopped",
"active",
"inactive",
"resumed",
"running",
"stalled",
"stalled_uploading",
"stalled_downloading",
"checking",
"moving",
"errored",
],
default="completed",
)
# --DEFINE VARIABLES--#

# --START SCRIPT--#
Expand Down Expand Up @@ -96,7 +119,7 @@ def stop_start_torrents(torrent_list, pause=True):

timeoffset_from = current - timedelta(days=args.days_from)
timeoffset_to = current - timedelta(days=args.days_to)
torrent_list = client.torrents.info(sort="added_on", reverse=True)
torrent_list = client.torrents.info(status_filter=args.status_filter, sort="added_on", reverse=True)

torrents = filter_torrents(torrent_list, timeoffset_from.timestamp(), timeoffset_to.timestamp(), args.cache_mount)

Expand Down

0 comments on commit bde9d8a

Please sign in to comment.