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
|
"""Example usage of pylaunches."""
import asyncio
import logging
import os
from pylaunches import PyLaunches, PyLaunchesError
logging.basicConfig(
level=logging.INFO,
format="%(message)s",
handlers=[logging.StreamHandler()],
)
log = logging.getLogger(__name__)
async def example():
"""Example usage of pylaunches."""
async with PyLaunches(token=os.environ.get("LAUNCH_TOKEN"), dev=True) as client:
try:
events = await client.event_upcoming(filters={"limit": 1})
for event in events:
log.info("%s: %s", event["date"], event["name"])
except PyLaunchesError as exception:
log.exception(exception)
asyncio.run(example())
|