Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shazamio/ShazamIO
π΅ Is a free asynchronous library from reverse engineered Shazam API written in Python 3.8+ with asyncio and aiohttp.
https://github.com/shazamio/ShazamIO
aiohttp api async asyncio identification music python python3 shazam
Last synced: 4 days ago
JSON representation
π΅ Is a free asynchronous library from reverse engineered Shazam API written in Python 3.8+ with asyncio and aiohttp.
- Host: GitHub
- URL: https://github.com/shazamio/ShazamIO
- Owner: shazamio
- License: mit
- Created: 2021-02-03T19:54:45.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-10-29T04:22:37.000Z (15 days ago)
- Last Synced: 2024-10-29T04:41:17.313Z (15 days ago)
- Topics: aiohttp, api, async, asyncio, identification, music, python, python3, shazam
- Language: Python
- Homepage:
- Size: 2.92 MB
- Stars: 507
- Watchers: 4
- Forks: 73
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
π΅ 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 track
Recognize a track based on a file
```python3
import asyncio
from shazamio import Shazamasync def main():
shazam = Shazam()
# out = await shazam.recognize_song('dora.ogg') # slow and deprecated, don't use this!
out = await shazam.recognize('dora.ogg') # rust version, use this!
print(out)loop = asyncio.get_event_loop()
loop.run_until_complete(main())
```
π¨βπ€ About artist
Retrieving information from an artist profile
https://www.shazam.com/artist/43328183/nathan-evans```python3
import asyncio
from shazamio import Shazam, Serializeasync def main():
shazam = Shazam()
artist_id = 43328183
about_artist = await shazam.artist_about(artist_id)
serialized = Serialize.artist(about_artist)print(about_artist) # dict
print(serialized) # serialized from dataclass factoryloop = asyncio.get_event_loop()
loop.run_until_complete(main())
```
π΅π About track
Get track information
https://www.shazam.com/track/552406075/ale-jazz```python3
import asyncio
from shazamio import Shazam, Serializeasync def main():
shazam = Shazam()
track_id = 552406075
about_track = await shazam.track_about(track_id=track_id)
serialized = Serialize.track(data=about_track)print(about_track) # dict
print(serialized) # serialized from dataclass factoryloop = asyncio.get_event_loop()
loop.run_until_complete(main())
```
π΅β Track listenings count
Returns the number of times a particular song has been played
https://www.shazam.com/track/559284007/rampampam```python3
import asyncio
from shazamio import Shazamasync def main():
# Example: https://www.shazam.com/track/559284007/rampampamshazam = Shazam()
track_id = 559284007
count = await shazam.listening_counter(track_id=track_id)
print(count)loop = asyncio.get_event_loop()
loop.run_until_complete(main())
```
πΆπ¬ Similar songs
Similar songs based song id
https://www.shazam.com/track/546891609/2-phu%CC%81t-ho%CC%9Bn-kaiz-remix```python3
import asyncio
from shazamio import Shazamasync def main():
shazam = Shazam()
track_id = 546891609
related = await shazam.related_tracks(track_id=track_id, limit=5, offset=2)
# ONLY β3, β4 SONG
print(related)loop = asyncio.get_event_loop()
loop.run_until_complete(main())
```
ππ¨βπ€ Search artists
Search all artists by prefix
```python3
import asyncio
from shazamio import Shazam, Serializeasync def main():
shazam = Shazam()
artists = await shazam.search_artist(query='Lil', limit=5)
for artist in artists['artists']['hits']:
serialized = Serialize.artist(data=artist)
print(serialized)loop = asyncio.get_event_loop()
loop.run_until_complete(main())```
ππΆ Search tracks
Search all tracks by prefix
```python3
import asyncio
from shazamio import Shazamasync def main():
shazam = Shazam()
tracks = await shazam.search_track(query='Lil', limit=5)
print(tracks)loop = asyncio.get_event_loop()
loop.run_until_complete(main())```
ππΆπ¨βπ€ Top artist tracks
Get the top songs according to Shazam
https://www.shazam.com/artist/201896832/kizaru```python3
import asyncio
from shazamio import Shazam, Serialize
from shazamio.schemas.artists import ArtistQuery
from shazamio.schemas.enums import ArtistViewasync def main():
shazam = Shazam()
artist_id = 1081606072about_artist = await shazam.artist_about(
artist_id,
query=ArtistQuery(
views=[
ArtistView.TOP_SONGS,
],
),
)
serialized = Serialize.artist_v2(about_artist)
for i in serialized.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 city
Retrieving information from an artist profile
https://www.shazam.com/charts/top-50/russia/moscow```python3
import asyncio
from shazamio import Shazam, Serializeasync def main():
shazam = Shazam()
top_ten_moscow_tracks = await shazam.top_city_tracks(country_code='RU', city_name='Moscow', limit=10)
print(top_ten_moscow_tracks)
# ALL TRACKS DICT
for track in top_ten_moscow_tracks['tracks']:
serialized = Serialize.track(data=track)
# SERIALIZE FROM DATACLASS FACTORY
print(serialized)loop = asyncio.get_event_loop()
loop.run_until_complete(main())```
ππΆπ³οΈβπ Top tracks in country
Get the best tracks by country code
https://www.shazam.com/charts/discovery/netherlands```python3
import asyncio
from shazamio import Shazam, Serializeasync def main():
shazam = Shazam()
top_five_track_from_amsterdam = await shazam.top_country_tracks('NL', 5)
for track in top_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 genre
The best tracks by a genre in the country
https://www.shazam.com/charts/genre/spain/hip-hop-rap```python3
import asyncio
from shazamio import Shazam, GenreMusicasync def main():
shazam = Shazam()
top_spain_rap = await shazam.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 genre
Get world tracks by certain genre
https://www.shazam.com/charts/genre/world/rock```python3
import asyncio
from shazamio import Shazam, Serialize, GenreMusicasync def main():
shazam = Shazam()
top_rock_in_the_world = await shazam.top_world_genre_tracks(genre=GenreMusic.ROCK, limit=10)for track in top_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 world
Get the best tracks from all over the world
https://www.shazam.com/charts/top-200/world```python3
import asyncio
from shazamio import Shazam, Serializeasync def main():
shazam = Shazam()
top_world_tracks = await shazam.top_world_tracks(limit=10)
print(top_world_tracks)
for track in top_world_tracks['tracks']:
serialized = Serialize.track(track)
print(serialized)loop = asyncio.get_event_loop()
loop.run_until_complete(main())
```## How to use data serialization
Open Code
```python3
import asyncio
from shazamio import Shazam, Serializeasync def main():
shazam = Shazam()
top_five_track_from_amsterdam = await shazam.top_country_tracks('NL', 5)
for track in top_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.