views:

379

answers:

1

Hi, so I've read the Bittorrent specification and done a number of searches, trying to find out how I can get the seeds/peers/downloaded data from a torrent tracker (using Python). I can calculate the info hash from a Torrent no problem, which matches up with the info hash given by various working torrent applications.

However, when I try to get the information from the tracker I either timeout (the tracker is working) or get empty data, depending on what form I put the URL in:

http://tracker.openbittorrent.com/scrape?info%5Fhash=a8c482902b1c735de462479721b011dc7b3d3558 - timeout

I was told that this should be 20 characters long, so took a substring, but this gives empty data.

http://tracker.openbittorrent.com/scrape?info%5Fhash=a8c482902b1c735de462 - d5:filesdee

I think I have misunderstood something with how I should encode or make the infohash for the scrape URL, but can't for the life of me see where.

+1  A: 

You're passing in a hex-character representation of the info_hash. It should be a binary representation. To get unprintable bytes into the URL use URL-encoding:

/scrape?info_hash=%A8%C4%82%90%2B%1Cs%5D%E4bG%97%21%B0%11%DC%7B%3D5X

(I'd also try to avoid encoding the _ in the info_hash parameter... not that it isn't correct, but it's the sort of thing I would expect some written-for-speed trackers to mess up.)

bobince