Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions torrentfile/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,10 @@ def execute(args: List[str] = None) -> List[str]:
metavar="<url>",
nargs="+",
default=[],
help="one or more space-seperated tracker url(s)",
help="""
One or more space-seperated tracker url(s), each will be in its own
tier, if a url is prefixed by '+', it will be added to previous tier.
""",
)

create_parser.add_argument(
Expand Down Expand Up @@ -443,7 +446,10 @@ def execute(args: List[str] = None) -> List[str]:
dest="announce",
metavar="<url>",
nargs="+",
help="replace current trackers with one or more urls",
help="""
Replace current trackers with one or more urls, each will be in its own
tier, if a url is prefixed by '+', it will be added to previous tier.
""",
)

edit_parser.add_argument(
Expand Down
15 changes: 10 additions & 5 deletions torrentfile/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,17 @@ def edit_torrent(metafile: str, args: dict) -> dict:
if "announce" in args:
val = args.get("announce", None)
if isinstance(val, str):
vallist = val.split()
meta["announce"] = vallist[0]
meta["announce-list"] = [vallist]
elif isinstance(val, list):
val = val.split()
if isinstance(val, list):
if val[0].startswith("+"):
val[0] = val[0][1:]
meta["announce"] = val[0]
meta["announce-list"] = [val]
meta["announce-list"] = []
for i in val:
if i.startswith("+"):
meta["announce-list"][-1].append(i[1:])
else:
meta["announce-list"].append([i])

if "url-list" in args:
val = args.get("url-list")
Expand Down
9 changes: 8 additions & 1 deletion torrentfile/torrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,14 @@ def __init__(
self.announce, self.announce_list = announce, [[announce]]

elif isinstance(announce, Sequence):
self.announce, self.announce_list = announce[0], [announce]
if announce[0].startswith("+"):
announce[0] = announce[0][1:]
self.announce, self.announce_list = announce[0], []
for i in announce:
if i.startswith("+"):
self.announce_list[-1].append(i[1:])
else:
self.announce_list.append([i])

self.align = align

Expand Down