Skip to content

Commit

Permalink
Merge pull request #44 from dotX12/dev
Browse files Browse the repository at this point in the history
[MASTER] - Fix about artist
  • Loading branch information
dotX12 authored Dec 19, 2022
2 parents c98044f + 6ed6f88 commit 37b50cc
Show file tree
Hide file tree
Showing 44 changed files with 989 additions and 222 deletions.
37 changes: 31 additions & 6 deletions examples/about_artist.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,41 @@
import asyncio
from pprint import pprint

from shazamio import Shazam, Serialize
from shazamio.schemas.artists import ArtistQuery
from shazamio.schemas.enums import ArtistExtend
from shazamio.schemas.enums import ArtistView


async def main():
shazam = Shazam()
artist_id = 43328183
about_artist = await shazam.artist_about(artist_id)
serialized = Serialize.artist(about_artist)
shazam = Shazam(language="ES")
artist_id = 1124753799
# extend: artistBio,bornOrFormed,editorialArtwork,origin
# views: full-albums,featured-albums,latest-release,top-music-videos,similar-artists,
# top-songs,playlists

about_artist = await shazam.artist_about(
artist_id,
query=ArtistQuery(
views=[
ArtistView.FULL_ALBUMS,
ArtistView.FEATURED_ALBUMS,
ArtistView.LATEST_RELEASE,
ArtistView.TOP_MUSIC_VIDEOS,
ArtistView.SIMULAR_ARTISTS,
],
extend=[
ArtistExtend.ARTIST_BIO,
ArtistExtend.BORN_OF_FORMED,
ArtistExtend.EDITORIAL_ARTWORK,
ArtistExtend.ORIGIN,
],
),
)
print(about_artist) # dict
print(serialized) # serialized from dataclass factory
serialized = Serialize.artist_v2(about_artist)
pprint(serialized) # serialized from pydantic


loop = asyncio.get_event_loop()
loop = asyncio.get_event_loop_policy().get_event_loop()
loop.run_until_complete(main())
2 changes: 1 addition & 1 deletion examples/about_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ async def main():
print(serialized) # serialized from dataclass factory


loop = asyncio.get_event_loop()
loop = asyncio.get_event_loop_policy().get_event_loop()
loop.run_until_complete(main())
2 changes: 1 addition & 1 deletion examples/recognize_song.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ async def main():
print(serialized)


loop = asyncio.get_event_loop()
loop = asyncio.get_event_loop_policy().get_event_loop()
loop.run_until_complete(main())
2 changes: 1 addition & 1 deletion examples/recognize_track_youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ async def main():
print(serialized_youtube.uri)


loop = asyncio.get_event_loop()
loop = asyncio.get_event_loop_policy().get_event_loop()
loop.run_until_complete(main())
2 changes: 1 addition & 1 deletion examples/related_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ async def main():
print(related)


loop = asyncio.get_event_loop()
loop = asyncio.get_event_loop_policy().get_event_loop()
loop.run_until_complete(main())
3 changes: 2 additions & 1 deletion examples/search_artists.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ async def main():
for artist in artists["artists"]["hits"]:
serialized = Serialize.artist(data=artist)
print(serialized)
print(artist)


loop = asyncio.get_event_loop()
loop = asyncio.get_event_loop_policy().get_event_loop()
loop.run_until_complete(main())
2 changes: 1 addition & 1 deletion examples/search_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ async def main():
print(tracks)


loop = asyncio.get_event_loop()
loop = asyncio.get_event_loop_policy().get_event_loop()
loop.run_until_complete(main())
2 changes: 1 addition & 1 deletion examples/song_listening_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ async def main():
print(count)


loop = asyncio.get_event_loop()
loop = asyncio.get_event_loop_policy().get_event_loop()
loop.run_until_complete(main())
6 changes: 2 additions & 4 deletions examples/top_artist_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
async def main():
shazam = Shazam()
artist_id = 201896832
top_three_artist_tracks = await shazam.artist_top_tracks(
artist_id=artist_id, limit=3
)
top_three_artist_tracks = await shazam.artist_top_tracks(artist_id=artist_id, limit=3)
for track in top_three_artist_tracks["tracks"]:
serialized_track = Serialize.track(data=track)
print(serialized_track)


loop = asyncio.get_event_loop()
loop = asyncio.get_event_loop_policy().get_event_loop()
loop.run_until_complete(main())
2 changes: 1 addition & 1 deletion examples/top_tracks_city.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ async def main():
print(serialized)


loop = asyncio.get_event_loop()
loop = asyncio.get_event_loop_policy().get_event_loop()
loop.run_until_complete(main())
2 changes: 1 addition & 1 deletion examples/top_tracks_country.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ async def main():
print(serialized)


loop = asyncio.get_event_loop()
loop = asyncio.get_event_loop_policy().get_event_loop()
loop.run_until_complete(main())
2 changes: 1 addition & 1 deletion examples/top_tracks_genre_country.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ async def main():
print(top_spain_rap)


loop = asyncio.get_event_loop()
loop = asyncio.get_event_loop_policy().get_event_loop()
loop.run_until_complete(main())
6 changes: 2 additions & 4 deletions examples/top_tracks_genre_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@

async def main():
shazam = Shazam()
top_rock_in_the_world = await shazam.top_world_genre_tracks(
genre=GenreMusic.ROCK, limit=10
)
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)


loop = asyncio.get_event_loop()
loop = asyncio.get_event_loop_policy().get_event_loop()
loop.run_until_complete(main())
2 changes: 1 addition & 1 deletion examples/top_world_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ async def main():
print(serialized)


loop = asyncio.get_event_loop()
loop = asyncio.get_event_loop_policy().get_event_loop()
loop.run_until_complete(main())
Loading

0 comments on commit 37b50cc

Please sign in to comment.