-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
23 lines (19 loc) · 690 Bytes
/
main.py
File metadata and controls
23 lines (19 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from bencode_parser import *
from torrent import *
from peer import get_peers
from client import Client
from p2p import download
import random
import string
if __name__ == '__main__':
file = open('debian-10.3.0-amd64-netinst.iso.torrent', 'rb').read()
torrent = Torrent(decode(file))
url = torrent.build_tracker_url(torrent.peer_id, 80)
response = torrent.retrieve_response(url)
peers = get_peers(response)
#This will go into p2p
#worker = Client(peers[3],torrent.info_hash,peer_id)
#worker.send_unchoke()
# then send interested, then start download pieces, then put them together
download(torrent, peers)
#remove peers if they don't respond