Giter Club home page Giter Club logo

shazamio's Introduction

https://scrutinizer-ci.com/g/dotX12/ShazamIO/ https://scrutinizer-ci.com/g/dotX12/ShazamIO/ https://scrutinizer-ci.com/g/dotX12/ShazamIO/ https://badge.fury.io/py/shazamio https://pepy.tech/project/shazamio https://pepy.tech/project/shazamio https://github.com/dotX12/ShazamIO/blob/master/LICENSE.txt

🎡 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

import asyncio
from shazamio import Shazam


async 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

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())
πŸŽ΅πŸ“„ About track

Get track information
https://www.shazam.com/track/552406075/ale-jazz

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())
πŸŽ΅βŒ› Track listenings count

Returns the number of times a particular song has been played
https://www.shazam.com/track/559284007/rampampam

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())
πŸŽΆπŸ’¬ Similar songs

Similar songs based song id
https://www.shazam.com/track/546891609/2-phu%CC%81t-ho%CC%9Bn-kaiz-remix

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())
πŸ”ŽπŸ‘¨β€πŸŽ€ Search artists

Search all artists by prefix

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())
πŸ”ŽπŸŽΆ Search tracks

Search all tracks by prefix

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())
πŸ”πŸŽΆπŸ‘¨β€πŸŽ€ Top artist tracks

Get the top songs according to Shazam
https://www.shazam.com/artist/201896832/kizaru

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())
πŸ”πŸŽΆπŸ™οΈ Top tracks in city

Retrieving information from an artist profile
https://www.shazam.com/charts/top-50/russia/moscow

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())
πŸ”πŸŽΆπŸ³οΈβ€πŸŒˆ Top tracks in country

Get the best tracks by country code
https://www.shazam.com/charts/discovery/netherlands

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())
πŸ”πŸŽΆπŸ³οΈβ€πŸŒˆπŸŽΈ 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

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())
πŸ”πŸŽΆπŸŒπŸŽΈ Top tracks in world by genre

Get world tracks by certain genre
https://www.shazam.com/charts/genre/world/rock

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())
πŸ”πŸŽΆπŸŒTop tracks in world

Get the best tracks from all over the world
https://www.shazam.com/charts/top-200/world

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())

How to use data serialization

Open Code
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())
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.

shazamio's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

shazamio's Issues

recognize_song function is blocking

I've been using the recognize_song function for a while now, but only just found out, that it is blocking. Am I doing something wrong or is it not my fault?

[Question] Get links to YouTube, Spotify, Deezer etc.

First of all, thank you for this great library! It is really ingenious and works perfectly.

However, I have a question: How is it possible to get the links to YouTube, Spotify etc.? The JSON answer contains the link to AppleMusic, but not to YouTube and/or Spotify. For Spotify, for example, there is no link but only a search query.

"uri":"spotify:search:Master%20of%20Puppets%20Metallica"

Within the App you can connect Spotify and save all results in a playlist. Therefore Shazam must know the Spotify URL / ID.

I am Having Issue on Song Recognize

This is the function im trying to use
async def main():
shazam = Shazam()
out = await shazam.recognize_song(f'./Audio_Clean/'+str(Video_ID)+''+str(Account_ID)+''+str(splite_id)+'.mp3')
print(out)

            serialized = Serialize.full_track(out)
            print(serialized)


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

and i'm getting an error like this

C:\Users\farha\AppData\Local\Programs\Python\Python311\Lib\site-packages\pydub\utils.py:198: RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work
warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)
Traceback (most recent call last):
File "C:\Users\farha\Desktop\Youtube Project\Automation Script Project\download.py", line 4, in
Download_Tiktok_Videos("tiktokvideos")
File "C:\Users\farha\Desktop\Youtube Project\Automation Script Project\Tiktok_Scrap.py", line 625, in Download_Tiktok_Videos
loop.run_until_complete(fatch_audio_Description())
File "C:\Users\farha\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 650, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\farha\Desktop\Youtube Project\Automation Script Project\Tiktok_Scrap.py", line 621, in fatch_audio_Description
fileoutput = await shazam.recognize_song('./Audio_Clean/'+str(Video_ID)+''+str(Account_ID)+''+str(splite_id)+'.mp3')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\farha\AppData\Local\Programs\Python\Python311\Lib\site-packages\shazamio\api.py", line 324, in recognize_song
song = await get_song(data=data)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\farha\AppData\Local\Programs\Python\Python311\Lib\site-packages\shazamio\utils.py", line 39, in get_song
return AudioSegment.from_file(BytesIO(song_bytes))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\farha\AppData\Local\Programs\Python\Python311\Lib\site-packages\pydub\audio_segment.py", line 728, in from_file
info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\farha\AppData\Local\Programs\Python\Python311\Lib\site-packages\pydub\utils.py", line 274, in mediainfo_json
res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\farha\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1022, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\farha\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1491, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified

and i'm finding it hard to fix don't know whats wrong i double check the files existense but still the same issue

InvalidFieldError

I got an InvalidFieldError when I shazam the audio from these urls:

Full error:
InvalidFieldError: Invalid data at path [0, matches]: init() missing 1 required positional argument: 'channel'

Code

shazam = Shazam()
out = await shazam.recognize_song(data=data_path)
result = Serialize.full_track(data=out)
if not result.track:
    return

youtube_data = await shazam.get_youtube_data(link=result.track.youtube_link)
info = Serialize.youtube(youtube_data)

where data_path is a path to the audio file downloaded from the two previous URLs (example path: /tmp/my_app/aze456sd)

Debug

After debug, the error is raised by the line Serialize.full_track(data=out) with out equal to (convert to JSON here)
https://gist.github.com/Dysta/6c2620f2b1fef49e479aed14ad996196

Song recognition giving error

When I tried to recognize the song, it is giving me the following error. How to fix it?
Code:

import asyncio
from shazamio import Shazam


async def main():
  shazam = Shazam()
  out = await shazam.recognize_song('sample.mp3')
  print(out)

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

Error:

Traceback (most recent call last):
  File "D:\programs\shazamio_shazam_t.py", line 11, in <module>
    loop.run_until_complete(main())
  File "D:\Python\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "D:\programs\shazamio_shazam_t.py", line 7, in main
    out = await shazam.recognize_song('sample.mp3')
  File "D:\Python\lib\site-packages\shazamio\api.py", line 220, in recognize_song
    audio = self.normalize_audio_data(file)
  File "D:\Python\lib\site-packages\shazamio\converter.py", line 45, in normalize_audio_data
    audio = AudioSegment.from_file(BytesIO(song_data))
  File "D:\Python\lib\site-packages\pydub\audio_segment.py", line 728, in from_file
    info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
  File "D:\Python\lib\site-packages\pydub\utils.py", line 279, in mediainfo_json
    info = json.loads(output)
  File "D:\Python\lib\json\__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "D:\Python\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "D:\Python\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Proxy option

I'm having trouble using the library in one of my projects. I'm constantly getting rate limited by Shazam and would like to know if there is a way to use proxies, if support for httpx or something else could be implemented?

how to fix?

raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8',

question: Recognizing multiple songs at the same time

Hello, is it possible to recognize multiple songs with the method recognize_song('dora.mp3') at the same time?

I have some mp3s files downloaded that I want to identify its name, it is possible to make this task asynchronously or do I need to make it one by one as the for loop goes on.
My goal is to speed up the process of identifying the whole list of mp3s files. I've tried this task with threads and with asyncio but there's no such a difference in time.

Regards

API Methods creation progress

  • - SEARCH_FROM_FILE

  • TOP_WORLD

  • - ABOUT_ARTIST

  • - ARTIST_TOP_TRACKS

  • - ABOUT_TRACK

  • - TOP_TRACKS_COUNTRY

  • - TOP_TRACKS_CITY

  • - CITY_ID

  • - GENRE_WORLD

  • - GENRE_COUNTRY

How to directly pass the audio as bytes to recognize?

Hi, I am getting audio bytes and I want to pass the bytes directly to recognize without creating a file from the bytes.

result = await shazam.recognize_song(bytes_of_audio_file)
print(result)

is there any way to do this?

Ошибка recognize_song()

Π’Ρ‹Π²ΠΎΠ΄ΠΈΡ‚ ΠΎΡˆΠΈΠ±ΠΊΡƒ:
FileNotFoundError: [WinError 2] НС удаСтся Π½Π°ΠΉΡ‚ΠΈ ΡƒΠΊΠ°Π·Π°Π½Π½Ρ‹ΠΉ Ρ„Π°ΠΉΠ»

ΠŸΡ€ΠΎΠ²Π΅Ρ€ΠΈΠ», Ρ„Π°ΠΉΠ» ΡƒΠΊΠ°Π·Π°Π½ Π²Π΅Ρ€Π½ΠΎ. ΠŸΠΎΠΌΠΎΠ³ΠΈΡ‚Π΅ поТалуйста с Ρ‚Π°ΠΊΠΎΠΉ странной ΠΏΡ€ΠΎΠ±Π»Π΅ΠΌΠΎΠΉ
Π‘Π½ΠΈΠΌΠΎΠΊ экрана 2024-02-20 220648

FileNotFoundError: [WinError 2]

When I try to recognize a song from a file:

import asyncio
from shazamio import Shazam, Serialize


async def main():
    shazam = Shazam()
    out = await shazam.recognize_song("dora.ogg")
    print(out)

    serialized = Serialize.full_track(out)
    print(serialized)


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

I get this error:

hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] НС удаСтся Π½Π°ΠΉΡ‚ΠΈ ΡƒΠΊΠ°Π·Π°Π½Π½Ρ‹ΠΉ Ρ„Π°ΠΉΠ»

Although the file is in the same directory as the code

How to fix this error?

Album song count

Hey,

thanks for this! :)

could you tell me what'd be the best way to get the album song count of a recognized track?
I can see the album in the metadata list under sections. But is there a way to look up the album and get the amount of songs on that album?

Thanks!

Pydantic compatibility issue

There is a compatibility issue when other projects use Pydantic in addition to the Shazamio library.

Please update compatibility with new libraries, because shazamio uses very outdated versions of libraries.

shazamio 0.4.0.1 requires pydantic<2.0.0,>=1.10.2, but you have pydantic 2.5.3 which is incompatible.

Can we access the database?

Hi, thanks for the great project, it works just perfectly. I was wondering is there a way we can access the database of original song fingerprints so that if any song fingerprint is not available in the db we can generate the fingerprint for the same, and update the db?

recognize_song raises FileNotFoundError even if file is present

I'm writing a Teleram bot with Shazam-like functionality. Under the hood it downloads the file or voice message sent by user, gets its path and tries to recognize the song from file located on that path.

My code:

import telebot
import requests
import asyncio
from shazamio import Shazam

TOKEN = None

with open("TOKEN") as f:
    TOKEN = f.read().strip()

bot = telebot.TeleBot(TOKEN, parse_mode=None)

def download_file_and_return_name(file_id):
    file_info = bot.get_file(file_id)
    filename = file_info.file_path.split("/")[-1]
    resp = requests.get('https://api.telegram.org/file/bot{0}/{1}'.format(TOKEN, file_info.file_path))
    with open(filename, "wb") as f:
        f.write(resp.content)
    return filename

async def recognize(path):
    shazam = Shazam()
    print(path)
    print(os.path.exists(path))
    out = await shazam.recognize_song(path)
    print(out)


@bot.message_handler(content_types=["audio", "voice"])
def handle_audio(message):
    filename = download_file_and_return_name(message.voice.file_id if message.content_type == "voice" else message.audio.file_id)
    # loop = asyncio.get_event_loop()
    # loop.run_until_complete(recognize(filename))
    asyncio.run(recognize(filename))

bot.polling()

Unfortunately, recognize_song(file_path) method raises FileNotFoundError even if file is present, which is logged by print(os.path.exists(path))
Console log:

C:\Users\stass\workspace\shazamBotProject\venv\Scripts\python.exe C:/Users/stass/workspace/shazamBotProject/main.py
C:\Users\stass\workspace\shazamBotProject\venv\lib\site-packages\pydub\utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
  warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
file_40.oga
True
C:\Users\stass\workspace\shazamBotProject\venv\lib\site-packages\pydub\utils.py:198: RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work
  warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)
Traceback (most recent call last):
  File "C:\Users\stass\workspace\shazamBotProject\main.py", line 42, in <module>
    bot.polling()
  File "C:\Users\stass\workspace\shazamBotProject\venv\lib\site-packages\telebot\__init__.py", line 514, in polling
    self.__threaded_polling(none_stop, interval, timeout, long_polling_timeout)
  File "C:\Users\stass\workspace\shazamBotProject\venv\lib\site-packages\telebot\__init__.py", line 573, in __threaded_polling
    raise e
  File "C:\Users\stass\workspace\shazamBotProject\venv\lib\site-packages\telebot\__init__.py", line 536, in __threaded_polling
    self.worker_pool.raise_exceptions()
  File "C:\Users\stass\workspace\shazamBotProject\venv\lib\site-packages\telebot\util.py", line 117, in raise_exceptions
    raise self.exception_info
  File "C:\Users\stass\workspace\shazamBotProject\venv\lib\site-packages\telebot\util.py", line 69, in run
    task(*args, **kwargs)
  File "C:\Users\stass\workspace\shazamBotProject\main.py", line 40, in handle_audio
    asyncio.run(recognize(filename))
  File "C:\Users\stass\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\stass\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 642, in run_until_complete
    return future.result()
  File "C:\Users\stass\workspace\shazamBotProject\main.py", line 30, in recognize
    out = await shazam.recognize_song("file_35.ogg")
  File "C:\Users\stass\workspace\shazamBotProject\venv\lib\site-packages\shazamio\api.py", line 220, in recognize_song
    audio = self.normalize_audio_data(file)
  File "C:\Users\stass\workspace\shazamBotProject\venv\lib\site-packages\shazamio\converter.py", line 45, in normalize_audio_data
    audio = AudioSegment.from_file(BytesIO(song_data))
  File "C:\Users\stass\workspace\shazamBotProject\venv\lib\site-packages\pydub\audio_segment.py", line 685, in from_file
    info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
  File "C:\Users\stass\workspace\shazamBotProject\venv\lib\site-packages\pydub\utils.py", line 274, in mediainfo_json
    res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
  File "C:\Users\stass\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 947, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\stass\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1416, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

Process finished with exit code 1

I haven't used the loop = asyncio.get_event_loop() loop.run_until_complete(main()) construct from the example because it raises RuntimeError: There is no current event loop in thread 'WorkerThread2'

FileNotFoundError

FileNotFoundError: [WinError 2] The system cannot find the specified file
I'm getting this error, is very strange because I have the file in the correct path.
I'm getting this error with the recognize song example.

I have also tried different ways to specify the file path, and nothing works.
Please help me :)

Python 3.10.10

Invalid URL

Hello,

Recently I got many issues with track recognition.

Here is the exception I get (not on every song but very frequently)
Error occurred during recognition: Check args, URL is invalid
URL- https://amp.shazam.com/discovery/v5/en-US/GB/iphone/-/tag/69C006D3-5A23-4799-8C9A-5A21C5505B91/47C35018-6964-44CC-A7F4-18791B76949A?sync=true&webv3=true&sampling=true&connected=&shazamapiversion=v3&sharehub=true&hubv5minorversion=v5.1&hidelb=true&video=v3

Maybe something changed Shazam side ?

Thank you :)

Question: How can I get the title and the artist name?

Hi, I would like to ask how can I get the name and artist name only?

image

I'm trying to get only the title and subtitle but I don't know how can I get them from the raw format, is there a way to get it?
thank you in advance.
image

Minor refactoring proposal

I was trying to understand the recognize_song function and I saw some possible code improvements. Please note that I'm new to this codebase and I might have gotten things really wrong, so feel free to correct me if I'm wrong!
https://github.com/dotX12/ShazamIO/blob/17627a805c5ac228b9dab42521591ac494001d6a/shazamio/api.py#L347-L353
Here I believe the logic behind the check for signature_generator.input_pending_processing is already included following code
https://github.com/dotX12/ShazamIO/blob/17627a805c5ac228b9dab42521591ac494001d6a/shazamio/algorithm.py#L87-L89
so my proposal would be

 song = await get_song(data=data) 
 audio = self.normalize_audio_data(song) 
 signature_generator = self.create_signature_generator(audio) 
 signature = signature_generator.get_next_signature() 
  
 if signature is None: 
     return {"matches": []} 

https://github.com/dotX12/ShazamIO/blob/17627a805c5ac228b9dab42521591ac494001d6a/shazamio/api.py#L355-L358
Here is will never go inside the while loop since signature_generator.get_next_signature() always returns a DecodedMessage() instance or None for the case we covered above. So my proposal would be

 results = await self.send_recognize_request(signature) 
 return results 

https://github.com/dotX12/ShazamIO/blob/17627a805c5ac228b9dab42521591ac494001d6a/shazamio/algorithm.py#L103-L108
This code is also in the __init__ method of the class so it's already applied, it seems to me that it's not needed here. My proposal would be to keep it only in the __init__ method.

If you believe there is any value in any of these suggestions I can open a PR, else please feel free to completely ignore.
Thanks in advance for your time

woow!!!

hello my friend!congratulations but please can you help me run your amazing project to search music from shazam?
I run this but nothing pip install shazamio

This event loop is already running

When i try to run this code on a google collab it gives error RuntimeError: This event loop is already running

What i did:
!pip install shazamio

my code:

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())

Full Error:

RuntimeError                              Traceback (most recent call last)
[<ipython-input-3-9a17980d49a4>](https://localhost:8080/#) in <cell line: 11>()
      9 
     10 loop = asyncio.get_event_loop()
---> 11 loop.run_until_complete(main())

1 frames
[/usr/lib/python3.10/asyncio/base_events.py](https://localhost:8080/#) in _check_running(self)
    582     def _check_running(self):
    583         if self.is_running():
--> 584             raise RuntimeError('This event loop is already running')
    585         if events._get_running_loop() is not None:
    586             raise RuntimeError(

RuntimeError: This event loop is already running

Running async function inside FastAPI

How to run shazamio inside async function of FastAPI?

Running like this gives "RuntimeError: This event loop is already running in python"

@app.post("/music_recognition")
async def music_recognition(file: Request):
    ...........
    async def get_music_info():
        out = await shazam.recognize_song('temp.mp3')

    loop = asyncio.get_event_loop()
    loop.run_until_complete(get_music_info())
     ..........

Is there way to run shazam.recognize_song() not async?

Quota or changes to the API recently ?

Hi,
I wrote some code that runs different audio files through the shazamio library and gives me back a tracklist but I noticed something strange yesterday. I retested an old run and where I would get 102 matches for a list of files mid january 2024 I now (12 feb 2024) only get 4 and all the other chunks error out in my logging with the following error :

Error with chunk_5.mp3: Check args, URL is invalid
URL- https://amp.shazam.com/discovery/v5/en-US/GB/iphone/-/tag/B8057BCE-C9BF-421D-8273-B7974DF3CEA3/8F4BD112-2382-4E5C-A050-14D86830B82F?sync=true&webv3=true&sampling=true&connected=&shazamapiversion=v3&sharehub=true&hubv5minorversion=v5.1&hidelb=true&video=v3
Error with chunk_6.mp3: Check args, URL is invalid
URL- https://amp.shazam.com/discovery/v5/en-US/GB/iphone/-/tag/AF1F5AC9-6B84-4652-BA89-2568DB3E56F8/2BFF82F8-5A28-47F4-9A35-7C9AEF3D8FAB?sync=true&webv3=true&sampling=true&connected=&shazamapiversion=v3&sharehub=true&hubv5minorversion=v5.1&hidelb=true&video=v3

etc..... 

  1. has anyone else run into the same issue recently ?
  2. Was there any change in the library, shazam API or quota that would explain this because the code & audio files are identical ?

dependency conflicts.

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behavior is the source of the following dependency conflicts.
aiogram 3.3.0 requires aiofiles~=23.2.1, but you have aiofiles 22.1.0 which is incompatible.
aiogram 3.3.0 requires pydantic<2.6,>=2.4.1, but you have pydantic 1.10.14 which is incompatible.

How to use without Pydub

I have ffmpeg but for some reason I cannot use pydub and I wish to use ffmpeg directly without any wrappers, is there a way I can tweak this library to work without pydub?

ShazamIO can't recognise some tracks, but Shazam app works well with them

Hello!

Thank you for this very useful package – I use it to recognize streams from some live radiostations and it works pretty well :)
My use case is to record 10 seconds and recognize them and repeat this process with the next 10 seconds. If the recognized track differs from the previous one, then it should be added to the DB – it works very well for 99% of recognized tracks :)

Recently I discovered that it doesn't work for some tracks (but that tracks are successfully recognized by a Shazam app on iPhone). I use the app store version (not Siri integration).

For example, its something strange with the track "The Only Magic" by Alloise. I tried to split full track for 10 seconds segments and this track can't be recognized at all. The same with 20-second segments, but the iOS app works fine with all segments (also it sends track to Shazam after 6-7 seconds).

File with the 20-second sample: segment_2780000.mp3.zip (sorry, Github doesn't support .mp3 files, so it needs to be archived)

I'll look for implementation on the weekend (some time is needed to understand DecodedMessage and signature generator), but if you have some ideas why it might not work – it would be very helpful!

I tried to increase MAX_TIME_SECONDS, remove audio normalization, but it still doesn't work.

DeprecationWarning about event loop.

Since upgrading to Linux Mint 21 (ubuntu 20.04) I'm seeing

DeprecationWarning: There is no current event loop
loop = asyncio.get_event_loop()

Seems my Python is now version 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]

Paul Cornelius says (on StackExchange) "code will run on Python3.10 but as of 3.11 it will be an error to call asyncio.get_event_loop when there is no running loop in the current thread. Since you need loop as an argument, apparently, you must explicitly create and set it.

I tried pasting something like his suggestion, into my script in place of the 'loop = asyncio.get_event_loop()' bit, but just got a TypeError instead...

about_artist.py doe snot work

Hi,
I love this code but while testing it I found out that about_artist.py, regardless the id I use, always returns

DeprecationWarning: There is no current event loop loop = asyncio.get_event_loop() Traceback (most recent call last): File "C:\Development\Sampler\Python\get_artist_by_id.py", line 16, in <module> loop.run_until_complete(main()) File "C:\Users\nicola\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete return future.result() File "C:\Development\Sampler\Python\get_artist_by_id.py", line 9, in main serialized = Serialize.artist(about_artist) File "C:\Users\nicola\AppData\Local\Programs\Python\Python310\lib\site-packages\shazamio\serializers.py", line 23, in artist return FACTORY_ARTIST.load(data, Union[ArtistV2, ArtistInfo]) File "C:\Users\nicola\AppData\Local\Programs\Python\Python310\lib\site-packages\dataclass_factory\factory.py", line 222, in load return self.parser(class_)(data) File "C:\Users\nicola\AppData\Local\Programs\Python\Python310\lib\site-packages\dataclass_factory\parsers.py", line 99, in union_parser raise UnionParseError("No suitable parsers in union found for%s" % data, errors) dataclass_factory.exceptions.UnionParseError: No suitable parsers in union found for {'message': 'Not found'}`
Suberrors:

  • get_complex_parser..complex_parser: ArtistV2.init() missing 1 required positional argument: 'artist'
  • get_complex_parser..complex_parser: ArtistInfo.init() missing 2 required positional arguments: 'name' and 'verified'`

I installed python 3.16 and latest Shazamio library.
I think the URL https://www.shazam.com/discovery/v3/en/GB/web/artist is not valid anymore.

Error when parsing using Serialize

Code:

from shazamio import Shazam, Serialize

shazam = Shazam()


async def recognize(file_path):
    song_info = await shazam.recognize_song(file_path)
    return Serialize.full_track(song_info)

Exception:

Invalid data at path [1, _sections, track]: No suitable parsers in union found for `{'type': 'LYRICS', 'text': ['Haha!', "It's Reid", 'Welcome to my hotel room', 'A hotel room freestyle', "You already know, let's go", 'It goes like this, it goes exactly like this', '', 'Life goes on like a windmill', 'Only plot I got is to grip steal, make a mill', "Stayin' real, always ill from 1993 til", 'Souls of mischief did it better still', 'Whatever on ya skin like leather', 'Flap ya like a feather', "Don't depend on the weather", "You know I'm better", 'Than most these clowns', "Ya be seein' on the TV", "Cause I don't need cream, I got enough for me see", "I'm like a dairy farm I make cheese when I please", 'This untapped potential have you stuck on ya knees', 'Spewing goop like a slut when they sneeze', 'Jack ya wallet with ease', 'Bruised lids from a lack of sleep', 'Put a chrome to ya dome and eject the meat', "I'll take my seat now", 'Big G on the beats, kaplow', "Don't move dude", 'I got some more food for ya mouth', "Turn this old church to a fuckin' slaughterhouse", '', 'But hold the phone', 'Pick up all the pieces of ya head blown', "I love drugs but I'll never condone", 'Knockout a cop in the comfort of my own home', "Fuck pigs til I'm six feet overgrown", 'Head to hell screamin\' "Fuck 12"', "'Til I'm out the ozone", "Then dust 'em off like a camera lens", 'Whip a Benz', "Y'all should really see how far my shawty bends", 'And how my shotty ends life', 'Put 2 through you and save the rest for ya wife, bitch good night', 'I love my wife, but fuck life', 'Could get a murder charge just to see what the fuck it feels like', 'Leave me alone', 'Could give a fuck who you with bitch', 'I said leave me alone', 'Feed ya Momma a bone', 'Give her a treat if she make me a scone', 'Live ya life and get the fuck off ya phone', "Appreciate the moment and you'll never be alone", '', "I can't surf, but I'm gnar like Spicolli", 'Flat ya like some dough', 'And cut ya up like pepperoni', 'Personal pan pizza in the oven', "Bitch I'm hungry", 'I eat these fools faster than a motherfucking humvee', 'My honey got a rump that make', 'Humpty Dumpty land on his feet', 'Capiche?', 'Damn Reid be off the leash', '', 'I been kicked around, eaten up chewed and spit out', 'My mind was torn into pieces so I ripped that shit out', "Ten years down the drain, guess I wasn't cut out", 'Fast forward 2020, who you listen to now? (Reid)', "Mothafucka's gettin' sick off the clout", "They'd rather suck each other off", 'Instead of figure it out', "Reid's here to patch it up like a squeaky leaky water spout (Bitch)", '', 'Like a squeaky leaky water spout (Uh, Bitch)', 'Imma clean this shit up', 'Imma kill this shit', 'Just for fun', "I don't even have to", "Someone's gotta do it", "That's why I'm here", 'Hot Vodka Volume 1'], 'footer': 'Writer(s): Tanner Petulla\nLyrics powered by www.musixmatch.com', 'tabname': 'Lyrics', 'beacondata': {'lyricsid': '27638669', 'providername': 'musixmatch', 'commontrackid': '110409337'}}`
Suberrors:
  * get_complex_parser.<locals>.complex_parser: __init__() missing 2 required positional arguments: 'meta_pages' and 'metadata'
  * get_complex_parser.<locals>.complex_parser: __init__() missing 1 required positional argument: 'youtube_url'
  * get_complex_parser.<locals>.complex_parser: __init__() missing 1 required positional argument: 'url'
Traceback (most recent call last):
  File "/home/lzrdblzzrd/.cache/pypoetry/virtualenvs/lzrdbot-QMN38oMy-py3.8/lib/python3.8/site-packages/dataclass_factory/parsers.py", line 46, in dyn_element_parser
    return parser(data)
  File "/home/lzrdblzzrd/.cache/pypoetry/virtualenvs/lzrdbot-QMN38oMy-py3.8/lib/python3.8/site-packages/dataclass_factory/parsers.py", line 99, in union_parser
    raise UnionParseError("No suitable parsers in union found for `%s`" % data, errors)
dataclass_factory.exceptions.UnionParseError: No suitable parsers in union found for `{'type': 'LYRICS', 'text': ['Haha!', "It's Reid", 'Welcome to my hotel room', 'A hotel room freestyle', "You already know, let's go", 'It goes like this, it goes exactly like this', '', 'Life goes on like a windmill', 'Only plot I got is to grip steal, make a mill', "Stayin' real, always ill from 1993 til", 'Souls of mischief did it better still', 'Whatever on ya skin like leather', 'Flap ya like a feather', "Don't depend on the weather", "You know I'm better", 'Than most these clowns', "Ya be seein' on the TV", "Cause I don't need cream, I got enough for me see", "I'm like a dairy farm I make cheese when I please", 'This untapped potential have you stuck on ya knees', 'Spewing goop like a slut when they sneeze', 'Jack ya wallet with ease', 'Bruised lids from a lack of sleep', 'Put a chrome to ya dome and eject the meat', "I'll take my seat now", 'Big G on the beats, kaplow', "Don't move dude", 'I got some more food for ya mouth', "Turn this old church to a fuckin' slaughterhouse", '', 'But hold the phone', 'Pick up all the pieces of ya head blown', "I love drugs but I'll never condone", 'Knockout a cop in the comfort of my own home', "Fuck pigs til I'm six feet overgrown", 'Head to hell screamin\' "Fuck 12"', "'Til I'm out the ozone", "Then dust 'em off like a camera lens", 'Whip a Benz', "Y'all should really see how far my shawty bends", 'And how my shotty ends life', 'Put 2 through you and save the rest for ya wife, bitch good night', 'I love my wife, but fuck life', 'Could get a murder charge just to see what the fuck it feels like', 'Leave me alone', 'Could give a fuck who you with bitch', 'I said leave me alone', 'Feed ya Momma a bone', 'Give her a treat if she make me a scone', 'Live ya life and get the fuck off ya phone', "Appreciate the moment and you'll never be alone", '', "I can't surf, but I'm gnar like Spicolli", 'Flat ya like some dough', 'And cut ya up like pepperoni', 'Personal pan pizza in the oven', "Bitch I'm hungry", 'I eat these fools faster than a motherfucking humvee', 'My honey got a rump that make', 'Humpty Dumpty land on his feet', 'Capiche?', 'Damn Reid be off the leash', '', 'I been kicked around, eaten up chewed and spit out', 'My mind was torn into pieces so I ripped that shit out', "Ten years down the drain, guess I wasn't cut out", 'Fast forward 2020, who you listen to now? (Reid)', "Mothafucka's gettin' sick off the clout", "They'd rather suck each other off", 'Instead of figure it out', "Reid's here to patch it up like a squeaky leaky water spout (Bitch)", '', 'Like a squeaky leaky water spout (Uh, Bitch)', 'Imma clean this shit up', 'Imma kill this shit', 'Just for fun', "I don't even have to", "Someone's gotta do it", "That's why I'm here", 'Hot Vodka Volume 1'], 'footer': 'Writer(s): Tanner Petulla\nLyrics powered by www.musixmatch.com', 'tabname': 'Lyrics', 'beacondata': {'lyricsid': '27638669', 'providername': 'musixmatch', 'commontrackid': '110409337'}}`
Suberrors:
  * get_complex_parser.<locals>.complex_parser: __init__() missing 2 required positional arguments: 'meta_pages' and 'metadata'
  * get_complex_parser.<locals>.complex_parser: __init__() missing 1 required positional argument: 'youtube_url'
  * get_complex_parser.<locals>.complex_parser: __init__() missing 1 required positional argument: 'url'


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/lzrdblzzrd/.cache/pypoetry/virtualenvs/lzrdbot-QMN38oMy-py3.8/lib/python3.8/site-packages/pyrogram/dispatcher.py", line 222, in handler_worker
    await handler.callback(self.client, *args)
  File "/home/lzrdblzzrd/PycharmProjects/LZRDBot/client_bot.py", line 33, in _
    song_info = await recognize(file_path)
  File "/home/lzrdblzzrd/PycharmProjects/LZRDBot/modules/shazam.py", line 8, in recognize
    return Serialize.full_track(song_info)
  File "/home/lzrdblzzrd/.cache/pypoetry/virtualenvs/lzrdbot-QMN38oMy-py3.8/lib/python3.8/site-packages/shazamio/serializers.py", line 24, in full_track
    return FACTORY_TRACK.load(data, ResponseTrack)
  File "/home/lzrdblzzrd/.cache/pypoetry/virtualenvs/lzrdbot-QMN38oMy-py3.8/lib/python3.8/site-packages/dataclass_factory/factory.py", line 213, in load
    return self.parser(class_)(data)
  File "/home/lzrdblzzrd/.cache/pypoetry/virtualenvs/lzrdbot-QMN38oMy-py3.8/lib/python3.8/site-packages/dataclass_factory/parsers.py", line 223, in complex_parser
    result = parser(data[item_name])
  File "/home/lzrdblzzrd/.cache/pypoetry/virtualenvs/lzrdbot-QMN38oMy-py3.8/lib/python3.8/site-packages/dataclass_factory/parsers.py", line 34, in element_parser
    return parser(data)
  File "/home/lzrdblzzrd/.cache/pypoetry/virtualenvs/lzrdbot-QMN38oMy-py3.8/lib/python3.8/site-packages/dataclass_factory/parsers.py", line 260, in optional_parser
    return parser(data) if data is not None else None
  File "/home/lzrdblzzrd/.cache/pypoetry/virtualenvs/lzrdbot-QMN38oMy-py3.8/lib/python3.8/site-packages/dataclass_factory/parsers.py", line 223, in complex_parser
    result = parser(data[item_name])
  File "/home/lzrdblzzrd/.cache/pypoetry/virtualenvs/lzrdbot-QMN38oMy-py3.8/lib/python3.8/site-packages/dataclass_factory/parsers.py", line 34, in element_parser
    return parser(data)
  File "/home/lzrdblzzrd/.cache/pypoetry/virtualenvs/lzrdbot-QMN38oMy-py3.8/lib/python3.8/site-packages/dataclass_factory/parsers.py", line 260, in optional_parser
    return parser(data) if data is not None else None
  File "/home/lzrdblzzrd/.cache/pypoetry/virtualenvs/lzrdbot-QMN38oMy-py3.8/lib/python3.8/site-packages/dataclass_factory/parsers.py", line 79, in collection_parser
    return collection_factory(
  File "/home/lzrdblzzrd/.cache/pypoetry/virtualenvs/lzrdbot-QMN38oMy-py3.8/lib/python3.8/site-packages/dataclass_factory/parsers.py", line 80, in <genexpr>
    dyn_element_parser(item_parser, x, i) for i, x in enumerate(data)
  File "/home/lzrdblzzrd/.cache/pypoetry/virtualenvs/lzrdbot-QMN38oMy-py3.8/lib/python3.8/site-packages/dataclass_factory/parsers.py", line 51, in dyn_element_parser
    raise InvalidFieldError(str(e), [str(key)])
dataclass_factory.exceptions.InvalidFieldError: Invalid data at path [1, _sections, track]: No suitable parsers in union found for `{'type': 'LYRICS', 'text': ['Haha!', "It's Reid", 'Welcome to my hotel room', 'A hotel room freestyle', "You already know, let's go", 'It goes like this, it goes exactly like this', '', 'Life goes on like a windmill', 'Only plot I got is to grip steal, make a mill', "Stayin' real, always ill from 1993 til", 'Souls of mischief did it better still', 'Whatever on ya skin like leather', 'Flap ya like a feather', "Don't depend on the weather", "You know I'm better", 'Than most these clowns', "Ya be seein' on the TV", "Cause I don't need cream, I got enough for me see", "I'm like a dairy farm I make cheese when I please", 'This untapped potential have you stuck on ya knees', 'Spewing goop like a slut when they sneeze', 'Jack ya wallet with ease', 'Bruised lids from a lack of sleep', 'Put a chrome to ya dome and eject the meat', "I'll take my seat now", 'Big G on the beats, kaplow', "Don't move dude", 'I got some more food for ya mouth', "Turn this old church to a fuckin' slaughterhouse", '', 'But hold the phone', 'Pick up all the pieces of ya head blown', "I love drugs but I'll never condone", 'Knockout a cop in the comfort of my own home', "Fuck pigs til I'm six feet overgrown", 'Head to hell screamin\' "Fuck 12"', "'Til I'm out the ozone", "Then dust 'em off like a camera lens", 'Whip a Benz', "Y'all should really see how far my shawty bends", 'And how my shotty ends life', 'Put 2 through you and save the rest for ya wife, bitch good night', 'I love my wife, but fuck life', 'Could get a murder charge just to see what the fuck it feels like', 'Leave me alone', 'Could give a fuck who you with bitch', 'I said leave me alone', 'Feed ya Momma a bone', 'Give her a treat if she make me a scone', 'Live ya life and get the fuck off ya phone', "Appreciate the moment and you'll never be alone", '', "I can't surf, but I'm gnar like Spicolli", 'Flat ya like some dough', 'And cut ya up like pepperoni', 'Personal pan pizza in the oven', "Bitch I'm hungry", 'I eat these fools faster than a motherfucking humvee', 'My honey got a rump that make', 'Humpty Dumpty land on his feet', 'Capiche?', 'Damn Reid be off the leash', '', 'I been kicked around, eaten up chewed and spit out', 'My mind was torn into pieces so I ripped that shit out', "Ten years down the drain, guess I wasn't cut out", 'Fast forward 2020, who you listen to now? (Reid)', "Mothafucka's gettin' sick off the clout", "They'd rather suck each other off", 'Instead of figure it out', "Reid's here to patch it up like a squeaky leaky water spout (Bitch)", '', 'Like a squeaky leaky water spout (Uh, Bitch)', 'Imma clean this shit up', 'Imma kill this shit', 'Just for fun', "I don't even have to", "Someone's gotta do it", "That's why I'm here", 'Hot Vodka Volume 1'], 'footer': 'Writer(s): Tanner Petulla\nLyrics powered by www.musixmatch.com', 'tabname': 'Lyrics', 'beacondata': {'lyricsid': '27638669', 'providername': 'musixmatch', 'commontrackid': '110409337'}}`
Suberrors:
  * get_complex_parser.<locals>.complex_parser: __init__() missing 2 required positional arguments: 'meta_pages' and 'metadata'
  * get_complex_parser.<locals>.complex_parser: __init__() missing 1 required positional argument: 'youtube_url'
  * get_complex_parser.<locals>.complex_parser: __init__() missing 1 required positional argument: 'url'


Does shazamio work with audio playing from URL instead of a file?

I want to detect the music playing on some URL (an IceCast stream for example), is there a way to do that? Running the following code gives FileNotFoundError: [Errno 2] No such file or directory: 'http://' :

async def main():
    shazam = Shazam()
    out = await shazam.recognize_song('http://<URL>')
    print(out)```

Artist Serialization doesn't work

Hello, I'm trying to serialize artist info with this code
import asyncio
from shazamio import Shazam, Serialize

async def main():
shazam = Shazam()
about_artist = await shazam.artist_about(293238693)
serialized = Serialize.artist(about_artist)
print(serialized)

asyncio.run(main())

However when I run this code I get this error:
Error Text
I think the parser might be out of date

load on the processor.

Hi. Great project.
You can tell why recognition is causing such a heavy load on the processor.
I am sending a file of 500 kb, this is enough for the detection, but the CPU load is huge at the moment of recognition.
Can the load be reduced? Does it depend on the file format for recognition?
Thanks!

Tracklist from a long audio sample

Hi! First of all thanks a lot for making this..
Did you consider to use as input a long audio sample and get back the tracklist? Do you have any idea on how to do it?

Get artist top tracks

I use this artist_id 1304716885 for get details from artist and it work fine
but when I want to get top track from this artist it show me error
shazamio.exceptions.FailedDecodeJson: Check args, URL is invalid URL- https://cdn.shazam.com/shazam/v3/en/GB/web/-/tracks/artisttoptracks_1304716885?startFrom=0&pageSize=3&connected=&channel=
I use this artist_id 201896832 you put in the example file and it works but for another artist, it gives an error

[Feature] Recognize to Rust Language

Recognize from Python to Rust

Currently, active work is underway to unload the processor; searching for a signature is a complex operation for the CPU, especially for a language where there is an asynchronous approach, because of this, asynchrony for the recoginze method disappears.
What has already been done:
The search for song signatures from Python to Rust has been rewritten.
integration of this module through pyo3, as is done with pydantic.

There is very little left, but now you can see the preliminary results.

Before

Test for 20 iterations.

async def main():
    shazam = Shazam()
    t = time.perf_counter()
    a = await asyncio.gather(*[shazam.recognize_song("data/dora.ogg") for _ in range(20)])  # blocking code
    t2 = time.perf_counter()
    print(t2-t)

loop = asyncio.get_event_loop_policy().get_event_loop()
loop.run_until_complete(main())
>>> 23.145966300013242

After:

Test for 50 iterations.

async def main():
    sender = rust.Recognizer()
    t = time.perf_counter()
    a = await asyncio.gather(*[sender.recognize_path("data/dora.ogg") for _ in range(50)])
    t2 = time.perf_counter()
    print(t2 - t)
>>> 2.246784299990395

Shazamio stops working

It was working perfectly fine but now if I used the example used in pypi i.e,

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())

Then it is returning {}.
What should I do? btw I am using shazamio==0.0.2 and python 3.8.2

Asyncio vs purely synchronous performance

I made a small experiment to understand the benefit of using asyncio but so far I found that there's no improvement over making synchronous requests to the API. It takes around 4 seconds for one request and the total time for the program scales with the number of calls. I've even made each request run in its own thread but the result was still the same. I am quite confused by this behaviour.

Does anyone have insights into this ?

import asyncio
from shazamio import Shazam
import threading 

async def run_task(shazam): 
    ret = await shazam.recognize_song('SomeFile.mp3')

def run_all_tasks(iters):
    shazam = Shazam()
    threads = []
    
    for i in range(iters):
        thread = threading.Thread(target=asyncio.run, args=(run_task(shazam),))
        threads.append(thread)
        thread.start()
        
    # Wait for all threads to finish
    for thread in threads:
        thread.join()


run_all_tasks(5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.