mirror of
https://github.com/NohamR/Ratio.py.git
synced 2025-05-24 00:38:57 +00:00
Add upload in configuration
This commit is contained in:
parent
39467076e4
commit
1d7385e6d4
@ -18,14 +18,17 @@ class process_torrent():
|
|||||||
|
|
||||||
def __init__(self, configuration):
|
def __init__(self, configuration):
|
||||||
self.configuration = configuration
|
self.configuration = configuration
|
||||||
|
self.open_torrent()
|
||||||
|
self.torrentclient = Transmission292(self.tracker_info_hash())
|
||||||
|
|
||||||
|
def open_torrent(self):
|
||||||
torrent_file = self.configuration['torrent']
|
torrent_file = self.configuration['torrent']
|
||||||
with open(torrent_file, 'rb') as tf:
|
with open(torrent_file, 'rb') as tf:
|
||||||
data = tf.read()
|
data = tf.read()
|
||||||
self.b_enc = bencoding()
|
self.b_enc = bencoding()
|
||||||
self.metainfo = self.b_enc.bdecode(data)
|
self.metainfo = self.b_enc.bdecode(data)
|
||||||
self.info = self.metainfo['info']
|
self.info = self.metainfo['info']
|
||||||
print(pretty_data(self.info))
|
# print(pretty_data(self.info))
|
||||||
self.torrentclient = Transmission292(self.tracker_info_hash())
|
|
||||||
|
|
||||||
def tracker_info_hash(self):
|
def tracker_info_hash(self):
|
||||||
raw_info = self.b_enc.get_dict('info')
|
raw_info = self.b_enc.get_dict('info')
|
||||||
@ -90,14 +93,20 @@ class process_torrent():
|
|||||||
def tracker_process(self):
|
def tracker_process(self):
|
||||||
while True:
|
while True:
|
||||||
print('----------- Sending Command to Tracker --------')
|
print('----------- Sending Command to Tracker --------')
|
||||||
|
|
||||||
|
# get upload
|
||||||
min_up = self.interval-(self.interval*0.1)
|
min_up = self.interval-(self.interval*0.1)
|
||||||
max_up = self.interval
|
max_up = self.interval
|
||||||
uploaded = 500000*random.randint(min_up, max_up)
|
randomize_upload = random.randint(min_up, max_up)
|
||||||
|
uploaded = int(self.configuration['upload'])*1000*randomize_upload
|
||||||
|
|
||||||
|
# get download
|
||||||
|
downloaded = 0
|
||||||
|
|
||||||
tc = self.torrentclient
|
tc = self.torrentclient
|
||||||
headers = tc.get_headers()
|
headers = tc.get_headers()
|
||||||
params = tc.get_query(uploaded=uploaded,
|
params = tc.get_query(uploaded=uploaded,
|
||||||
downloaded=0,
|
downloaded=downloaded,
|
||||||
left=0,
|
left=0,
|
||||||
event='stopped')
|
event='stopped')
|
||||||
content = self.send_request(params, headers)
|
content = self.send_request(params, headers)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user