Compare commits

...

7 Commits

Author SHA1 Message Date
d80d97bb9b Merge pull request '1.2.3' (#5) from dev into latest
All checks were successful
Build And Publish Package / publish (push) Successful in 36s
Reviewed-on: #5
2026-03-08 18:05:57 +03:00
4f78653596 Фикс получения EventSub
All checks were successful
Verify Dev Build / publish (push) Successful in 38s
2026-03-08 18:04:33 +03:00
19b8d7fb49 Merge pull request '1.2.2' (#4) from dev into latest
All checks were successful
Build And Publish Package / publish (push) Successful in 34s
Reviewed-on: #4
2026-03-08 07:32:09 +03:00
0e83d8eaa8 Исправлена работа клиента авторизации
Some checks failed
Verify Dev Build / publish (push) Has been cancelled
2026-03-08 07:30:55 +03:00
818affc74b Merge pull request '1.2.1' (#3) from dev into latest
All checks were successful
Build And Publish Package / publish (push) Successful in 35s
Reviewed-on: #3
2026-03-08 00:27:16 +03:00
645f7029ad Фикс base_url
All checks were successful
Verify Dev Build / publish (push) Successful in 38s
2026-03-08 00:25:32 +03:00
63a874b94c Правки README
All checks were successful
Verify Dev Build / publish (push) Successful in 38s
2026-02-26 17:57:07 +03:00
4 changed files with 19 additions and 17 deletions

View File

@ -37,9 +37,10 @@ import asyncio
from oxidetwitch.api import TwitchAPIClient
async def main():
async with TwitchClient(
async with TwitchAPIClient(
client_id="your_id",
client_secret="your_client_secret",
redirect_uri="https://example.com",
redis_url="redis://localhost:6379",
) as twitch:
# 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
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
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)
return [s for s in streams if s.is_live]
```

View File

@ -1,6 +1,6 @@
[project]
name = "oxidetwitch"
version = "1.2.0"
version = "1.2.3"
description = "Client for Twitch API"
readme = "README.md"
authors = [{ name = "Miwory", email = "miwory.uwu@gmail.com" }]

View File

@ -23,7 +23,7 @@ class TwitchAPIClient(OxideHTTP):
redis_url: str | None = None,
proxy_url: str | None = None,
) -> None:
self.base_uri = 'https://api.twitch.tv/helix'
self.base_uri = 'https://api.twitch.tv/helix/'
self.client_id = client_id
self.client_secret = client_secret
self.redirect_uri = redirect_uri
@ -1470,12 +1470,14 @@ class TwitchAPIClient(OxideHTTP):
'/eventsub/subscriptions',
s.EventsubBaseSubscriptions,
self._auth(access_token),
self.clean_dict(
{
'status': status,
'type': sub_type,
'user_id': user_id,
'subscription_id': subscription_id,
},
}
),
cache_ttl,
):
for item in data.data:

View File

@ -16,7 +16,7 @@ class TwitchAuthClient(OxideHTTP):
redis_url: str | None = None,
proxy_url: str | None = None,
) -> None:
self.base_uri = 'https://id.twitch.tv/oauth2'
self.base_uri = 'https://id.twitch.tv/oauth2/'
self.client_id = client_id
self.client_secret = client_secret
self.redirect_uri = redirect_uri
@ -62,7 +62,7 @@ class TwitchAuthClient(OxideHTTP):
match req.status_code:
case st.OK:
return s.AppAccessToken.model_validate(req.json())
return s.AppAccessToken.model_validate(await req.json())
case _:
raise s.InternalError(req.status_code, 'Internal Server Error')
@ -81,7 +81,7 @@ class TwitchAuthClient(OxideHTTP):
match req.status_code:
case st.OK:
return s.UserAccessToken.model_validate(req.json())
return s.UserAccessToken.model_validate(await req.json())
case st.BAD_REQUEST:
return None
@ -99,7 +99,7 @@ class TwitchAuthClient(OxideHTTP):
match req.status_code:
case st.OK:
return s.AccessTokenValidation.model_validate(req.json())
return s.AccessTokenValidation.model_validate(await req.json())
case st.UNAUTHORIZED:
return None
@ -122,7 +122,7 @@ class TwitchAuthClient(OxideHTTP):
match req.status_code:
case st.OK:
return s.UserAccessToken.model_validate(req.json())
return s.UserAccessToken.model_validate(await req.json())
case st.BAD_REQUEST:
return None