From 98b58a4293aecb782d51c262f29ffdfb3d90078c Mon Sep 17 00:00:00 2001 From: BarsTiger Date: Wed, 17 Nov 2021 19:28:19 +0200 Subject: [PATCH] SuperTimer.py downloads alarm.mp3 at 1 superSec before alarm starts --- OfficialProjects/SuperTimer/SuperTimer.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/OfficialProjects/SuperTimer/SuperTimer.py b/OfficialProjects/SuperTimer/SuperTimer.py index f576ede..bc18856 100644 --- a/OfficialProjects/SuperTimer/SuperTimer.py +++ b/OfficialProjects/SuperTimer/SuperTimer.py @@ -10,9 +10,6 @@ except: subprocess.check_call([sys.executable, "-m", "pip", "install", 'playsound']) from playsound import playsound -if not os.path.isfile('alarm.mp3'): - urllib.request.urlretrieve("https://github.com/BarsTiger/KOTIKOTapps_download_repo/blob/master/FilesForDownloading/alarm.mp3?raw=true", 'alarm.mp3') - superSecond = float(input("Print how many real seconds will be in superSecond: ")) timeInSuperSeconds = int(input("Timer in superSeconds: ")) @@ -25,6 +22,11 @@ while timeInSuperSeconds > 0: formattedTimeInSuperSeconds = str(datetime.timedelta(seconds=timeInSuperSeconds)) print('Time remaining: {{:{:}}}'.format(width).format(formattedTimeInSuperSeconds), end='\r') timeInSuperSeconds -= 1 + if timeInSuperSeconds <= 1: + if not os.path.isfile('alarm.mp3'): + urllib.request.urlretrieve( + "https://github.com/BarsTiger/KOTIKOTapps_download_repo/blob/master/FilesForDownloading/alarm.mp3?raw=true", + 'alarm.mp3') time.sleep(superSecond) print("Press Ctrl + C to stop alarm")