diff options
Diffstat (limited to 'python-shazamio.spec')
-rw-r--r-- | python-shazamio.spec | 963 |
1 files changed, 963 insertions, 0 deletions
diff --git a/python-shazamio.spec b/python-shazamio.spec new file mode 100644 index 0000000..c62c2e3 --- /dev/null +++ b/python-shazamio.spec @@ -0,0 +1,963 @@ +%global _empty_manifest_terminate_build 0 +Name: python-shazamio +Version: 0.4.0.1 +Release: 1 +Summary: Is a asynchronous framework from reverse engineered Shazam API written in Python 3.8+ with asyncio and aiohttp. +License: MIT +URL: https://github.com/dotX12/ShazamIO +Source0: https://mirrors.aliyun.com/pypi/web/packages/2d/9a/a0d12348cba3cd4856a5beb0b073f767c7ab31e7d46d957115da5c2c9f73/shazamio-0.4.0.1.tar.gz +BuildArch: noarch + +Requires: python3-numpy +Requires: python3-aiohttp +Requires: python3-pydub +Requires: python3-dataclass-factory +Requires: python3-aiofiles +Requires: python3-pytest +Requires: python3-pytest-asyncio +Requires: python3-anyio +Requires: python3-pydantic + +%description +</p> +## πΏ Installation +``` +π² pip install shazamio +``` +## π» Example +<details> +<summary> +<i>ππ΅ Recognize track</i> +</summary> +Recognize a track based on a file<br> + ```python3 +import asyncio +from shazamio import Shazam +async def main(): + shazam = Shazam() + out = await shazam.recognize_song('dora.ogg') + print(out) +loop = asyncio.get_event_loop() +loop.run_until_complete(main()) + ``` +</details> +<details> +<summary> +<i>π¨βπ€ About artist</i> +</summary> +Retrieving information from an artist profile<br> +<a href="https://www.shazam.com/artist/43328183/nathan-evans">https://www.shazam.com/artist/43328183/nathan-evans</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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 factory +loop = asyncio.get_event_loop() +loop.run_until_complete(main()) + ``` +</details> +<details> +<summary> +<i>π΅π About track</i> +</summary> +Get track information<br> +<a href="https://www.shazam.com/track/552406075/ale-jazz">https://www.shazam.com/track/552406075/ale-jazz</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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 factory +loop = asyncio.get_event_loop() +loop.run_until_complete(main()) + ``` +</details> +<details> +<summary> +<i>π΅β Track listenings count</i> +</summary> +Returns the number of times a particular song has been played<br> +<a href="https://www.shazam.com/track/559284007/rampampam">https://www.shazam.com/track/559284007/rampampam</a> + ```python3 +import asyncio +from shazamio import Shazam +async def main(): + # Example: https://www.shazam.com/track/559284007/rampampam + shazam = 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()) + ``` +</details> +<details> +<summary> +<i>πΆπ¬ Similar songs</i> +</summary> +Similar songs based song id<br> +<a href="https://www.shazam.com/track/546891609/2-phu%CC%81t-ho%CC%9Bn-kaiz-remix">https://www.shazam.com/track/546891609/2-phu%CC%81t-ho%CC%9Bn-kaiz-remix</a> + ```python3 +import asyncio +from shazamio import Shazam +async 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()) + ``` +</details> +<details> +<summary> +<i>ππ¨βπ€ Search artists</i> +</summary> +Search all artists by prefix<br> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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()) + ``` +</details> +<details> +<summary> +<i>ππΆ Search tracks</i> +</summary> +Search all tracks by prefix<br> + ```python3 +import asyncio +from shazamio import Shazam +async 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()) + ``` +</details> +<details> +<summary> +<i>ππΆπ¨βπ€ Top artist tracks</i> +</summary> +Get the top songs according to Shazam<br> +<a href="https://www.shazam.com/artist/201896832/kizaru">https://www.shazam.com/artist/201896832/kizaru</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +from shazamio.schemas.artists import ArtistQuery +from shazamio.schemas.enums import ArtistView +async def main(): + shazam = Shazam() + artist_id = 1081606072 + about_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()) + ``` +</details> +<details> +<summary> +<i>ππΆποΈ Top tracks in city</i> +</summary> +Retrieving information from an artist profile<br> +<a href="https://www.shazam.com/charts/top-50/russia/moscow">https://www.shazam.com/charts/top-50/russia/moscow</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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()) + ``` +</details> +<details> +<summary> +<i>ππΆπ³οΈβπ Top tracks in country</i> +</summary> +Get the best tracks by country code<br> +<a href="https://www.shazam.com/charts/discovery/netherlands">https://www.shazam.com/charts/discovery/netherlands</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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()) + ``` +</details> +<details> +<summary> +<i>ππΆπ³οΈβππΈ Top tracks in country by genre</i> +</summary> +The best tracks by a genre in the country<br> +<a href="https://www.shazam.com/charts/genre/spain/hip-hop-rap">https://www.shazam.com/charts/genre/spain/hip-hop-rap</a> + ```python3 +import asyncio +from shazamio import Shazam, GenreMusic +async 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()) + ``` +</details> +<details> +<summary> +<i>ππΆππΈ Top tracks in word by genre</i> +</summary> +Get world tracks by certain genre<br> +<a href="https://www.shazam.com/charts/genre/world/rock">https://www.shazam.com/charts/genre/world/rock</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize, GenreMusic +async 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()) + ``` +</details> +<details> +<summary> +<i>ππΆπTop tracks in word</i> +</summary> +Get the best tracks from all over the world<br> +<a href="https://www.shazam.com/charts/top-200/world">https://www.shazam.com/charts/top-200/world</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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()) + ``` +</details> +## How to use data serialization +<details> +<summary> +<i>Open Code</i> +</summary> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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()) + ``` +</details> +<details> +<summary> +<i>Open photo: What song information looks like (Dict)</i> +</summary> +<img src="https://user-images.githubusercontent.com/64792903/109454521-75b4c980-7a65-11eb-917e-62da3abefb8a.png"> +</details> +<details> +<summary> +<i>Open photo: what song information looks like (Custom serializer)</i> +</summary> +<img src="https://user-images.githubusercontent.com/64792903/109454465-57e76480-7a65-11eb-956c-1bcac41d7de5.png"> +</details> +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. + +%package -n python3-shazamio +Summary: Is a asynchronous framework from reverse engineered Shazam API written in Python 3.8+ with asyncio and aiohttp. +Provides: python-shazamio +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-shazamio +</p> +## πΏ Installation +``` +π² pip install shazamio +``` +## π» Example +<details> +<summary> +<i>ππ΅ Recognize track</i> +</summary> +Recognize a track based on a file<br> + ```python3 +import asyncio +from shazamio import Shazam +async def main(): + shazam = Shazam() + out = await shazam.recognize_song('dora.ogg') + print(out) +loop = asyncio.get_event_loop() +loop.run_until_complete(main()) + ``` +</details> +<details> +<summary> +<i>π¨βπ€ About artist</i> +</summary> +Retrieving information from an artist profile<br> +<a href="https://www.shazam.com/artist/43328183/nathan-evans">https://www.shazam.com/artist/43328183/nathan-evans</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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 factory +loop = asyncio.get_event_loop() +loop.run_until_complete(main()) + ``` +</details> +<details> +<summary> +<i>π΅π About track</i> +</summary> +Get track information<br> +<a href="https://www.shazam.com/track/552406075/ale-jazz">https://www.shazam.com/track/552406075/ale-jazz</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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 factory +loop = asyncio.get_event_loop() +loop.run_until_complete(main()) + ``` +</details> +<details> +<summary> +<i>π΅β Track listenings count</i> +</summary> +Returns the number of times a particular song has been played<br> +<a href="https://www.shazam.com/track/559284007/rampampam">https://www.shazam.com/track/559284007/rampampam</a> + ```python3 +import asyncio +from shazamio import Shazam +async def main(): + # Example: https://www.shazam.com/track/559284007/rampampam + shazam = 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()) + ``` +</details> +<details> +<summary> +<i>πΆπ¬ Similar songs</i> +</summary> +Similar songs based song id<br> +<a href="https://www.shazam.com/track/546891609/2-phu%CC%81t-ho%CC%9Bn-kaiz-remix">https://www.shazam.com/track/546891609/2-phu%CC%81t-ho%CC%9Bn-kaiz-remix</a> + ```python3 +import asyncio +from shazamio import Shazam +async 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()) + ``` +</details> +<details> +<summary> +<i>ππ¨βπ€ Search artists</i> +</summary> +Search all artists by prefix<br> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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()) + ``` +</details> +<details> +<summary> +<i>ππΆ Search tracks</i> +</summary> +Search all tracks by prefix<br> + ```python3 +import asyncio +from shazamio import Shazam +async 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()) + ``` +</details> +<details> +<summary> +<i>ππΆπ¨βπ€ Top artist tracks</i> +</summary> +Get the top songs according to Shazam<br> +<a href="https://www.shazam.com/artist/201896832/kizaru">https://www.shazam.com/artist/201896832/kizaru</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +from shazamio.schemas.artists import ArtistQuery +from shazamio.schemas.enums import ArtistView +async def main(): + shazam = Shazam() + artist_id = 1081606072 + about_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()) + ``` +</details> +<details> +<summary> +<i>ππΆποΈ Top tracks in city</i> +</summary> +Retrieving information from an artist profile<br> +<a href="https://www.shazam.com/charts/top-50/russia/moscow">https://www.shazam.com/charts/top-50/russia/moscow</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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()) + ``` +</details> +<details> +<summary> +<i>ππΆπ³οΈβπ Top tracks in country</i> +</summary> +Get the best tracks by country code<br> +<a href="https://www.shazam.com/charts/discovery/netherlands">https://www.shazam.com/charts/discovery/netherlands</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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()) + ``` +</details> +<details> +<summary> +<i>ππΆπ³οΈβππΈ Top tracks in country by genre</i> +</summary> +The best tracks by a genre in the country<br> +<a href="https://www.shazam.com/charts/genre/spain/hip-hop-rap">https://www.shazam.com/charts/genre/spain/hip-hop-rap</a> + ```python3 +import asyncio +from shazamio import Shazam, GenreMusic +async 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()) + ``` +</details> +<details> +<summary> +<i>ππΆππΈ Top tracks in word by genre</i> +</summary> +Get world tracks by certain genre<br> +<a href="https://www.shazam.com/charts/genre/world/rock">https://www.shazam.com/charts/genre/world/rock</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize, GenreMusic +async 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()) + ``` +</details> +<details> +<summary> +<i>ππΆπTop tracks in word</i> +</summary> +Get the best tracks from all over the world<br> +<a href="https://www.shazam.com/charts/top-200/world">https://www.shazam.com/charts/top-200/world</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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()) + ``` +</details> +## How to use data serialization +<details> +<summary> +<i>Open Code</i> +</summary> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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()) + ``` +</details> +<details> +<summary> +<i>Open photo: What song information looks like (Dict)</i> +</summary> +<img src="https://user-images.githubusercontent.com/64792903/109454521-75b4c980-7a65-11eb-917e-62da3abefb8a.png"> +</details> +<details> +<summary> +<i>Open photo: what song information looks like (Custom serializer)</i> +</summary> +<img src="https://user-images.githubusercontent.com/64792903/109454465-57e76480-7a65-11eb-956c-1bcac41d7de5.png"> +</details> +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. + +%package help +Summary: Development documents and examples for shazamio +Provides: python3-shazamio-doc +%description help +</p> +## πΏ Installation +``` +π² pip install shazamio +``` +## π» Example +<details> +<summary> +<i>ππ΅ Recognize track</i> +</summary> +Recognize a track based on a file<br> + ```python3 +import asyncio +from shazamio import Shazam +async def main(): + shazam = Shazam() + out = await shazam.recognize_song('dora.ogg') + print(out) +loop = asyncio.get_event_loop() +loop.run_until_complete(main()) + ``` +</details> +<details> +<summary> +<i>π¨βπ€ About artist</i> +</summary> +Retrieving information from an artist profile<br> +<a href="https://www.shazam.com/artist/43328183/nathan-evans">https://www.shazam.com/artist/43328183/nathan-evans</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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 factory +loop = asyncio.get_event_loop() +loop.run_until_complete(main()) + ``` +</details> +<details> +<summary> +<i>π΅π About track</i> +</summary> +Get track information<br> +<a href="https://www.shazam.com/track/552406075/ale-jazz">https://www.shazam.com/track/552406075/ale-jazz</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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 factory +loop = asyncio.get_event_loop() +loop.run_until_complete(main()) + ``` +</details> +<details> +<summary> +<i>π΅β Track listenings count</i> +</summary> +Returns the number of times a particular song has been played<br> +<a href="https://www.shazam.com/track/559284007/rampampam">https://www.shazam.com/track/559284007/rampampam</a> + ```python3 +import asyncio +from shazamio import Shazam +async def main(): + # Example: https://www.shazam.com/track/559284007/rampampam + shazam = 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()) + ``` +</details> +<details> +<summary> +<i>πΆπ¬ Similar songs</i> +</summary> +Similar songs based song id<br> +<a href="https://www.shazam.com/track/546891609/2-phu%CC%81t-ho%CC%9Bn-kaiz-remix">https://www.shazam.com/track/546891609/2-phu%CC%81t-ho%CC%9Bn-kaiz-remix</a> + ```python3 +import asyncio +from shazamio import Shazam +async 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()) + ``` +</details> +<details> +<summary> +<i>ππ¨βπ€ Search artists</i> +</summary> +Search all artists by prefix<br> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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()) + ``` +</details> +<details> +<summary> +<i>ππΆ Search tracks</i> +</summary> +Search all tracks by prefix<br> + ```python3 +import asyncio +from shazamio import Shazam +async 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()) + ``` +</details> +<details> +<summary> +<i>ππΆπ¨βπ€ Top artist tracks</i> +</summary> +Get the top songs according to Shazam<br> +<a href="https://www.shazam.com/artist/201896832/kizaru">https://www.shazam.com/artist/201896832/kizaru</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +from shazamio.schemas.artists import ArtistQuery +from shazamio.schemas.enums import ArtistView +async def main(): + shazam = Shazam() + artist_id = 1081606072 + about_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()) + ``` +</details> +<details> +<summary> +<i>ππΆποΈ Top tracks in city</i> +</summary> +Retrieving information from an artist profile<br> +<a href="https://www.shazam.com/charts/top-50/russia/moscow">https://www.shazam.com/charts/top-50/russia/moscow</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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()) + ``` +</details> +<details> +<summary> +<i>ππΆπ³οΈβπ Top tracks in country</i> +</summary> +Get the best tracks by country code<br> +<a href="https://www.shazam.com/charts/discovery/netherlands">https://www.shazam.com/charts/discovery/netherlands</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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()) + ``` +</details> +<details> +<summary> +<i>ππΆπ³οΈβππΈ Top tracks in country by genre</i> +</summary> +The best tracks by a genre in the country<br> +<a href="https://www.shazam.com/charts/genre/spain/hip-hop-rap">https://www.shazam.com/charts/genre/spain/hip-hop-rap</a> + ```python3 +import asyncio +from shazamio import Shazam, GenreMusic +async 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()) + ``` +</details> +<details> +<summary> +<i>ππΆππΈ Top tracks in word by genre</i> +</summary> +Get world tracks by certain genre<br> +<a href="https://www.shazam.com/charts/genre/world/rock">https://www.shazam.com/charts/genre/world/rock</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize, GenreMusic +async 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()) + ``` +</details> +<details> +<summary> +<i>ππΆπTop tracks in word</i> +</summary> +Get the best tracks from all over the world<br> +<a href="https://www.shazam.com/charts/top-200/world">https://www.shazam.com/charts/top-200/world</a> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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()) + ``` +</details> +## How to use data serialization +<details> +<summary> +<i>Open Code</i> +</summary> + ```python3 +import asyncio +from shazamio import Shazam, Serialize +async 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()) + ``` +</details> +<details> +<summary> +<i>Open photo: What song information looks like (Dict)</i> +</summary> +<img src="https://user-images.githubusercontent.com/64792903/109454521-75b4c980-7a65-11eb-917e-62da3abefb8a.png"> +</details> +<details> +<summary> +<i>Open photo: what song information looks like (Custom serializer)</i> +</summary> +<img src="https://user-images.githubusercontent.com/64792903/109454465-57e76480-7a65-11eb-956c-1bcac41d7de5.png"> +</details> +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. + +%prep +%autosetup -n shazamio-0.4.0.1 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-shazamio -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Tue Jun 20 2023 Python_Bot <Python_Bot@openeuler.org> - 0.4.0.1-1 +- Package Spec generated |