Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python package to create "webseed" torrent file?

The bittorrent extension called webseed allows a simple HTTP/FTP server to help serve content to a BitTorrent network. I'm serving content from a HTTP webserver, and I'd also like to provide .torrent files to seed using this method. I'd like to use Python to generate the .torrent files.

Which Python torrent library could/should I use to facilitate webseeding?

The PyPi index lists lots of python bittorrent packages, but I'm hoping that I don't need full torrent client functionality, just something that can create these .torrent files with all the checksums etc. I don't mind using a full-featured lib, just not sure what to go for in this case.

like image 954
Dan Stowell Avatar asked Dec 11 '25 05:12

Dan Stowell


1 Answers

Well, it seems at least that libtorrent can put webseed info into the torrent file, and this can be used via the python-libtorrent package. (This means it's not a pure-python approach but that's OK.)

Code sketch:

import libtorrent as lt
piece_size = 256 * 1024
creator_str = "python-libtorrent"
thetracker = "your desired tracker"
theurlseed = "your desired url seed"

fs = lt.file_storage()
lt.add_files(fs, "/tmp/torrentme")
fs.num_files()

t = lt.create_torrent(fs, piece_size)
t.add_tracker(thetracker)
lt.set_piece_hashes(t, ".")

t.set_creator(creator_str)
t.add_url_seed(theurlseed)
t.generate()
like image 139
Dan Stowell Avatar answered Dec 12 '25 18:12

Dan Stowell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!