Skip to main content

LyricsPy

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

Metadata

Release files for LyricsPy 2.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for LyricsPy 2.2.1
File Size Uploaded
lyricspy-2.2.1.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for LyricsPy 2.2.1
File Interpreter ABI Platform
LyricsPy-2.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.9 kB

Release files / lyricspy-2.2.1.tar.gz

Download URL lyricspy-2.2.1.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6289eec6b503ad1f50c882455ca9e434a4370b3b6a525b1ef4d500d7ef7a0c14
BLAKE2b-256 checksum
How to use checksums
43f95b3a5cf630a061b444498e13960f462d54d57b04b49b6f1a467b36460700
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Release files / LyricsPy-2.2.1-py3-none-any.whl

Download URL LyricsPy-2.2.1-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b27307758978dc4a6f4124ef7b083521e0e9e5dbc9dac20c1b3eaacd5fc2d5e2
BLAKE2b-256 checksum
How to use checksums
a5ce369a327e129281d364f648a552f720dfe431c1068157299c54ea24e80e50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page