Merge pull request '1.0.1' (#6) from dev into latest
All checks were successful
Build And Publish Package / publish (push) Successful in 23s
All checks were successful
Build And Publish Package / publish (push) Successful in 23s
Reviewed-on: #6
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "oxidespotify"
|
name = "oxidespotify"
|
||||||
version = "1.0.0"
|
version = "1.0.1"
|
||||||
description = "Client for Spotify API"
|
description = "Client for Spotify API"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
authors = [{ name = "Miwory", email = "miwory.uwu@gmail.com" }]
|
authors = [{ name = "Miwory", email = "miwory.uwu@gmail.com" }]
|
||||||
|
|||||||
@ -1,7 +1,13 @@
|
|||||||
from datetime import datetime
|
from datetime import date, datetime
|
||||||
from typing import Literal
|
from typing import Annotated, Literal
|
||||||
|
|
||||||
from pydantic import BaseModel, HttpUrl, RootModel, field_validator
|
from pydantic import (
|
||||||
|
BaseModel,
|
||||||
|
BeforeValidator,
|
||||||
|
HttpUrl,
|
||||||
|
RootModel,
|
||||||
|
field_validator,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Error(Exception):
|
class Error(Exception):
|
||||||
@ -22,6 +28,21 @@ class InternalError(Error):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def normalize_spotify_date(v: str) -> str:
|
||||||
|
parts = v.split('-')
|
||||||
|
if len(parts) == 1:
|
||||||
|
return f'{v}-01-01'
|
||||||
|
if len(parts) == 2:
|
||||||
|
return f'{v}-01'
|
||||||
|
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
|
PrecisionedReleaseDate = Annotated[
|
||||||
|
date, BeforeValidator(normalize_spotify_date)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class Token(BaseModel):
|
class Token(BaseModel):
|
||||||
token_type: Literal['Bearer']
|
token_type: Literal['Bearer']
|
||||||
access_token: str
|
access_token: str
|
||||||
@ -134,7 +155,7 @@ class BaseAlbum(BaseModel):
|
|||||||
id: str
|
id: str
|
||||||
images: list[Image]
|
images: list[Image]
|
||||||
name: str
|
name: str
|
||||||
release_date: datetime
|
release_date: PrecisionedReleaseDate
|
||||||
release_date_precision: Literal['year', 'month', 'day']
|
release_date_precision: Literal['year', 'month', 'day']
|
||||||
restrictions: Restriction | None = None
|
restrictions: Restriction | None = None
|
||||||
type: Literal['album']
|
type: Literal['album']
|
||||||
@ -206,7 +227,7 @@ class AudioBookChapter(BaseModel):
|
|||||||
is_playable: bool
|
is_playable: bool
|
||||||
languages: list[str]
|
languages: list[str]
|
||||||
name: str
|
name: str
|
||||||
release_date: datetime
|
release_date: PrecisionedReleaseDate
|
||||||
release_date_precision: Literal['year', 'month', 'day']
|
release_date_precision: Literal['year', 'month', 'day']
|
||||||
resume_point: ResumePoint
|
resume_point: ResumePoint
|
||||||
type: Literal['episode']
|
type: Literal['episode']
|
||||||
|
|||||||
Reference in New Issue
Block a user