1

I'm currently working on a bittorrent client in Python.

I'm trying to get the Peer Information from the Tracker for the torrent file to download ubuntu.

I've B-decoded the .torrent file and extracted the info dictionary and created a SHA1 hash from it (exactly as specified in the bittorrent protocol wiki).

I'm using python's requests library to send a HTTP Get request, but when I send the request, I get an error back.

This is my Python GET request for the Ubuntu torrent using the tracker_url as specified in the .torrent file

resp = requests.get('http://torrent.ubuntu.com:6969/announce?info_hash=%3F%19%B1I%F5%3AP%E1O%C0%B7%99%26%A3%91%89n%AB%ABo&peer_id=SAoe4hc3u3du0nepwp1h&compact=1&no_peer_id=0&event=started&port=6883&uploaded=0&downloaded=0&left=1178386432')

In response, I get a Response 200, and the resp.content is

b'd14:failure reason63:Requested download is not authorized for use with this tracker.e'

I'm wondering if someone could tell me what's wrong with my request? Thank you very much!

Somya Agrawal
  • 355
  • 2
  • 14
  • Not an answer, but you may want to look at this: http://markuseliasson.se/article/bittorrent-in-python/ – Gigaflop Aug 02 '18 at 15:44
  • Thanks for the link! I've seen that and been basing my code off that as well! I tried hashing the B-encoded info dict from that post and my URL matches that one. That's partly why I'm confused as to why my code doesn't seem to be working. Thanks! – Somya Agrawal Aug 02 '18 at 16:49
  • The problem is that that torrent is not whitelisted on the tracker. It has probably been removed because it's too old. Try a newer Ubuntu torrent. – Encombe Aug 04 '18 at 22:45

1 Answers1

0

just look on this answer, a lot of people already asked it https://stackoverflow.com/a/1019588/4399634

or you can use this bit-torrent client, it's very simple and useful https://github.com/borzunov/bit-torrent

frankegoesdown
  • 1,898
  • 1
  • 20
  • 38
  • Hi, thanks for the answer! I've tried the answer you've linked with requests.get('http://torrent.ubuntu.com:6969/announce?info_hash=%9A%813%3C%1B%16%E4%A8%3C%10%F3%05%2C%15%90%AA%DF%5E.%20&peer_id=ABCDEFGHIJKLMNOPQRST&port=6881&uploaded=0&downloaded=0&left=727955456&event=started&numwant=100&no_peer_id=1&compact=1') and I've gotten the same error... Requested download is not authorized for use with this tracker. I also tried replacing the peerID in that with the random peerID I created but I'm still getting the same error. – Somya Agrawal Aug 02 '18 at 16:43
  • 1
    By the way, I've tried the bit-torrent client you linked and I get the same error. I've looked through the source-code on that client too to extract the HTTP link it is using and if I try GET on that I get the same d14 failure. – Somya Agrawal Aug 03 '18 at 22:07