diff --git a/README.md b/README.md index d652638..5e67bef 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/gamdl/downloader.py b/gamdl/downloader.py index 478d2a6..afa4237 100644 --- a/gamdl/downloader.py +++ b/gamdl/downloader.py @@ -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 ), ) diff --git a/gamdl/enums.py b/gamdl/enums.py index cec7cc8..ff9dc63 100644 --- a/gamdl/enums.py +++ b/gamdl/enums.py @@ -46,3 +46,4 @@ class PostQuality(Enum): class CoverFormat(Enum): JPG = "jpg" PNG = "png" + RAW = "raw"