proof of concept
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
venv/
|
||||
0
deps/__init__.py
vendored
Normal file
0
deps/__init__.py
vendored
Normal file
BIN
deps/__pycache__/__init__.cpython-312.pyc
vendored
Normal file
BIN
deps/__pycache__/__init__.cpython-312.pyc
vendored
Normal file
Binary file not shown.
1
deps/libtorrent-2.0.11.dist-info/INSTALLER
vendored
Normal file
1
deps/libtorrent-2.0.11.dist-info/INSTALLER
vendored
Normal file
@@ -0,0 +1 @@
|
||||
pip
|
||||
16
deps/libtorrent-2.0.11.dist-info/METADATA
vendored
Normal file
16
deps/libtorrent-2.0.11.dist-info/METADATA
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
Metadata-Version: 2.2
|
||||
Name: libtorrent
|
||||
Version: 2.0.11
|
||||
Summary: Python bindings for libtorrent-rasterbar
|
||||
Home-page: http://libtorrent.org
|
||||
Author: Arvid Norberg
|
||||
Author-email: arvid@libtorrent.org
|
||||
License: BSD
|
||||
Dynamic: author
|
||||
Dynamic: author-email
|
||||
Dynamic: description
|
||||
Dynamic: home-page
|
||||
Dynamic: license
|
||||
Dynamic: summary
|
||||
|
||||
Python bindings for libtorrent-rasterbar
|
||||
7
deps/libtorrent-2.0.11.dist-info/RECORD
vendored
Normal file
7
deps/libtorrent-2.0.11.dist-info/RECORD
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
libtorrent-2.0.11.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
libtorrent-2.0.11.dist-info/METADATA,sha256=sPtq23Wl5bUYxfIuAo34PrNgCXVR7j5icBJXapZiVX4,362
|
||||
libtorrent-2.0.11.dist-info/RECORD,,
|
||||
libtorrent-2.0.11.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
libtorrent-2.0.11.dist-info/WHEEL,sha256=siqMuoWpRueIZ87ijidBxnOwHeSOOcxNwYCs-pC4Yv0,151
|
||||
libtorrent-2.0.11.dist-info/top_level.txt,sha256=Va3S8jfMOK-hJMDdMSrC7MrqlelkXSU30H5E4QppA3c,11
|
||||
libtorrent/__init__.cpython-312-x86_64-linux-gnu.so,sha256=A37ASE55Ar1brGnb2Ptb85-TcV7E-vK3T3cE3zsDJxU,26320472
|
||||
0
deps/libtorrent-2.0.11.dist-info/REQUESTED
vendored
Normal file
0
deps/libtorrent-2.0.11.dist-info/REQUESTED
vendored
Normal file
6
deps/libtorrent-2.0.11.dist-info/WHEEL
vendored
Normal file
6
deps/libtorrent-2.0.11.dist-info/WHEEL
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: setuptools (75.8.0)
|
||||
Root-Is-Purelib: false
|
||||
Tag: cp312-cp312-manylinux_2_17_x86_64
|
||||
Tag: cp312-cp312-manylinux2014_x86_64
|
||||
|
||||
1
deps/libtorrent-2.0.11.dist-info/top_level.txt
vendored
Normal file
1
deps/libtorrent-2.0.11.dist-info/top_level.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
libtorrent
|
||||
BIN
deps/libtorrent/__init__.cpython-312-x86_64-linux-gnu.so
vendored
Executable file
BIN
deps/libtorrent/__init__.cpython-312-x86_64-linux-gnu.so
vendored
Executable file
Binary file not shown.
0
deps/requirements.txt
vendored
Normal file
0
deps/requirements.txt
vendored
Normal file
42
mvm.py
Normal file
42
mvm.py
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
import libtorrent as lt
|
||||
import time
|
||||
import os
|
||||
|
||||
ses = lt.session()
|
||||
ses.listen_on(6881, 6891)
|
||||
|
||||
magnet_uri = "magnet:?xt=urn:btih:19223321411e27f51213a2407842d773f0f8ac4e"
|
||||
params = {'save_path': './downloads/'}
|
||||
|
||||
handle = lt.add_magnet_uri(ses, magnet_uri, params)
|
||||
|
||||
print("Fetching metadata (torrent info)...")
|
||||
while not handle.has_metadata():
|
||||
time.sleep(1)
|
||||
print(".", end="", flush=True)
|
||||
|
||||
print("\nMetadata received!")
|
||||
|
||||
torrent_info = handle.get_torrent_info()
|
||||
|
||||
print("\nFiles in torrent:")
|
||||
for idx, f in enumerate(torrent_info.files()):
|
||||
print(f"[{idx}] {f.path} ({f.size / 1_000_000:.2f} MB)")
|
||||
|
||||
selected_indexes = [0, 2]
|
||||
|
||||
file_priorities = [0] * torrent_info.num_files()
|
||||
for i in selected_indexes:
|
||||
file_priorities[i] = 1
|
||||
|
||||
handle.prioritize_files(file_priorities)
|
||||
|
||||
print("\nDownloading selected files only...")
|
||||
while handle.status().state != lt.torrent_status.seeding:
|
||||
s = handle.status()
|
||||
print(f"\rProgress: {s.progress * 100:.2f}% | Down: {s.download_rate / 1000:.1f} kB/s | Peers: {s.num_peers}", end=" ")
|
||||
time.sleep(1)
|
||||
|
||||
print("\nDownload complete!")
|
||||
|
||||
Reference in New Issue
Block a user