Compare commits

...

3 Commits

Author SHA1 Message Date
7e4807f95a Добавлено более подробное описание ошибки
All checks were successful
Verify Dev Build / publish (push) Successful in 33s
2026-03-08 21:48:27 +03:00
88f6bbb7db Фикс статус кода при отсутствии модели
All checks were successful
Verify Dev Build / publish (push) Successful in 31s
2026-03-08 17:55:24 +03:00
c7ffb2608d Добавлено 2 эндпоинта на скип текущего и возврат прошлого сонга
All checks were successful
Verify Dev Build / publish (push) Successful in 32s
2026-03-08 10:10:21 +03:00
3 changed files with 26 additions and 7 deletions

View File

@ -1,6 +1,6 @@
[project]
name = "oxidespotify"
version = "0.1.1"
version = "0.2.2"
description = "Client for Spotify API"
readme = "README.md"
authors = [{ name = "Miwory", email = "miwory.uwu@gmail.com" }]

View File

@ -36,7 +36,9 @@ class SpotifyAPIClient(OxideHTTP):
async def _process[T: BaseModel](
self, req: Response | CachedResponse, schema: type[T] | None
) -> T | None:
if req.status_code == 204:
if req.status_code == 204 or (
req.status_code == 200 and schema is None
):
return None
if req.status_code >= 500:
@ -128,11 +130,27 @@ class SpotifyAPIClient(OxideHTTP):
async def pause_playback(self) -> NoReturn:
raise NotImplementedError
async def skip_to_next(self) -> NoReturn:
raise NotImplementedError
async def skip_to_next(self, access_token: str, device_id: str) -> None:
req = self.post(
'/me/player/next',
params={'device_id': device_id},
headers=self._auth(access_token),
)
async def skip_to_previous(self) -> NoReturn:
raise NotImplementedError
req = await self._process_request(req)
return await self._process(req, None)
async def skip_to_previous(
self, access_token: str, device_id: str
) -> None:
req = self.post(
'/me/player/previous',
params={'device_id': device_id},
headers=self._auth(access_token),
)
req = await self._process_request(req)
return await self._process(req, None)
async def seek_to_position(self) -> NoReturn:
raise NotImplementedError

View File

@ -41,7 +41,8 @@ class SpotifyAuthClient(OxideHTTP):
data = await req.json()
if req.status_code >= 400:
raise s.ClientError(req.status_code, data['error'])
err = f'{data["error"]}: {data["error_description"]}'
raise s.ClientError(req.status_code, err)
return schema.model_validate(data)