search lyrics on musixmatch.com
Project description
LyricsPy
A library to search for music lyrics.
Installation
LyricsPy can be installed using pip from PyPI or from GitHub.
via PyPI
pip install -U lyricspy
via GitHub using pip+git
pip install -U git+https://github.com/AmanoTeam/LyricsPy
Usage
Using LyricsPy is easy, but let's see some examples:
Musixmatch example
from lyricspy import Musixmatch
import json
def search_lyrics_and_translation_musixmatch(query, lang="pt", limit=1):
# Initializes the Musixmatch class
musixmatch = Musixmatch()
# Note: after the 2.2.0 update the token is optional
# Performs an automatic search to obtain the lyrics and their translations
search_results = musixmatch.auto(query, lang, limit)
# Saves the results in a JSON file for viewing
with open("musixmatch_results.json", "w") as f:
json.dump(search_results, f)
# Example of use
search_lyrics_and_translation_musixmatch("Hello")
Lyrics example
from lyricspy import Lyrics
def search_lyrics_and_translation(query):
# Initializes the Lyrics class
lyrics = Lyrics()
# Performs the initial search to obtain the links to the lyrics
search_results = lyrics.search(query)
# Iterates through the search results
for result in search_results:
# Extracts the link to the lyrics
lyrics_link = result["link"]
# Performs the search for the lyrics on the page of the obtained link
lyrics_details = lyrics.lyric(result)
# Prints the title of the song, the lyrics, and the translation (if available)
print(f"Title: {lyrics_details['music']}")
print(f"Lyrics: \n{lyrics_details['lyric']}\n")
if lyrics_details['translation']:
print(f"Translation: \n{lyrics_details['translation']}\n")
# Example of use
search_lyrics_and_translation("Hello")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lyricspy-2.2.0.post1.tar.gz
(4.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lyricspy-2.2.0.post1.tar.gz.
File metadata
- Download URL: lyricspy-2.2.0.post1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
259c19890e9074b79b674cbbba8537a9bdef8323e9b2333d605dbe7dd9aa81ad
|
|
| MD5 |
543da12950359220bef4deebd33833c8
|
|
| BLAKE2b-256 |
50d8057715c0f862de9e8780688f8e4abe797409cc2d638dec79e408a146b18b
|
File details
Details for the file LyricsPy-2.2.0.post1-py3-none-any.whl.
File metadata
- Download URL: LyricsPy-2.2.0.post1-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5d6bb79be5b40084732f7b0688e6e59d6e9387f0d4aa8322549ed3f63864e77
|
|
| MD5 |
6e132322d32a3ff261ab7053bff96f0f
|
|
| BLAKE2b-256 |
a82d324b02c37a5775abb01498d7e75dceaa67507530633f646b5695368a2630
|