Format main file
This commit is contained in:
parent
553365c108
commit
cf968da148
1 changed files with 12 additions and 3 deletions
|
|
@ -8,6 +8,7 @@ from typing import Annotated, Any
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import typer
|
import typer
|
||||||
|
from rich import print
|
||||||
|
|
||||||
BASE_URL = "https://www.nightjet.com"
|
BASE_URL = "https://www.nightjet.com"
|
||||||
BASE_DIR = "out"
|
BASE_DIR = "out"
|
||||||
|
|
@ -277,7 +278,9 @@ def query(
|
||||||
) -> list[Price]:
|
) -> list[Price]:
|
||||||
token = get_init_token()
|
token = get_init_token()
|
||||||
connections = request_connections(token, start_station, end_station, travel_date)
|
connections = request_connections(token, start_station, end_station, travel_date)
|
||||||
booking_requests = connection_data_to_booking_requests(connections, traveller_birthdate=traveller_birthdate)
|
booking_requests = connection_data_to_booking_requests(
|
||||||
|
connections, traveller_birthdate=traveller_birthdate
|
||||||
|
)
|
||||||
bookings = [request_bookings(token, req) for req in booking_requests]
|
bookings = [request_bookings(token, req) for req in booking_requests]
|
||||||
prices = extract_prices(bookings)
|
prices = extract_prices(bookings)
|
||||||
|
|
||||||
|
|
@ -299,7 +302,10 @@ def main(
|
||||||
end_station: int = typer.Option(
|
end_station: int = typer.Option(
|
||||||
END_STATION, help="Destination station number. (default: Paris Est)"
|
END_STATION, help="Destination station number. (default: Paris Est)"
|
||||||
),
|
),
|
||||||
birthdate: str = typer.Option(TRAVELLER_BIRTHDATE.strftime("%Y-%m-%d"), help="Traveller birthdate, may be important for discounts. (YYYY-MM-DD)"),
|
birthdate: str = typer.Option(
|
||||||
|
TRAVELLER_BIRTHDATE.strftime("%Y-%m-%d"),
|
||||||
|
help="Traveller birthdate, may be important for discounts. (YYYY-MM-DD)",
|
||||||
|
),
|
||||||
notification_channel: str = typer.Option(
|
notification_channel: str = typer.Option(
|
||||||
NOTIFICATION_CHANNEL, help="ntfy channel to inform user on."
|
NOTIFICATION_CHANNEL, help="ntfy channel to inform user on."
|
||||||
),
|
),
|
||||||
|
|
@ -338,7 +344,10 @@ def main(
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
prices = query(
|
prices = query(
|
||||||
start_station=start_station, end_station=end_station, travel_date=travel_date_obj, traveller_birthdate=birth_date_obj,
|
start_station=start_station,
|
||||||
|
end_station=end_station,
|
||||||
|
travel_date=travel_date_obj,
|
||||||
|
traveller_birthdate=birth_date_obj,
|
||||||
)
|
)
|
||||||
|
|
||||||
# create a snapshot of all current prices
|
# create a snapshot of all current prices
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue