Package metalparser.libs¶
Module metalparser.libs.darklyrics_utils¶
-
class
metalparser.libs.darklyrics_utils.
DarkLyricsHelper
(use_cache)[source]¶ Bases:
object
A class with helpers for DarkLyricsApi
-
BASE_URL
¶ DarkLyrics.com base URL
- Type
str
-
scraping_agent
¶ The agent taking hand of HTTP requests
- Type
-
get_artist_page
(self, artist)[source]¶ Returns a DarkLyrics.com page related to an artist in form of a BeautifulSoup object.
-
get_songs_links_from_artist
(self, artist, album=None)[source]¶ Returns a links list containing all the lyrics URLs related to an artist or an album.
-
get_albums_info_from_artist_page(self, artist_page, all_info=False):
Given the artist page, returns infos about the albums.
-
get_albums_info_from_url(self, url):
Returns album info given the album’s URL.
-
get_lyrics_url_by_song
(self, song, artist)[source]¶ Given a song title and the artist, returns the link related to the lyrics.
-
get_lyrics_url_by_tag
(self, link_tag)[source]¶ Given an <a> HTML tag related to a song’s lyrics, returns the related URL.
-
get_albums_info_from_artist_page
(artist_page, title_only=False)[source]¶ Given the artist page, retrieve infos about the albums.
- Parameters
{BeautifulSoup} -- The artist page in BeautifulSoup format. (artist_page) –
- Keyword Arguments
{bool} -- Flag to determinate if returning all albums info or title only (default (all_info) – {False})
- Returns
[list] – List of albums (str list or dict list, depending on all_info)
-
get_albums_info_from_url
(url)[source]¶ Returns album info given the album’s URL.
- Parameters
{str} -- The album's URL (url) –
- Returns
title, release year and type (album, EP).
- Return type
[dict] – A dict with the following album info
-
get_artist_page
(artist)[source] Returns a DarkLyrics.com page related to an artist in form of a BeautifulSoup object.
- Parameters
{str} -- The artist's name (artist) –
- Raises
ArtistNotFoundException – Exception raised when the URL is not found on DarkLyrics.com
- Returns
[BeautifulSoup] – Page related to an artist in form of a BeautifulSoup object
-
get_base_url
()[source] Returns DarkLyrics.com base URL.
- Returns
[str] – DarkLyrics.com base URL
-
get_lyrics_by_url
(url)[source] Given an URL related to a song, returns the lyrics.
- Parameters
{str} -- URL leading to the lyrics of a certain song (url) –
- Raises
LyricsNotFoundException – Exception raised when no lyrics div is found
- Returns
[str] – A string with the lyrics related to the specified URL
-
get_lyrics_url_by_song
(song, artist)[source] Given a song title and the artist, returns the link related to the lyrics.
- Parameters
{str} -- The title of the song (song) –
{str} -- The artist's name (artist) –
- Raises
LyricsNotFoundException – Exception raised when no link is found
- Returns
[str] – The link related to the lyrics of the specified song
-
get_lyrics_url_by_tag
(link_tag)[source] Given an <a> HTML tag related to a song’s lyrics, returns the related URL.
- Parameters
{BeautifulSoup} -- <a> tag which is supposed to contain an URL related to lyrics (link_tag) –
- Raises
LyricsNotFoundException – Exception raised when no link or invalid link is found
- Returns
[str] – URL string contained in the specified <a> tag, leading to lyrics.
-
get_songs_links_from_artist
(artist, album=None)[source] Returns a links list containing all the lyrics URLs related to an artist or an album.
- Parameters
{str} -- The artist's name (artist) –
- Keyword Arguments
{str} -- The title of the album (album) – {None})
- Raises
SongsNotFoundException – Exception raised when no songs related to an artist or album are found
- Returns
[list] – List of strings containing all the lyrics URLs related to an artist or an album
-