sciop-cli 0.1.2__tar.gz → 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/PKG-INFO +1 -1
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/pyproject.toml +1 -1
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/src/sciop_cli/cli/torrent.py +9 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/src/sciop_cli/torrent.py +11 -1
- sciop_cli-0.1.3/tests/data/basic_v2.torrent +3 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/tests/test_cli/test_torrent.py +7 -3
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/LICENSE +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/README.md +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/src/sciop_cli/__init__.py +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/src/sciop_cli/__main__.py +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/src/sciop_cli/cli/__init__.py +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/src/sciop_cli/cli/main.py +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/src/sciop_cli/cli/manifest.py +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/src/sciop_cli/const.py +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/src/sciop_cli/data.py +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/src/sciop_cli/exceptions.py +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/src/sciop_cli/file.py +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/src/sciop_cli/models/__init__.py +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/src/sciop_cli/schema.py +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/src/sciop_cli/types.py +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/tests/.DS_Store +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/tests/__init__.py +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/tests/conftest.py +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/tests/data/basic/part_1/subdir/part_1 +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/tests/data/basic/part_2/subdir/part_2 +0 -0
- /sciop_cli-0.1.2/tests/data/basic.torrent → /sciop_cli-0.1.3/tests/data/basic_hybrid.torrent +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/tests/test_cli/__init__.py +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/tests/test_data.py +0 -0
- {sciop_cli-0.1.2 → sciop_cli-0.1.3}/tests/test_temp.py +0 -0
|
@@ -94,6 +94,13 @@ def pack() -> None:
|
|
|
94
94
|
"Similar torrents are torrents who have files in common with this torrent, "
|
|
95
95
|
"clients are able to reuse files from the other torrents if they already have them downloaded.",
|
|
96
96
|
)
|
|
97
|
+
@click.option(
|
|
98
|
+
"-2",
|
|
99
|
+
"--v2",
|
|
100
|
+
is_flag=True,
|
|
101
|
+
default=False,
|
|
102
|
+
help="Make a v2-only torrent (otherwise, hybrid v1/v2)",
|
|
103
|
+
)
|
|
97
104
|
@click.option("--progress/--no-progress", default=True, help="Enable progress bar (default True)")
|
|
98
105
|
@click.option(
|
|
99
106
|
"-o",
|
|
@@ -112,6 +119,7 @@ def create(
|
|
|
112
119
|
creator: str = DEFAULT_TORRENT_CREATOR,
|
|
113
120
|
webseed: list[str] | None = None,
|
|
114
121
|
similar: list[str] | None = None,
|
|
122
|
+
v2: bool = False,
|
|
115
123
|
progress: bool = True,
|
|
116
124
|
output: Path | None = None,
|
|
117
125
|
) -> None:
|
|
@@ -146,6 +154,7 @@ def create(
|
|
|
146
154
|
creator=creator,
|
|
147
155
|
webseeds=webseed,
|
|
148
156
|
similar=similar,
|
|
157
|
+
version="v2" if v2 else "hybrid",
|
|
149
158
|
pbar=progress,
|
|
150
159
|
bencode=True,
|
|
151
160
|
)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import warnings
|
|
2
2
|
from math import floor
|
|
3
3
|
from pathlib import Path
|
|
4
|
+
from typing import Literal as L
|
|
4
5
|
|
|
5
6
|
import bencode_rs
|
|
6
7
|
import libtorrent
|
|
@@ -40,6 +41,7 @@ def create_torrent(
|
|
|
40
41
|
creator: str = DEFAULT_TORRENT_CREATOR,
|
|
41
42
|
webseeds: list[str] | None = None,
|
|
42
43
|
similar: list[str] | None = None,
|
|
44
|
+
version: L["v1", "v2", "hybrid"] = "hybrid",
|
|
43
45
|
bencode: bool = True,
|
|
44
46
|
piece_size: PieceSize = 512 * (2**10),
|
|
45
47
|
pbar: bool = False,
|
|
@@ -60,6 +62,8 @@ def create_torrent(
|
|
|
60
62
|
must match the directory structure of the torrent and their content exactly.
|
|
61
63
|
similar: Infohashes of torrents that have identical files to those in this torrent.
|
|
62
64
|
Clients can use this to deduplicate downloads.
|
|
65
|
+
version: Torrent version to create. Default ``"hybrid"`` creates v1/v2 compatible torrents.
|
|
66
|
+
v1 is *not recommended.*
|
|
63
67
|
bencode: If ``True`` ( default ) return the bencoded bytestring.
|
|
64
68
|
Otherwise return a python dictionary
|
|
65
69
|
piece_size: The size of data chunks to hash.
|
|
@@ -100,7 +104,13 @@ def create_torrent(
|
|
|
100
104
|
|
|
101
105
|
piece_size = TypeAdapter(PieceSize).validate_python(piece_size)
|
|
102
106
|
|
|
103
|
-
|
|
107
|
+
flags = 0
|
|
108
|
+
if version == "v1":
|
|
109
|
+
flags = libtorrent.create_torrent.v1_only
|
|
110
|
+
elif version == "v2":
|
|
111
|
+
flags = libtorrent.create_torrent.v2_only
|
|
112
|
+
|
|
113
|
+
torrent = libtorrent.create_torrent(fs, piece_size=piece_size, flags=flags)
|
|
104
114
|
|
|
105
115
|
if trackers:
|
|
106
116
|
for tier, tracker in enumerate(trackers):
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
d8:announce22:udp://example.com:696913:announce-listll22:udp://example.com:696931:http://example.com/announce.phpee7:comment4:test10:created by11:sciop-tests4:infod9:file treed6:part_1d6:subdird6:part_1d0:d6:lengthi65536e11:pieces root32:El���/���U����d�Pk*U�7ܼ�9eeee6:part_2d6:subdird6:part_2d0:d6:lengthi65536e11:pieces root32:
|
|
2
|
+
��:H� �w�2$L����Ѵ�ioUјT��eeeee12:meta versioni2e4:name5:basic12:piece lengthi16384ee12:piece layersd32:El���/���U����d�Pk*U�7ܼ�9128:�i�q�ˆ��U:e���g�e����T΄�:7�K(�Mၤ�y�LfTj� G�M�&�"0�O%�{�Rdĺ�V��j�A���Y2U
|
|
3
|
+
��:H� �w�2$L����Ѵ�ioUјT��128:���fY_E~"ic6U;��?�'��&L+L��l��Cˮ`���{1���w�1����ߕ��_�D����l���L�Ս���
|
|
@@ -9,7 +9,8 @@ from sciop_cli.exceptions import NoTrackersWarning
|
|
|
9
9
|
from ..conftest import DATA_DIR
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
@pytest.mark.parametrize("version", ["hybrid", "v2"])
|
|
13
|
+
def test_create_torrent(tmp_path, version):
|
|
13
14
|
trackers = ["udp://example.com:6969", "http://example.com/announce.php"]
|
|
14
15
|
webseeds = ["https://example.com/files"]
|
|
15
16
|
output = tmp_path / "basic.torrent"
|
|
@@ -29,16 +30,19 @@ def test_create_torrent(tmp_path):
|
|
|
29
30
|
args.extend(["--tracker", tracker])
|
|
30
31
|
for webseed in webseeds:
|
|
31
32
|
args.extend(["--webseed", webseed])
|
|
33
|
+
if version == "v2":
|
|
34
|
+
args.append("--v2")
|
|
32
35
|
|
|
33
36
|
runner = CliRunner()
|
|
34
37
|
result = runner.invoke(torrent.create, args)
|
|
35
38
|
assert result.exit_code == 0
|
|
36
|
-
expected = bencode_rs.bdecode((DATA_DIR / "
|
|
39
|
+
expected = bencode_rs.bdecode((DATA_DIR / f"basic_{version}.torrent").read_bytes())
|
|
37
40
|
created = bencode_rs.bdecode(output.read_bytes())
|
|
38
41
|
|
|
39
42
|
# remove creation_date, which can't be set from python libtorrent
|
|
40
|
-
del expected[b"creation date"]
|
|
41
43
|
del created[b"creation date"]
|
|
44
|
+
if b"creation date" in expected:
|
|
45
|
+
del expected[b"creation date"]
|
|
42
46
|
|
|
43
47
|
# qbittorrent assigns trackers to the same tier by default,
|
|
44
48
|
# while we assign each to a different tier.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/sciop_cli-0.1.2/tests/data/basic.torrent → /sciop_cli-0.1.3/tests/data/basic_hybrid.torrent
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|