@@ -213,20 +213,22 @@ def main():
213213 if LOG_LEVEL == "DEBUG" :
214214 interval = 30
215215 else :
216- # Si on est hors de la plage minuit-7h, on attend jusqu'à minuit
217- if not (0 <= now .hour < 3 ):
218- next_midnight = (now + datetime .timedelta (days = 1 )).replace (hour = 0 , minute = 0 , second = 0 , microsecond = 0 )
219- sleep_seconds = (next_midnight - now ).total_seconds ()
220- print (f"Hors plage horaire, dodo jusqu'à minuit ({ next_midnight .strftime ('%Y-%m-%d %H:%M:%S' )} )" )
221- time .sleep (sleep_seconds )
222- continue
223216 interval = CHECK_INTERVAL
224217 now_tz = get_tz_time ()
225218 current_date = now_tz .date ()
226219 if window_date != current_date :
227220 window_date = current_date
228221 window_done = False
229222
223+ # Si on est hors de la plage minuit-3h, on attend directement jusqu'à 01:40
224+ if not (0 <= now_tz .hour < 3 ):
225+ next_140 = (now_tz + datetime .timedelta (days = 1 )).replace (hour = 1 , minute = 40 , second = 0 , microsecond = 0 )
226+ sleep_seconds = (next_140 - now_tz ).total_seconds ()
227+ print (f"Hors plage horaire, dodo jusqu'à 01:40 ({ next_140 .strftime ('%Y-%m-%d %H:%M:%S' )} )" )
228+ time .sleep (sleep_seconds )
229+ continue
230+
231+ # Entre 00:00 et 01:20 : checks normaux
230232 # Entre 01:20 et 01:40 : on attend 01:40
231233 if now_tz .hour == 1 and 20 <= now_tz .minute < 40 :
232234 next_140 = now_tz .replace (minute = 40 , second = 0 , microsecond = 0 )
@@ -235,24 +237,24 @@ def main():
235237 time .sleep (sleep_seconds )
236238 continue
237239
238- # Entre 01:40 et 01:59 : un seul check, puis dodo jusqu'au lendemain
240+ # À partir de 01:40 : un seul check, puis dodo jusqu'au lendemain à 01:40
239241 if now_tz .hour == 1 and now_tz .minute >= 40 :
240242 if window_done :
241- next_midnight = (now_tz + datetime .timedelta (days = 1 )).replace (hour = 0 , minute = 0 , second = 0 , microsecond = 0 )
242- sleep_seconds = max (0 , (next_midnight - now_tz ).total_seconds ())
243- print ("Check déjà fait à 01:40, dodo jusqu'au lendemain " )
243+ next_140 = (now_tz + datetime .timedelta (days = 1 )).replace (hour = 1 , minute = 40 , second = 0 , microsecond = 0 )
244+ sleep_seconds = max (0 , (next_140 - now_tz ).total_seconds ())
245+ print (f "Check déjà fait à 01:40, dodo jusqu'à demain 01:40 ( { next_140 . strftime ( '%Y-%m-%d %H:%M:%S' ) } ) " )
244246 time .sleep (sleep_seconds )
245247 continue
246- interval = CHECK_INTERVAL
248+ # Sinon on fait le check et on marquera window_done après
247249
248250 check_notes ()
249251 if LOG_LEVEL != "DEBUG" :
250252 now_tz = get_tz_time ()
251253 if now_tz .hour == 1 and now_tz .minute >= 40 :
252254 window_done = True
253- next_midnight = (now_tz + datetime .timedelta (days = 1 )).replace (hour = 0 , minute = 0 , second = 0 , microsecond = 0 )
254- sleep_seconds = max (0 , (next_midnight - now_tz ).total_seconds ())
255- print ("Check effectué à 01:40, dodo jusqu'au lendemain " )
255+ next_140 = (now_tz + datetime .timedelta (days = 1 )).replace (hour = 1 , minute = 40 , second = 0 , microsecond = 0 )
256+ sleep_seconds = max (0 , (next_140 - now_tz ).total_seconds ())
257+ print (f "Check effectué à 01:40, dodo jusqu'à demain 01:40 ( { next_140 . strftime ( '%Y-%m-%d %H:%M:%S' ) } ) " )
256258 time .sleep (sleep_seconds )
257259 continue
258260
0 commit comments