Compare commits

..

No commits in common. "dafc04a109b4a08baa506bfec4671769eef91c05" and "8114498ca12601990f996a604fcf0c50e8a34b12" have entirely different histories.

3 changed files with 9 additions and 16 deletions

View File

@ -42,17 +42,7 @@ async def main():
args.club_id, config["DEFAULT"]["weather_api_key"], args.days
)
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),
key=lambda x: weather_names.index(x))
print("{} ({}, {}m): {}".format(
field_name,
start_time.strftime("%Y-%m-%d %H:%M"),
int(duration.total_seconds() // 60),
" -> ".join(pruned_weather_names)
))
print(res)
if __name__ == "__main__":

View File

@ -1,6 +1,6 @@
from tennis import get_time_slots, get_club_address
from weather import WeatherAPI
from datetime import timedelta, datetime
from datetime import timedelta
import asyncio as aio
@ -29,10 +29,11 @@ async def get_decent_timeslots(club_id, weather_api_key, days=1):
weather_forecasts = {
date_obj: weather_str for date_obj, weather_str, _ in weather_forecasts
}
print(weather_forecasts)
# Filter out non-free timeslots or timeslots in the past
now = datetime.now()
timeslots = list(filter(lambda x: x[1] == 0 and x[2] > now, timeslots))
# Filter out non-free timeslots
timeslots = list(filter(lambda x: x[1] == 0, timeslots))
print(timeslots)
output = []

View File

@ -13,7 +13,9 @@ def extract_timeslots(tbody, column_headers):
for tr in tbody.findAll("tr"):
# Determine time for row
start_time = time.fromisoformat(tr.find("th").text)
time_str = tr.find("th").text
hour, minute = map(int, time_str.split(":"))
start_time = time(hour=hour, minute=minute)
# Iterate over each column
for td in tr.findAll("td"):