Skip to content

Commit 8363a7b

Browse files
committed
add up/down limit
1 parent bf8c776 commit 8363a7b

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

library/playback/torrents_info.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ def parse_args():
3636
parser.add_argument("--move", type=Path, help="Directory to move folders/files")
3737
parser.add_argument("--start", action=argparse.BooleanOptionalAction, help="Start matching torrents")
3838
parser.add_argument("--force-start", action=argparse.BooleanOptionalAction, help="Force start matching torrents")
39+
parser.add_argument("--download-limit", "--dl-limit", type=nums.human_to_bytes, help="Torrent download limit")
40+
parser.add_argument(
41+
"--upload-limit", "--up-limit", "--ul-limit", type=nums.human_to_bytes, help="Torrent upload limit"
42+
)
3943
parser.add_argument("--check", "--recheck", action="store_true", help="Check matching torrents")
4044
parser.add_argument("--export", action="store_true", help="Export matching torrent files")
4145

@@ -174,9 +178,6 @@ def filter_torrents_by_criteria(args, torrents):
174178
if args.no_tracker:
175179
trackers = set(args.no_tracker)
176180
torrents = [t for t in torrents if t.tracker_domain() not in trackers]
177-
if args.tracker:
178-
trackers = set(args.tracker)
179-
torrents = [t for t in torrents if t.tracker_domain() in trackers]
180181
if args.torrent_search:
181182
torrents = [
182183
t
@@ -188,6 +189,10 @@ def filter_torrents_by_criteria(args, torrents):
188189
if args.file_search:
189190
torrents = [t for t in torrents if strings.glob_match(args.file_search, [f.name for f in t.files])]
190191

192+
if args.tracker:
193+
trackers = set(args.tracker)
194+
torrents = [t for t in torrents if t.tracker_domain() in trackers]
195+
191196
if args.timeout_size:
192197
torrents = [t for t in torrents if not processes.sizeout(args.timeout_size, t.total_size)]
193198

@@ -568,6 +573,14 @@ def set_download_path(t, download_path):
568573
print("Force-starting", len(torrents))
569574
qbt_client.torrents_set_force_start(args.force_start, torrent_hashes=torrent_hashes)
570575

576+
if args.download_limit is not None:
577+
print("Setting DL limit", len(torrents))
578+
qbt_client.torrents_set_download_limit(args.download_limit or -1, torrent_hashes=torrent_hashes)
579+
580+
if args.upload_limit is not None:
581+
print("Setting UP limit", len(torrents))
582+
qbt_client.torrents_set_upload_limit(args.upload_limit or -1, torrent_hashes=torrent_hashes)
583+
571584
if args.check:
572585
print("Checking", len(torrents))
573586
qbt_client.torrents_recheck(torrent_hashes=torrent_hashes)

library/utils/file_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ def read_file_to_dataframes(
550550

551551
dfs: list[NDF] = []
552552

553-
if mimetype in ("sqlite", "sqlite3", "sqlite database file"):
553+
if mimetype in ("sqlite", "sqlite3", "sqlite database file", "application/vnd.sqlite3"):
554554
import pandas as pd
555555
from sqlite_utils import Database
556556

0 commit comments

Comments
 (0)