Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/AmanoTeam/LyricsPy
Python library for searching lyrics on Musixmatch, Genius and letras.mus.br.
https://github.com/AmanoTeam/LyricsPy
genius lyrics lyrics-fetcher music musixmatch python python-library python3
Last synced: 3 months ago
JSON representation
Python library for searching lyrics on Musixmatch, Genius and letras.mus.br.
- Host: GitHub
- URL: https://github.com/AmanoTeam/LyricsPy
- Owner: AmanoTeam
- Created: 2019-06-11T23:33:10.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-17T00:30:12.000Z (4 months ago)
- Last Synced: 2024-07-17T04:33:02.892Z (4 months ago)
- Topics: genius, lyrics, lyrics-fetcher, music, musixmatch, python, python-library, python3
- Language: Python
- Homepage:
- Size: 72.3 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
LyricsPy
A library to search for music lyrics.
## Installation
LyricsPy can be installed using `pip` from PyPI or from GitHub.
### via PyPI
```bash
pip install -U lyricspy
```#### via GitHub using pip+git
```bash
pip install -U git+https://github.com/AmanoTeam/LyricsPy
```## Usage
Using LyricsPy is easy, but let's see some examples:
### Musixmatch example
```python
from lyricspy import Musixmatch
import jsondef 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
```python
from lyricspy import Lyricsdef 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")
```