feat: added artwork fetching from musify
This commit is contained in:
parent
44d1f0d7db
commit
4ee2914405
@ -9,7 +9,7 @@ from rich.console import Console
|
||||
from .utils.shared import DEBUG, DEBUG_LOGGING
|
||||
from .utils.config import logging_settings, main_settings, read_config
|
||||
|
||||
__version__ = "1.14.0"
|
||||
__version__ = "1.15.0"
|
||||
|
||||
read_config()
|
||||
|
||||
|
@ -33,7 +33,10 @@ class Artwork:
|
||||
def _calculate_deviation(*dimensions: List[int]) -> float:
|
||||
return sum(abs(d - main_settings["preferred_artwork_resolution"]) for d in dimensions) / len(dimensions)
|
||||
|
||||
def append(self, url: str, width: int, height: int, **kwargs) -> None:
|
||||
def append(self, url: str, width: int = main_settings["preferred_artwork_resolution"], height: int = main_settings["preferred_artwork_resolution"], **kwargs) -> None:
|
||||
if url is None:
|
||||
return
|
||||
|
||||
self._variant_mapping[hash_url(url=url)] = {
|
||||
"url": url,
|
||||
"width": width,
|
||||
|
@ -21,7 +21,8 @@ from ..objects import (
|
||||
Label,
|
||||
Target,
|
||||
DatabaseObject,
|
||||
Lyrics
|
||||
Lyrics,
|
||||
Artwork
|
||||
)
|
||||
from ..utils.config import logging_settings
|
||||
from ..utils import string_processing, shared
|
||||
@ -477,6 +478,11 @@ class Musify(Page):
|
||||
|
||||
track_name = list_points[4].text.strip()
|
||||
|
||||
# artwork
|
||||
artwork: Artwork = Artwork()
|
||||
album_image_element_list: List[BeautifulSoup] = soup.find_all("img", {"class": "album-img"})
|
||||
for album_image_element in album_image_element_list:
|
||||
artwork.append(url=album_image_element.get("data-src", album_image_element.get("src")))
|
||||
|
||||
# lyrics
|
||||
lyrics_container: List[BeautifulSoup] = soup.find_all("div", {"id": "tabLyrics"})
|
||||
@ -501,6 +507,7 @@ class Musify(Page):
|
||||
lyrics_list=lyrics_list,
|
||||
main_artist_list=artist_list,
|
||||
album_list=album_list,
|
||||
artwork=artwork,
|
||||
)
|
||||
|
||||
def _parse_song_card(self, song_card: BeautifulSoup) -> Song:
|
||||
|
Loading…
Reference in New Issue
Block a user