πΆ LyricsΒΆ
Module: lyrics.py
Provides functionality for retrieving song lyrics using the LRClib API.
- class LyricsΒΆ
A class for interacting with the LRClib API to fetch and manage song lyrics.
- check_instrumental(metadata: TrackMetadata) bool ΒΆ
Determines if a track is instrumental.
- Parameters:
metadata (TrackMetadata) β The metadata of the track.
- Returns:
True if the track is instrumental (i.e., no lyrics found), False otherwise.
- Return type:
bool
- get_lyrics(metadata: TrackMetadata) str ΒΆ
Retrieves lyrics from LRClib.net for a specified track and artist.
- Parameters:
metadata (TrackMetadata) β The metadata of the track.
- Returns:
The lyrics of the track in plain text if available; otherwise, a placeholder message for instrumental tracks.
- Return type:
str
- Raises:
NoLyricsAvailable β If no lyrics are found for the specified track and artist.
- select_lines(lyrics: str, selection: str) str ΒΆ
Extracts a specific range of lines from the given song lyrics.
- Parameters:
lyrics (str) β The full lyrics of the song as a single string.
selection (str) β The range of lines to extract, specified in the format βstart-endβ (e.g., β2-5β).
- Returns:
A string containing exactly 4 extracted lines, separated by newline characters.
- Return type:
str
- Raises:
InvalidFormatError β If the selection argument is not in the correct βstart-endβ format.
InvalidSelectionError β If the specified range is out of bounds or otherwise invalid.
LineLimitExceededError β If the selected range does not include exactly 4 non-empty lines.