Skip to content

Commit 6e04b77

Browse files
committed
add torrents-info, torrents-stop, and torrents-stop-incomplete
1 parent a362a06 commit 6e04b77

18 files changed

+511
-58
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#

tests/mediafiles/test_torrents_list.py

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#

xklb/__main__.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@
7575
"images_to_pdf": "Convert folders of images into image PDFs",
7676
"pdf_edit": "Apply brightness, contrast, saturation, and sharpness adjustments to PDFs",
7777
"torrents_start": "Start torrents (qBittorrent-nox)",
78-
"torrents_stop": "Stop torrents (qBittorrent-nox)",
78+
"torrents_stop": "Stop seeding torrents (qBittorrent-nox)",
79+
"torrents_stop_incomplete": "Stop downloading torrents (qBittorrent-nox)",
7980
},
8081
"Multi-database subcommands": {
8182
"merge_dbs": "Merge SQLite databases",
@@ -108,6 +109,7 @@
108109
"tabs_open": "Open your tabs for the day",
109110
"links_open": "Open links from link dbs",
110111
"surf": "Auto-load browser tabs in a streaming way (stdin)",
112+
"torrents_info": "List torrents (qBittorrent-nox)",
111113
},
112114
"Database enrichment subcommands": {
113115
"dedupe_db": "Dedupe SQLite tables",
@@ -227,6 +229,7 @@ def print_help(parser) -> None:
227229
"xklb.mediafiles.pdf_edit.pdf_edit": [],
228230
"xklb.mediafiles.torrents_start.torrents_start": ["torrent-start"],
229231
"xklb.mediafiles.torrents_stop.torrents_stop": ["torrent-stop"],
232+
"xklb.mediafiles.torrents_stop_incomplete.torrents_stop_incomplete": ["torrent-stop-incomplete"],
230233
"xklb.misc.dedupe_czkawka.czkawka_dedupe": ["dedupe-czkawka"],
231234
"xklb.misc.export_text.export_text": [],
232235
"xklb.multidb.copy_play_counts.copy_play_counts": [],
@@ -242,10 +245,11 @@ def print_help(parser) -> None:
242245
"xklb.playback.playback_control.playback_next": ["next"],
243246
"xklb.playback.playback_control.playback_now": ["now"],
244247
"xklb.playback.playback_control.playback_pause": ["pause", "play"],
245-
"xklb.playback.playback_control.playback_stop": ["stop"],
246248
"xklb.playback.playback_control.playback_seek": ["ffwd", "rewind", "seek"], # TODO: make rewind negative...
249+
"xklb.playback.playback_control.playback_stop": ["stop"],
247250
"xklb.playback.surf.streaming_tab_loader": ["surf"],
248251
"xklb.playback.tabs_open.tabs_open": ["tb", "tabs", "open_tabs"],
252+
"xklb.playback.torrents_info.torrents_info": ["torrent-info", "torrents", "torrent"],
249253
"xklb.tablefiles.eda.eda": ["preview"],
250254
"xklb.tablefiles.incremental_diff.incremental_diff": [],
251255
"xklb.tablefiles.columns.columns": [],
@@ -277,7 +281,20 @@ def create_subcommands_parser() -> argparse.ArgumentParser:
277281
subparsers = parser.add_subparsers()
278282

279283
# this needs to stay inside the function to prevent side-effects during testing
280-
known_subcommands = ["fs", "media", "open", "table", "tables", "tabs", "du", "search", "links", "images"]
284+
known_subcommands = [
285+
"fs",
286+
"media",
287+
"open",
288+
"table",
289+
"tables",
290+
"tabs",
291+
"du",
292+
"search",
293+
"links",
294+
"images",
295+
"torrents",
296+
"torrent",
297+
]
281298

282299
def consecutive_prefixes(s):
283300
prefixes = [s[:j] for j in range(5, len(s)) if s[:j] and s[:j] not in known_subcommands]
@@ -325,7 +342,12 @@ def add_parser(subparsers, func, aliases=None):
325342

326343
def library(args=None) -> None:
327344
if args:
328-
sys.argv = ["lb", *args]
345+
original_argv = sys.argv
346+
try:
347+
sys.argv = ["lb", *args]
348+
return library()
349+
finally:
350+
sys.argv = original_argv
329351

330352
parser.exit_on_error = False # type: ignore
331353
try:

xklb/createdb/torrents_add.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import concurrent.futures, os, statistics
22
from pathlib import Path
3-
from urllib.parse import urlparse
43

54
from torrentool.api import Torrent
65

76
from xklb import usage
87
from xklb.mediadb import db_playlists
98
from xklb.utils import arg_utils, arggroups, argparse_utils, consts, db_utils, iterables, nums, objects, printing
109
from xklb.utils.log_utils import log
10+
from xklb.utils.path_utils import domain_from_url
1111

1212

1313
def parse_args():
@@ -29,8 +29,7 @@ def get_tracker(torrent: Torrent):
2929
log.debug(torrent.announce_urls)
3030

3131
for tracker in iterables.flatten(torrent.announce_urls):
32-
url = urlparse(tracker)
33-
domain = ".".join(url.netloc.rsplit(":")[0].rsplit(".", 2)[-2:]).lower()
32+
domain = domain_from_url(tracker)
3433
return domain
3534

3635
return torrent.source

0 commit comments

Comments
 (0)