Skip to content

Commit eedee6c

Browse files
committed
fzf: toggle all option
1 parent 1d202f0 commit eedee6c

File tree

7 files changed

+71
-57
lines changed

7 files changed

+71
-57
lines changed

library/mediafiles/torrents_start.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,6 @@ def torrents_start():
158158

159159
if args.delete_torrent:
160160
trash(args, path)
161+
162+
if shutil.which("qbt_prioritize.py"):
163+
processes.cmd("qbt_prioritize.py")

library/playback/torrents_info.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,13 @@ def is_matching(args, t):
115115

116116

117117
def filter_torrents_by_activity(args, torrents):
118-
if args.stopped:
119-
torrents = [t for t in torrents if t.state_enum.is_stopped]
120-
if args.errored:
121-
torrents = [t for t in torrents if t.state == "error"]
122-
if args.missing:
123-
torrents = [t for t in torrents if t.state == "missingFiles"]
118+
if args.stopped is not None:
119+
torrents = [t for t in torrents if args.stopped == t.state_enum.is_stopped]
120+
if args.errored is not None:
121+
torrents = [t for t in torrents if args.errored == (t.state == "error")]
122+
if args.missing is not None:
123+
torrents = [t for t in torrents if args.missing == (t.state == "missingFiles")]
124+
124125
if args.complete:
125126
torrents = [t for t in torrents if t.state_enum.is_complete]
126127
if args.incomplete:
@@ -160,6 +161,16 @@ def shorten(s, width):
160161
qbt_client = torrents_start.start_qBittorrent(args)
161162
torrents = qbt_client.torrents_info()
162163

164+
tbl = []
165+
for t in torrents:
166+
msg = "; ".join(tr.msg for tr in torrents[0].trackers if tr.msg != "This torrent is private")
167+
if msg:
168+
tracker = qbt_get_tracker(qbt_client, t)
169+
tbl.append({"path": t.content_path, "tracker": tracker, "msg": msg})
170+
if tbl:
171+
print(f"Error Torrents ({len(tbl)})")
172+
printing.table(sorted(tbl, key=lambda d: (d["msg"], d["tracker"])))
173+
163174
error_torrents = [t for t in torrents if t.state_enum.is_errored]
164175
if error_torrents:
165176
args.status = True

library/playback/torrents_status.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ def shorten(s, width):
119119

120120
trackers = []
121121
for tracker, tracker_torrents in torrents_by_tracker.items():
122-
if not args.stopped:
123-
tracker_torrents = [t for t in tracker_torrents if t.state not in ("stoppedDL",)]
124122
remaining = sum(t.amount_left for t in tracker_torrents)
125123
trackers.append(
126124
{

library/utils/arggroups.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,9 +1997,11 @@ def qBittorrent_torrents(parent_parser):
19971997
"--active", action="store_true", help="Include active torrents (default when not --all or --inactive)"
19981998
)
19991999
parser.add_argument("--inactive", "--dead", action="store_true", help="Include inactive torrents")
2000-
parser.add_argument("--stopped", "--paused", action="store_true", help="Include stopped torrents")
2001-
parser.add_argument("--missing", action="store_true", help="Include missing torrents")
2002-
parser.add_argument("--errored", action="store_true", help="Include errored torrents")
2000+
2001+
parser.add_argument("--stopped", "--paused", action=argparse.BooleanOptionalAction, help="Include stopped torrents")
2002+
parser.add_argument("--missing", action=argparse.BooleanOptionalAction, help="Include missing torrents")
2003+
parser.add_argument("--errored", action=argparse.BooleanOptionalAction, help="Include errored torrents")
2004+
20032005
parser.add_argument("--complete", "--completed", action="store_true", help="Include completed torrents")
20042006
parser.add_argument("--incomplete", action="store_true", help="Include incomplete torrents")
20052007

library/utils/processes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ def unar_delete(archive_path):
484484
def fzf_select(items, multi=True):
485485
input_text = "\n".join(reversed(items))
486486

487-
fzf_command = ["fzf"]
487+
fzf_command = ["fzf", "--bind", "ctrl-a:toggle-all"]
488488
if multi:
489489
fzf_command += ["--multi"]
490490

library/utils/strings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def duration_short(seconds, format_str="%0.1f") -> str:
377377

378378
try:
379379
if seconds < 60:
380-
return f"{format_str % seconds} seconds"
380+
return f"{int(seconds)} seconds"
381381

382382
minutes = seconds / 60
383383
if minutes < 1.1:

pdm.lock

Lines changed: 44 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)