mirror of
https://github.com/NohamR/Ratio.py.git
synced 2025-05-23 16:28:58 +00:00
timer
This commit is contained in:
parent
3621afa8bd
commit
1861b4599d
@ -83,8 +83,8 @@ class process_torrent():
|
||||
peers.append((ip, port))
|
||||
self.interval = response['interval']
|
||||
|
||||
def seedqueue(queue):
|
||||
while True:
|
||||
def seedqueue(queue, time):
|
||||
while time > 0:
|
||||
waitingqueue = ""
|
||||
for torrent in queue:
|
||||
if torrent.timer <= 0:
|
||||
@ -112,4 +112,5 @@ def seedqueue(queue):
|
||||
waitingqueue += f"Waiting {torrent.timer} seconds for {torrent.configuration['torrent']}" + "\n"
|
||||
os.system('cls' if os.name == 'nt' else 'clear')
|
||||
print(waitingqueue)
|
||||
sleep(1)
|
||||
sleep(1)
|
||||
time -= 1
|
21
ratio.py
21
ratio.py
@ -8,6 +8,8 @@ def parse_args():
|
||||
"""Create the arguments"""
|
||||
parser = argparse.ArgumentParser(description="Fake ratio")
|
||||
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()
|
||||
|
||||
def load_configuration(configuration_file):
|
||||
@ -17,6 +19,22 @@ def load_configuration(configuration_file):
|
||||
return None
|
||||
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__":
|
||||
queue = []
|
||||
args = parse_args()
|
||||
@ -40,4 +58,5 @@ if __name__ == "__main__":
|
||||
torrent = process_torrent(config)
|
||||
queue.append(torrent)
|
||||
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