-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_usage_example.py
More file actions
40 lines (30 loc) · 980 Bytes
/
Copy pathbasic_usage_example.py
File metadata and controls
40 lines (30 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import asyncio
import os
import aiohttp
from dotenv import load_dotenv
from emt_madrid.main import EMTClient
# Load environment variables from .env file
load_dotenv()
STOP = 72
LINES = ["27", "150"]
if __name__ == "__main__":
async def main():
# Get required environment variables
email = os.getenv("EMT_API_EMAIL")
password = os.getenv("EMT_API_PASSWORD")
if not email or not password:
raise ValueError(
"EMT_API_EMAIL and EMT_API_PASSWORD environment variables must be set"
)
# Create a session and pass it to the EMTClient
async with aiohttp.ClientSession() as session:
emt_client = EMTClient(
email=email,
password=password,
stop_id=STOP,
lines=LINES,
session=session,
)
stop = await emt_client.get_arrivals()
print(stop)
asyncio.run(main())