Skip to content

Commit

Permalink
Big update.
Browse files Browse the repository at this point in the history
* All complex logic for song recognition has been moved to RUST (used pyo3).
* recognize_song deprecated.
* Added interface for custom HTTPClient.
* Added the ability to use a proxy.
* Added retry exponential.
* Code refactoring.
* The foundation has been laid to add logging to the project.
* Added random device for recognize requests, previously there was only android.
  • Loading branch information
dotX12 committed Feb 17, 2024
1 parent ee77a37 commit 16a7807
Show file tree
Hide file tree
Showing 17 changed files with 1,315 additions and 175 deletions.
28 changes: 24 additions & 4 deletions examples/recognize_song.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
import asyncio
import logging

from shazamio import Shazam, Serialize

logger = logging.getLogger(__name__)
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s - %(name)s - [%(filename)s:%(lineno)d - %(funcName)s()] - %(levelname)s - %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)


async def main():
shazam = Shazam()
out = await shazam.recognize_song("data/dora.ogg")
print(out)

serialized = Serialize.full_track(out)
print(serialized)
# pass path (deprecated)
old_version = await shazam.recognize_song(data="data/dora.ogg") # deprecated
serialized_old = Serialize.full_track(old_version)
print(serialized_old)

# pass path
new_version_path = await shazam.recognize("data/dora.ogg")
serialized_new_path = Serialize.full_track(new_version_path)
print(serialized_new_path)

# pass bytes
with open("data/dora.ogg", "rb") as file:
new_version_path = await shazam.recognize(file.read())
serialized_new_path = Serialize.full_track(new_version_path)
print(serialized_new_path)


loop = asyncio.get_event_loop_policy().get_event_loop()
Expand Down
2 changes: 2 additions & 0 deletions examples/song_listening_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ async def main():
track_id = 559284007
count = await shazam.listening_counter(track_id=track_id)
print(count)
count_many = await shazam.listening_counter_many(track_ids=[559284007, 684678069])
print(count_many)


loop = asyncio.get_event_loop_policy().get_event_loop()
Expand Down
676 changes: 566 additions & 110 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pytest = "^7.2.0"
pytest-asyncio = "^0.20.3"
anyio = "^3.6.2"
pydantic = "^1.10.2"
shazamio-core = "^1.0.1"
aiohttp-retry = "^2.8.3"

[build-system]
requires = ["poetry-core>=1.0.0", "wheel>=0.36,<1.0"]
Expand Down
4 changes: 2 additions & 2 deletions shazamio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .serializers import Serialize
from .api import Shazam
from .converter import Geo
from .converter import GeoService
from .enums import GenreMusic

__all__ = ("Serialize", "Shazam", "Geo", "GenreMusic")
__all__ = ("Serialize", "Shazam", "GeoService", "GenreMusic")
Loading

0 comments on commit 16a7807

Please sign in to comment.