'I want to get the information of a torrent file in a desired format through python
I am writing code to parse tracker information in torrent file using python.
import bencoder
import sys
target = './'+sys.argv[1]
with open(target, 'rb') as torrent_file:
torrent = bencoder.decode(torrent_file.read())
i=0
while True:
try:
print(torrent[b'announce-list'][i])
i+=1
except:
break
The output is as follows.
[b'udp://tracker.openbittorrent.com:80/announce']
[b'udp://tracker.opentrackr.org:1337/announce']
I want to parse the value in the form below.
["tracker.openbittorrent.com", 80]
["tracker.opentrackr.org", 1337]
How should I parse it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
