some fix, well fucked up gregorian calendar...

This commit is contained in:
localhost_frssoft 2024-07-16 16:04:36 +03:00
parent e696eaa375
commit 9b1fc812d4
2 changed files with 13 additions and 5 deletions

View File

@ -1,20 +1,20 @@
from src import listener_context, listener_mention, imdb_datasets_worker
from src import listener_context, listener_mention
from config import logger_default_level
from loguru import logger
import time
import sys
def main():
logger.remove()
logger.add(sink=sys.stderr, level=logger_default_level)
logger.add(sink='suggestions.log', level='INFO', filter='src.listener_context')
listener_mention.run_scan_notif() # Слушаем упоминания в фоне
listener_mention.run_scan_notif() # Слушаем упоминания в фоне
time.sleep(1)
listener_context.scan_context_thread() # Слушаем тред на новые предложения фильмов
listener_context.scan_context_thread() # Слушаем тред на новые предложения фильмов
if __name__ == '__main__':
main()

View File

@ -8,8 +8,16 @@ def check_stop_thread_scan(suggested_date):
suggested_year = suggested_date.year
tuesdays = []
for i in calendar.Calendar().itermonthdays4(suggested_year, suggested_month):
print(i)
if i[3] == 1 and datetime.datetime(year=i[0], month=i[1], day=i[2]) > suggested_date:
tuesdays.append(datetime.datetime(
year=i[0], month=i[1], day=i[2], hour=hour_poll_posting))
if tuesdays == []:
shift_for_next_week = suggested_date + datetime.timedelta(days=1)
suggested_month = shift_for_next_week.month
suggested_year = shift_for_next_week.year
for i in calendar.Calendar().itermonthdays4(suggested_year, suggested_month):
if i[3] == 1 and datetime.datetime(year=i[0], month=i[1], day=i[2]) > suggested_date:
tuesdays.append(datetime.datetime(
year=i[0], month=i[1], day=i[2], hour=hour_poll_posting))
return tuesdays[0] # near tuesday