Created
July 30, 2020 22:05
-
-
Save rochacbruno/104a9e84f44f392d72326e9cd4c02374 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Usage: | |
wait time: 600 (10 minutes) | |
title: 'Hello World' | |
duration: 7200 (2 hours) | |
$ python countdown.py 600 'Titulo da Live' 7200 | |
""" | |
import os | |
import sys | |
import time | |
secs, msg, live = sys.argv[1:] | |
def countdown(t, l): | |
while t: | |
mins, secs = divmod(t, 60) | |
timeformat = "{:02d}:{:02d}".format(mins, secs) | |
print(timeformat, end="\r") | |
with open("countdown.txt", "w") as f: | |
f.write(timeformat) | |
time.sleep(1) | |
t -= 1 | |
with open("countdown.txt", "w") as f: | |
f.write(msg) | |
time.sleep(300) | |
while l: | |
mins, secs = divmod(l, 60) | |
timeformat = "{} - {:02d}:{:02d} minutes".format(msg, mins, secs) | |
print(timeformat, end="\r") | |
with open("countdown.txt", "w") as f: | |
f.write(timeformat) | |
time.sleep(1) | |
l -= 1 | |
with open("countdown.txt", "w") as f: | |
f.write("It is time to stop!!!") | |
while True: | |
os.system("mpg123 stop.mp3") | |
time.sleep(15) | |
print("Goodbye!\n\n\n\n\n") | |
countdown(int(secs), int(live)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment