Advertisement
Toumo

jojo_alarma.py

Feb 9th, 2023 (edited)
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. import os
  2. import sys
  3. import time
  4. from datetime import datetime
  5. from datetime import timedelta
  6.  
  7. os.chdir(os.path.dirname(os.path.abspath(__file__))) # Camino a roundabout.mp3
  8.  
  9. h, m = 16, 20 # Hora y minuto en formato 24:60
  10. if len(sys.argv) > 1:
  11.     h, m = int(sys.argv[1]), int(sys.argv[2])
  12.  
  13. now = datetime.now()
  14. target = datetime(now.year, now.month, now.day, h, m, 0)
  15. target -= timedelta(seconds = 43.8) # Tarda aprox 44 en llegar al drop
  16.  
  17. t_step = 0.01
  18. while (target - now).total_seconds() > t_step:
  19.     now = datetime.now()
  20.     time.sleep(t_step)
  21.  
  22. os.system("mpv roundabout.mp3")
  23. print("To be continued...")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement