Small changes
parent
56ff5d4cc3
commit
dafc04a109
|
@ -43,11 +43,13 @@ async def main():
|
||||||
)
|
)
|
||||||
|
|
||||||
for field_name, start_time, duration, weather_names in res:
|
for field_name, start_time, duration, weather_names in res:
|
||||||
|
# Very satisfying, create a set & sort it using the original list's index
|
||||||
pruned_weather_names = sorted(set(weather_names),
|
pruned_weather_names = sorted(set(weather_names),
|
||||||
key=lambda x: weather_names.index(x))
|
key=lambda x: weather_names.index(x))
|
||||||
|
|
||||||
print("{} ({}, {}m): {}".format(
|
print("{} ({}, {}m): {}".format(
|
||||||
field_name,
|
field_name,
|
||||||
start_time.strftime("%d:%m:%y %H:%M"),
|
start_time.strftime("%Y-%m-%d %H:%M"),
|
||||||
int(duration.total_seconds() // 60),
|
int(duration.total_seconds() // 60),
|
||||||
" -> ".join(pruned_weather_names)
|
" -> ".join(pruned_weather_names)
|
||||||
))
|
))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from tennis import get_time_slots, get_club_address
|
from tennis import get_time_slots, get_club_address
|
||||||
from weather import WeatherAPI
|
from weather import WeatherAPI
|
||||||
from datetime import timedelta
|
from datetime import timedelta, datetime
|
||||||
import asyncio as aio
|
import asyncio as aio
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,8 +30,9 @@ async def get_decent_timeslots(club_id, weather_api_key, days=1):
|
||||||
date_obj: weather_str for date_obj, weather_str, _ in weather_forecasts
|
date_obj: weather_str for date_obj, weather_str, _ in weather_forecasts
|
||||||
}
|
}
|
||||||
|
|
||||||
# Filter out non-free timeslots
|
# Filter out non-free timeslots or timeslots in the past
|
||||||
timeslots = list(filter(lambda x: x[1] == 0, timeslots))
|
now = datetime.now()
|
||||||
|
timeslots = list(filter(lambda x: x[1] == 0 and x[2] > now, timeslots))
|
||||||
|
|
||||||
output = []
|
output = []
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,7 @@ def extract_timeslots(tbody, column_headers):
|
||||||
|
|
||||||
for tr in tbody.findAll("tr"):
|
for tr in tbody.findAll("tr"):
|
||||||
# Determine time for row
|
# Determine time for row
|
||||||
time_str = tr.find("th").text
|
start_time = time.fromisoformat(tr.find("th").text)
|
||||||
hour, minute = map(int, time_str.split(":"))
|
|
||||||
start_time = time(hour=hour, minute=minute)
|
|
||||||
|
|
||||||
# Iterate over each column
|
# Iterate over each column
|
||||||
for td in tr.findAll("td"):
|
for td in tr.findAll("td"):
|
||||||
|
|
Loading…
Reference in New Issue