]>
git.ipfire.org Git - people/shoehn/ipfire.org.git/blob - www/pages/torrent/__init__.py
3 TRACKER_URL
="http://tracker.ipfire.org:6969/stats?format=txt&mode=tpbs"
4 TORRENT_BASE
="/srv/pakfire/data/torrent"
10 from client
.bencode
import bencode
, bdecode
14 def __init__(self
, url
):
17 f
= urllib2
.urlopen(url
)
18 for line
in f
.readlines():
19 (hash, seeds
, peers
,) = line
.split(":")
20 self
.info
[hash] = (seeds
, peers
.rstrip("\n"),)
28 return self
.info
[hash]
34 def __init__(self
, file):
35 self
.name
= os
.path
.basename(file)
37 self
.info
= bdecode(f
.read())
41 print "File : %s" % self
.get_file()
42 print "Hash : %s" % self
.get_hash()
45 return sha
.sha(bencode(self
.info
["info"])).hexdigest().upper()
52 for file in os
.listdir(TORRENT_BASE
):
53 if not file.endswith(".torrent"):
55 file = os
.path
.join(TORRENT_BASE
, file)
56 torrent_files
.insert(0, TorrentObject(file))
59 tracker
= TrackerInfo(TRACKER_URL
)
61 class TorrentBox(web
.Box
):
62 def __init__(self
, file):
63 web
.Box
.__init
__(self
, file.name
, file.get_hash())
66 <strong>Seeders:</strong> %s<br />
67 <strong>Leechers:</strong> %s
68 </p>""" % tracker
.get(file.get_hash()))
70 <p style="text-align: right;">
71 <a href="http://download.ipfire.org/torrent/%s">Download</a>
72 </p>""" % (file.name
,))
75 class Content(web
.Content
):
76 def __init__(self
, name
):
77 web
.Content
.__init
__(self
, name
)
80 self
.w("<h3>IPFire Torrent Tracker</h3>")
81 for t
in torrent_files
: