Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Request) - search lyrics #77

Closed
Sansekai opened this issue Dec 15, 2023 · 2 comments
Closed

(Request) - search lyrics #77

Sansekai opened this issue Dec 15, 2023 · 2 comments
Labels
good first issue Good for newcomers

Comments

@Sansekai
Copy link

Can add search lyrics?

@dotX12
Copy link
Collaborator

dotX12 commented Dec 16, 2023

@Sansekai, hello!
It's worth considering that not all songs have lyrics, but if they do, this function will find them.

image

import asyncio

from shazamio import Shazam


def find_lyrics(data) -> list[str] | None:
    if data.get("track"):
        if data["track"].get("sections"):
            for element in data["track"]["sections"]:
                if element.get("type") == "LYRICS":
                    return element.get("text")
    return None


async def main():
    shazam = Shazam()
    out = await shazam.recognize_song("data/Joey_Bada_THE_REV3NGE.mp3")
    print(find_lyrics(out))


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

@dotX12
Copy link
Collaborator

dotX12 commented Dec 16, 2023

You can always look at the JSON that shazam returns and get the necessary data, for example, the lyrics of a song.
from shazamio import Serialize was created for simple scenarios; there is not always time to keep it up to date :(

@dotX12 dotX12 added the good first issue Good for newcomers label Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants