fix: adapt to Shazam API endpoint changes#148
Open
alejandromav wants to merge 1 commit intoshazamio:masterfrom
Open
fix: adapt to Shazam API endpoint changes#148alejandromav wants to merge 1 commit intoshazamio:masterfrom
alejandromav wants to merge 1 commit intoshazamio:masterfrom
Conversation
…hazamio#147) - Search: use amapi/v1/catalog/search for search_track and search_artist - Charts: use CSV chart endpoints for top_world/country/city/genre_tracks - artist_about: resolve artist name from Shazam page when using artist_id, then search via catalog search; support artist_name for direct lookup - Add request_csv and validate_csv for chart CSV responses - Mark listening_counter, listening_counter_many, artist_albums, search_album as deprecated (endpoints no longer available) - Make ArtistV3.views optional for new response shape - Add tests for search, charts, track_about, related_tracks, artist_by_name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Several Shazam API endpoints have been deprecated or shut down, causing
FailedDecodeJson/ HTTP 404 / 405 errors across multiple library methods. This PR migrates to the replacement endpoints that are still functional.Fixes #145, fixes #146, fixes #147
What changed
Search (
search_track,search_artist)services/search/v3/...endpoints now return 404.amapi/v1/catalog/{country}/search?term={query}&types={songs|artists}.Charts (
top_world_tracks,top_country_tracks,top_city_tracks,top_world_genre_tracks,top_country_genre_tracks)https://www.shazam.com/services/charts/csv/...), which return ranked track lists.validate_csvutility to parse CSV responses andrequest_csvto the HTTP client.GeoService(converter) with helper methods to resolve URL-friendly location/genre names for the new chart URLs.Artist lookup (
artist_about)amapi/v1/catalog/{country}/artists/{id}endpoint was shut down.shazam.com/artist/_/{id}), then searches via the catalog search API.artist_nameparameter to skip the resolution step when the name is already known.ArtistV3.viewsoptional to accommodate the new response shape from the search API.Deprecated methods
listening_counter,listening_counter_many,artist_albums, andsearch_albumare marked@deprecated— their underlying endpoints are no longer available and have no known replacements.Files changed
shazamio/api.py_resolve_artist_name; deprecated dead methodsshazamio/misc.pySEARCH_AMAPIandCHART_CSVURL constants; removed broken URLsshazamio/utils.pyvalidate_csvfor parsing chart CSV responsesshazamio/client.pyrequest_csvmethodshazamio/interfaces/client.pyrequest_csvto the HTTP client interfaceshazamio/converter.pyshazamio/schemas/artists.pyArtistV3.viewsoptionaltests/test_about_artist.pytest_about_artist_by_nametests/test_search.pytest_search_track,test_search_artisttests/test_charts.pytests/test_track_about.pytest_track_abouttests/test_related_tracks.pytest_related_tracksTest plan
test_about_artist.pyblack --check .passes (pre-existingfactory_misc.pyissue excluded)pytest -vNotes
{"tracks": [...]}) is preserved for backward compatibility, but individual track dicts are simpler.artist_aboutmethod now makes an extra HTTP call to resolve the artist name from the Shazam web page when called withartist_id. Passartist_namedirectly to avoid this overhead.@deprecatedstill exist but raise aDeprecationWarningand return an error dict explaining the endpoint is no longer available.