-
I'm writing a peertube mirror in python that's supposed to use libtorrent, but I can't seem to get it to work. The status is stuck at "downloading_metadata".
$ uname -mor
5.16.11-lp153.2.g90630c5-default x86_64 GNU/Linux
$ python --version
Python 3.9.10
$ python -c "import libtorrent; print(libtorrent.version)"
2.0.5.0 CodeMostly copied from the example. import sys
import time
from pathlib import Path
import libtorrent as lt
ses = lt.session({'listen_interfaces': '0.0.0.0:6881'})
download_dir_path = Path("/tmp/tilvids/")
download_dir_path.mkdir(parents=True, exist_ok=True)
download_file_path = download_dir_path / "video"
magnet_uri = "magnet:?xs=https%3A%2F%2Ftilvids.com%2Flazy-static%2Ftorrents%2Fd86fade7-561c-481a-b5bb-e8421177638c-1080.torrent&xt=urn:btih:9ae6455145efe03ae11f4da742bbfddadc3ffe18&dn=Eternal+Inflation%3A+The+Theory+of+Infinite+Big+Bangs&tr=https%3A%2F%2Ftilvids.com%2Ftracker%2Fannounce&tr=wss%3A%2F%2Ftilvids.com%3A443%2Ftracker%2Fsocket&ws=https%3A%2F%2Ftilvids.com%2Fstatic%2Fwebseed%2Fd86fade7-561c-481a-b5bb-e8421177638c-1080.mp4"
add_torrent_params = lt.parse_magnet_uri(magnet_uri)
add_torrent_params.save_path = str(download_file_path)
h = ses.add_torrent(add_torrent_params)
s = h.status()
print('starting', s.name)
while (not s.is_seeding):
s = h.status()
print(
'\r%.2f%% complete (down: %.1f kB/s up: %.1f kB/s peers: %d) %s' % (
s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000,
s.num_peers, s.state), end=' '
)
alerts = ses.pop_alerts()
for a in alerts:
if a.category() & lt.alert.category_t.error_notification:
print(a)
sys.stdout.flush()
time.sleep(1)
print(h.status().name, 'complete') Output
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
The |
Beta Was this translation helpful? Give feedback.
-
support for the webtorrent protocol is in the |
Beta Was this translation helpful? Give feedback.
support for the webtorrent protocol is in the
master
branch of libtorrent