문제

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.

도움이 되었습니까?

해결책

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()
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top