Package: shazamio
🎵 Is a FREE asynchronous library from reverse engineered Shazam API written in Python 3.8+ with asyncio and aiohttp. Includes all the methods that Shazam has, including searching for a song by file.💿 Installation💲 pip install shazamio💻 Example🔎🎵 Recognize trackRecognize a track based on a fileimportasynciofromshazamioimportShazamasyncdefmain():shazam=Shazam()# out = await shazam.recognize_song('dora.ogg') # slow and deprecated, don't use this!out=awaitshazam.recognize('dora.ogg')# rust version, use this!print(out)loop=asyncio.get_event_loop()loop.run_until_complete(main())👨‍🎤 About artistRetrieving information from an artist profilehttps://www.shazam.com/artist/43328183/nathan-evansimportasynciofromshazamioimportShazam,Serializeasyncdefmain():shazam=Shazam()artist_id=43328183about_artist=awaitshazam.artist_about(artist_id)serialized=Serialize.artist(about_artist)print(about_artist)# dictprint(serialized)# serialized from dataclass factoryloop=asyncio.get_event_loop()loop.run_until_complete(main())🎵📄 About trackGet track informationhttps://www.shazam.com/track/552406075/ale-jazzimportasynciofromshazamioimportShazam,Serializeasyncdefmain():shazam=Shazam()track_id=552406075about_track=awaitshazam.track_about(track_id=track_id)serialized=Serialize.track(data=about_track)print(about_track)# dictprint(serialized)# serialized from dataclass factoryloop=asyncio.get_event_loop()loop.run_until_complete(main())🎵⌛ Track listenings countReturns the number of times a particular song has been playedhttps://www.shazam.com/track/559284007/rampampamimportasynciofromshazamioimportShazamasyncdefmain():# Example: https://www.shazam.com/track/559284007/rampampamshazam=Shazam()track_id=559284007count=awaitshazam.listening_counter(track_id=track_id)print(count)loop=asyncio.get_event_loop()loop.run_until_complete(main())🎶💬 Similar songsSimilar songs based song idhttps://www.shazam.com/track/546891609/2-phu%CC%81t-ho%CC%9Bn-kaiz-remiximportasynciofromshazamioimportShazamasyncdefmain():shazam=Shazam()track_id=546891609related=awaitshazam.related_tracks(track_id=track_id,limit=5,offset=2)# ONLY №3, №4 SONGprint(related)loop=asyncio.get_event_loop()loop.run_until_complete(main())🔎👨‍🎤 Search artistsSearch all artists by prefiximportasynciofromshazamioimportShazam,Serializeasyncdefmain():shazam=Shazam()artists=awaitshazam.search_artist(query='Lil',limit=5)forartistinartists['artists']['hits']:serialized=Serialize.artist(data=artist)print(serialized)loop=asyncio.get_event_loop()loop.run_until_complete(main())🔎🎶 Search tracksSearch all tracks by prefiximportasynciofromshazamioimportShazamasyncdefmain():shazam=Shazam()tracks=awaitshazam.search_track(query='Lil',limit=5)print(tracks)loop=asyncio.get_event_loop()loop.run_until_complete(main())🔝🎶👨‍🎤 Top artist tracksGet the top songs according to Shazamhttps://www.shazam.com/artist/201896832/kizaruimportasynciofromshazamioimportShazam,Serializefromshazamio.schemas.artistsimportArtistQueryfromshazamio.schemas.enumsimportArtistViewasyncdefmain():shazam=Shazam()artist_id=1081606072about_artist=awaitshazam.artist_about(artist_id,query=ArtistQuery(views=[ArtistView.TOP_SONGS,],),)serialized=Serialize.artist_v2(about_artist)foriinserialized.data[0].views.top_songs.data:print(i.attributes.name)loop=asyncio.get_event_loop_policy().get_event_loop()loop.run_until_complete(main())🔝🎶🏙️ Top tracks in cityRetrieving information from an artist profilehttps://www.shazam.com/charts/top-50/russia/moscowimportasynciofromshazamioimportShazam,Serializeasyncdefmain():shazam=Shazam()top_ten_moscow_tracks=awaitshazam.top_city_tracks(country_code='RU',city_name='Moscow',limit=10)print(top_ten_moscow_tracks)# ALL TRACKS DICTfortrackintop_ten_moscow_tracks['tracks']:serialized=Serialize.track(data=track)# SERIALIZE FROM DATACLASS FACTORYprint(serialized)loop=asyncio.get_event_loop()loop.run_until_complete(main())🔝🎶🏳️‍🌈 Top tracks in countryGet the best tracks by country codehttps://www.shazam.com/charts/discovery/netherlandsimportasynciofromshazamioimportShazam,Serializeasyncdefmain():shazam=Shazam()top_five_track_from_amsterdam=awaitshazam.top_country_tracks('NL',5)fortrackintop_five_track_from_amsterdam['tracks']:serialized=Serialize.track(data=track)print(serialized)loop=asyncio.get_event_loop()loop.run_until_complete(main())🔝🎶🏳️‍🌈🎸 Top tracks in country by genreThe best tracks by a genre in the countryhttps://www.shazam.com/charts/genre/spain/hip-hop-rapimportasynciofromshazamioimportShazam,GenreMusicasyncdefmain():shazam=Shazam()top_spain_rap=awaitshazam.top_country_genre_tracks(country_code='ES',genre=GenreMusic.HIP_HOP_RAP,limit=4)print(top_spain_rap)loop=asyncio.get_event_loop()loop.run_until_complete(main())🔝🎶🌏🎸 Top tracks in world by genreGet world tracks by certain genrehttps://www.shazam.com/charts/genre/world/rockimportasynciofromshazamioimportShazam,Serialize,GenreMusicasyncdefmain():shazam=Shazam()top_rock_in_the_world=awaitshazam.top_world_genre_tracks(genre=GenreMusic.ROCK,limit=10)fortrackintop_rock_in_the_world['tracks']:serialized_track=Serialize.track(data=track)print(serialized_track.spotify_url)loop=asyncio.get_event_loop()loop.run_until_complete(main())🔝🎶🌏Top tracks in worldGet the best tracks from all over the worldhttps://www.shazam.com/charts/top-200/worldimportasynciofromshazamioimportShazam,Serializeasyncdefmain():shazam=Shazam()top_world_tracks=awaitshazam.top_world_tracks(limit=10)print(top_world_tracks)fortrackintop_world_tracks['tracks']:serialized=Serialize.track(track)print(serialized)loop=asyncio.get_event_loop()loop.run_until_complete(main())How to use data serializationOpen CodeimportasynciofromshazamioimportShazam,Serializeasyncdefmain():shazam=Shazam()top_five_track_from_amsterdam=awaitshazam.top_country_tracks('NL',5)fortrackintop_five_track_from_amsterdam['tracks']:serialized=Serialize.track(data=track)print(serialized.title)loop=asyncio.get_event_loop()loop.run_until_complete(main())Open photo: What song information looks like (Dict)Open photo: what song information looks like (Custom serializer)Agree, thanks to the serializer, you no longer need to manually select the necessary data from the dictionary. Now the serializer contains the most necessary information about an artist or a track.