-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from shazamio/dev-fix-top-tracks
Fix top tracks, small refactoring.
- Loading branch information
Showing
32 changed files
with
518 additions
and
353 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import asyncio | ||
import logging | ||
|
||
from aiohttp_retry import ExponentialRetry | ||
|
||
from shazamio import Shazam, Serialize, HTTPClient | ||
|
||
logger = logging.getLogger(__name__) | ||
logging.basicConfig( | ||
level=logging.DEBUG, | ||
format="%(asctime)s - %(name)s - [%(filename)s:%(lineno)d - %(funcName)s()] - %(levelname)s - %(message)s", | ||
datefmt="%Y-%m-%d %H:%M:%S", | ||
) | ||
|
||
|
||
async def main(): | ||
shazam = Shazam( | ||
http_client=HTTPClient( | ||
retry_options=ExponentialRetry( | ||
attempts=12, max_timeout=204.8, statuses={500, 502, 503, 504, 429} | ||
), | ||
), | ||
) | ||
|
||
new_version_path = await shazam.recognize("data/Gloria.ogg") | ||
|
||
album_info = await shazam.search_album(album_id=new_version_path["track"]["albumadamid"]) | ||
album_serialized = Serialize.album_info(data=album_info) | ||
# Get album name | ||
print(album_serialized.data[0].attributes.name) | ||
|
||
# And get all tracks in album | ||
for i in album_serialized.data[0].relationships.tracks.data: | ||
msg = ( | ||
f"{i.id} | {i.attributes.album_name} | {i.attributes.artist_name} [{i.attributes.name}]" | ||
) | ||
print(msg) | ||
|
||
|
||
loop = asyncio.get_event_loop_policy().get_event_loop() | ||
loop.run_until_complete(main()) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.