mirror of
https://github.com/glomatico/gamdl.git
synced 2025-01-22 11:18:39 +00:00
chore: Add support for fetching raw cover images
This commit is contained in:
parent
57ee6e1db8
commit
b8bd406d74
@ -197,3 +197,5 @@ The following synced lyrics formats are available:
|
||||
The following cover formats are available:
|
||||
* `jpg`
|
||||
* `png`
|
||||
* `raw`
|
||||
* Gets the raw cover without any processing in JPEG format.
|
||||
|
@ -353,8 +353,25 @@ class Downloader:
|
||||
return self.output_path.joinpath(*final_path_folder).joinpath(*final_path_file)
|
||||
|
||||
def get_cover_url(self, metadata: dict) -> str:
|
||||
if self.cover_format == CoverFormat.RAW:
|
||||
return self._get_raw_cover_url(metadata["attributes"]["artwork"]["url"])
|
||||
return self._get_cover_url(metadata["attributes"]["artwork"]["url"])
|
||||
|
||||
def _get_raw_cover_url(self, cover_url_template: str) -> str:
|
||||
return re.sub(
|
||||
r"image/thumb/",
|
||||
"",
|
||||
re.sub(
|
||||
r"is1-ssl",
|
||||
"a1",
|
||||
re.sub(
|
||||
r"/\{w\}x\{h\}([a-z]{2})\.jpg",
|
||||
"",
|
||||
cover_url_template,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
def _get_cover_url(self, cover_url_template: str) -> str:
|
||||
return re.sub(
|
||||
r"\{w\}x\{h\}([a-z]{2})\.jpg",
|
||||
@ -409,7 +426,7 @@ class Downloader:
|
||||
self.get_url_response_bytes(cover_url),
|
||||
imageformat=(
|
||||
MP4Cover.FORMAT_JPEG
|
||||
if self.cover_format == CoverFormat.JPG
|
||||
if self.cover_format in (CoverFormat.JPG, CoverFormat.RAW)
|
||||
else MP4Cover.FORMAT_PNG
|
||||
),
|
||||
)
|
||||
|
@ -46,3 +46,4 @@ class PostQuality(Enum):
|
||||
class CoverFormat(Enum):
|
||||
JPG = "jpg"
|
||||
PNG = "png"
|
||||
RAW = "raw"
|
||||
|
Loading…
Reference in New Issue
Block a user