This commit is contained in:
@ -37,9 +37,10 @@ import asyncio
|
|||||||
from oxidetwitch.api import TwitchAPIClient
|
from oxidetwitch.api import TwitchAPIClient
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
async with TwitchClient(
|
async with TwitchAPIClient(
|
||||||
client_id="your_id",
|
client_id="your_id",
|
||||||
client_secret="your_client_secret",
|
client_secret="your_client_secret",
|
||||||
|
redirect_uri="https://example.com",
|
||||||
redis_url="redis://localhost:6379",
|
redis_url="redis://localhost:6379",
|
||||||
) as twitch:
|
) as twitch:
|
||||||
# Get user data (automatically cached if configured)
|
# Get user data (automatically cached if configured)
|
||||||
@ -57,11 +58,10 @@ If you are polling 100+ streams, OxideTwitch spaces out the requests using the *
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
async def poll_streams(channels):
|
async def poll_streams(channels):
|
||||||
async with TwitchClient(...) as twitch:
|
async with TwitchAPIClient(...) as twitch:
|
||||||
# These will be executed as fast as the rate limiter allows
|
# These will be executed as fast as the rate limiter allows
|
||||||
tasks = [twitch.get_stream(user_login=name) for name in channels]
|
tasks = [twitch.get_streams(..., user_login=name) for name in channels]
|
||||||
streams = await asyncio.gather(*tasks)
|
streams = await asyncio.gather(*tasks)
|
||||||
return [s for s in streams if s.is_live]
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user