✨ Use Album.image() to get cover url.

This commit is contained in:
Robert Honz
2024-03-25 16:53:27 +01:00
parent 453205bf48
commit f7361b3078
6 changed files with 9 additions and 15 deletions
+5 -3
View File
@@ -36,9 +36,11 @@ class StreamManifestMimeType(Enum):
class CoverDimensions(Enum): class CoverDimensions(Enum):
Px320: str = "320x320" Px80: int = 80
Px640: str = "640x640" Px160: int = 160
Px1280: str = "1280x1280" Px320: int = 320
Px640: int = 640
Px1280: int = 1280
class TidalLists(Enum): class TidalLists(Enum):
+1 -10
View File
@@ -21,7 +21,6 @@ from tidal_dl_ng.constants import (
EXTENSION_LYRICS, EXTENSION_LYRICS,
REQUESTS_TIMEOUT_SEC, REQUESTS_TIMEOUT_SEC,
AudioExtensions, AudioExtensions,
CoverDimensions,
MediaType, MediaType,
SkipExisting, SkipExisting,
StreamManifestMimeType, StreamManifestMimeType,
@@ -271,12 +270,6 @@ class Download:
# Move it. # Move it.
shutil.move(tmp_lyrics_file_path, os.path.splitext(file_media_dst)[0] + EXTENSION_LYRICS) shutil.move(tmp_lyrics_file_path, os.path.splitext(file_media_dst)[0] + EXTENSION_LYRICS)
def cover_url(self, sid: str, dimension: CoverDimensions = CoverDimensions.Px320):
if sid is None:
return ""
return f"https://resources.tidal.com/images/{sid.replace('-', '/')}/{dimension.value}.jpg"
def lyrics_write_file(self, file_path: str, lyrics: str) -> str: def lyrics_write_file(self, file_path: str, lyrics: str) -> str:
result: str = file_path result: str = file_path
@@ -331,9 +324,7 @@ class Download:
totaltrack=track.album.num_tracks if track.album and track.album.num_tracks else 1, totaltrack=track.album.num_tracks if track.album and track.album.num_tracks else 1,
totaldisc=track.album.num_volumes if track.album and track.album.num_volumes else 1, totaldisc=track.album.num_volumes if track.album and track.album.num_volumes else 1,
discnumber=track.volume_num if track.volume_num else 1, discnumber=track.volume_num if track.volume_num else 1,
url_cover=( url_cover=track.album.image(self.settings.data.metadata_cover_dimension),
self.cover_url(track.album.cover, self.settings.data.metadata_cover_dimension) if track.album else ""
),
) )
m.save() m.save()
+2 -1
View File
@@ -142,7 +142,8 @@ class Metadata:
self.m.tags["\xa9wrt"] = ", ".join(self.composer) if self.composer else "" self.m.tags["\xa9wrt"] = ", ".join(self.composer) if self.composer else ""
self.m.tags["\xa9lyr"] = self.lyrics self.m.tags["\xa9lyr"] = self.lyrics
def cover_data(self, url: str = None, path_file: str = None) -> str | bytes: @staticmethod
def cover_data(url: str = None, path_file: str = None) -> str | bytes:
result: str | bytes = "" result: str | bytes = ""
if url: if url:
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

+1 -1
View File
@@ -543,7 +543,7 @@
<string/> <string/>
</property> </property>
<property name="pixmap"> <property name="pixmap">
<pixmap>placeholder_cover.jpg</pixmap> <pixmap>default_album_image.png</pixmap>
</property> </property>
<property name="scaledContents"> <property name="scaledContents">
<bool>true</bool> <bool>true</bool>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB