Skip to content

Commit

Permalink
small fixes for search top songs, version poetry + setup.py update, f…
Browse files Browse the repository at this point in the history
…ix parse_obj to model_validate
  • Loading branch information
dotX12 committed Oct 29, 2024
1 parent 7d24b1c commit 978a1b3
Show file tree
Hide file tree
Showing 7 changed files with 763 additions and 494 deletions.
1,223 changes: 743 additions & 480 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ include = [
]

[tool.poetry.dependencies]
python = "^3.8"
numpy = "^1.24.0"
python = "^3.10"
numpy = "2.1.2"
aiohttp = "^3.8.3"
pydub = "^0.25.1"
dataclass-factory = "2.16"
aiofiles = "23.2.1"
anyio = "4.3.0"
shazamio-core = "^1.0.7"
aiohttp-retry = "^2.8.3"

pydantic = "2.9.2"
[tool.poetry.dev-dependencies]
black = {version = "^24.2.0", allow-prereleases = true}
pytest = "8.1.2"
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="shazamio",
version="0.5.1",
version="0.7.0",
author="dotX12",
description="Is a FREE asynchronous library from reverse engineered Shazam API written in Python 3.6+ with asyncio and aiohttp. Includes all the methods that Shazam has, including searching for a song by file.",
long_description=long_description,
Expand All @@ -20,5 +20,5 @@
"shazamio_core",
],
packages=setuptools.find_packages(),
python_requires=">=3.8",
python_requires=">=3.10",
)
7 changes: 5 additions & 2 deletions shazamio/schemas/artist/views/top_song.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

from shazamio.schemas.artist.views.top_music import PlayParams
from shazamio.schemas.attributes import AttributeName
from shazamio.schemas.base import BaseAttributesModel, BaseIdTypeHref
from shazamio.schemas.base import (
BaseAttributesModel,
BaseHrefNext,
)
from shazamio.schemas.photos import ImageModel
from shazamio.schemas.urls import UrlDTO

Expand Down Expand Up @@ -36,6 +39,6 @@ class AttributesTopSong(BaseModel):
content_rating: Optional[str] = Field(None, alias="contentRating")


class TopSong(BaseIdTypeHref):
class TopSong(BaseHrefNext):
attributes: Optional[AttributeName] = None
data: Optional[List[BaseAttributesModel[AttributesTopSong]]] = None
7 changes: 5 additions & 2 deletions shazamio/schemas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class BaseIdTypeHref(BaseHref):
type: str


class BaseHrefNext(BaseHref):
next: Optional[str] = None


class BaseIdTypeHrefAttributesModel(BaseIdTypeHref, Generic[T]):
attributes: T

Expand All @@ -28,8 +32,7 @@ class BaseDataModel(BaseModel, Generic[T]):
data: T


class BaseHrefNextData(BaseHref, Generic[T]):
next: Optional[str] = None
class BaseHrefNextData(BaseHrefNext, Generic[T]):
data: T


Expand Down
2 changes: 1 addition & 1 deletion shazamio/schemas/playlist/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PlayListAttributes(BaseModel):
url: str
play_params: Optional[PlayParams] = Field(None, alias="playParams")
disc_number: int = Field(..., alias="discNumber")
has_credits: bool = Field(..., alias="hasCredits")
has_credits: Optional[bool] = Field(None, alias="hasCredits")
is_apple_digital_master: bool = Field(..., alias="isAppleDigitalMaster")
has_lyrics: bool = Field(..., alias="hasLyrics")
audio_traits: List[str] = Field(..., alias="audioTraits")
Expand Down
8 changes: 4 additions & 4 deletions shazamio/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def track(cls, data):

@classmethod
def playlist(cls, data) -> PlayList:
return PlayList.parse_obj(data)
return PlayList.model_validate(data)

@classmethod
def playlists(cls, data) -> List[PlayList]:
Expand All @@ -33,11 +33,11 @@ def youtube(cls, data):

@classmethod
def artist_v2(cls, data) -> ArtistResponse:
return ArtistResponse.parse_obj(data)
return ArtistResponse.model_validate(data)

@classmethod
def artist_albums(cls, data) -> FullAlbumsModel:
return FullAlbumsModel.parse_obj(data)
return FullAlbumsModel.model_validate(data)

@classmethod
def artist(cls, data):
Expand All @@ -49,4 +49,4 @@ def full_track(cls, data):

@classmethod
def album_info(cls, data) -> BaseDataModel[List[AlbumModel]]:
return BaseDataModel[List[AlbumModel]].parse_obj(data)
return BaseDataModel[List[AlbumModel]].model_validate(data)

0 comments on commit 978a1b3

Please sign in to comment.