mirror of
https://github.com/NohamR/Ratio.py.git
synced 2025-05-24 00:38:57 +00:00
timer
This commit is contained in:
parent
3621afa8bd
commit
1861b4599d
@ -83,8 +83,8 @@ class process_torrent():
|
|||||||
peers.append((ip, port))
|
peers.append((ip, port))
|
||||||
self.interval = response['interval']
|
self.interval = response['interval']
|
||||||
|
|
||||||
def seedqueue(queue):
|
def seedqueue(queue, time):
|
||||||
while True:
|
while time > 0:
|
||||||
waitingqueue = ""
|
waitingqueue = ""
|
||||||
for torrent in queue:
|
for torrent in queue:
|
||||||
if torrent.timer <= 0:
|
if torrent.timer <= 0:
|
||||||
@ -113,3 +113,4 @@ def seedqueue(queue):
|
|||||||
os.system('cls' if os.name == 'nt' else 'clear')
|
os.system('cls' if os.name == 'nt' else 'clear')
|
||||||
print(waitingqueue)
|
print(waitingqueue)
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
time -= 1
|
21
ratio.py
21
ratio.py
@ -8,6 +8,8 @@ def parse_args():
|
|||||||
"""Create the arguments"""
|
"""Create the arguments"""
|
||||||
parser = argparse.ArgumentParser(description="Fake ratio")
|
parser = argparse.ArgumentParser(description="Fake ratio")
|
||||||
parser.add_argument("-c", "--configuration", help="Configuration file")
|
parser.add_argument("-c", "--configuration", help="Configuration file")
|
||||||
|
parser.add_argument("-t", "--time", help="Time to seed", type=str, default="1d")
|
||||||
|
# parser.add_argument("-s", "--speed", help="Speed to seed", type=str, default="350")
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
def load_configuration(configuration_file):
|
def load_configuration(configuration_file):
|
||||||
@ -17,6 +19,22 @@ def load_configuration(configuration_file):
|
|||||||
return None
|
return None
|
||||||
return configuration
|
return configuration
|
||||||
|
|
||||||
|
def get_time(timestring):
|
||||||
|
days = hours = minutes = seconds = 0
|
||||||
|
if 'd' in timestring:
|
||||||
|
days, timestring = timestring.split('d')
|
||||||
|
days = int(days)
|
||||||
|
if 'h' in timestring:
|
||||||
|
hours, timestring = timestring.split('h')
|
||||||
|
hours = int(hours)
|
||||||
|
if 'm' in timestring:
|
||||||
|
minutes, timestring = timestring.split('m')
|
||||||
|
minutes = int(minutes)
|
||||||
|
if 's' in timestring:
|
||||||
|
seconds = int(timestring.split('s')[0])
|
||||||
|
total_seconds = days * 86400 + hours * 3600 + minutes * 60 + seconds
|
||||||
|
return total_seconds
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
queue = []
|
queue = []
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
@ -40,4 +58,5 @@ if __name__ == "__main__":
|
|||||||
torrent = process_torrent(config)
|
torrent = process_torrent(config)
|
||||||
queue.append(torrent)
|
queue.append(torrent)
|
||||||
print(f'Got {len(queue)} torrents')
|
print(f'Got {len(queue)} torrents')
|
||||||
seedqueue(queue)
|
time = get_time(args.time)
|
||||||
|
seedqueue(queue, time)
|
Loading…
x
Reference in New Issue
Block a user