m2t
m2t copied to clipboard
QQ: scraper library
I'm trying to cobble something together to take a torrent / magnet as input, get the HASH and Trackers, then verify that there are at lease X seeds active. I found your library on a stackoverflow there and wondering if you could suggest a method. My attempt so far has failed with either "TypeError: Odd-length string" or bombed due to domain not existing.
excerpt
Open torrent file
torrent_file = open(sys.argv[1], "rb")
metainfo = bencode.bdecode(torrent_file.read())
info = metainfo['info']
print metainfo['announce']
print hashlib.sha1(bencode.bencode(info)).hexdigest()
torrent_hash = hashlib.sha1(bencode.bencode(info)).hexdigest()
tracker = metainfo['announce']
scrape(tracker,torrent_hash)