add coverSize

add coverSize
pull/8/head
zhaarey 6 months ago committed by GitHub
commit 2338271f27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      config.toml
  2. 4
      src/api.py
  3. 1
      src/config.py
  4. 4
      src/metadata.py
  5. 2
      src/rip.py

@ -19,6 +19,7 @@ dirPathFormat = "downloads/{album_artist}/{album}"
saveLyrics = true saveLyrics = true
saveCover = true saveCover = true
coverFormat = "jpg" coverFormat = "jpg"
coverSize = "5000x5000"
afterDownloaded = "" afterDownloaded = ""
check = "" check = ""

@ -84,9 +84,9 @@ async def get_meta(album_id: str, token: str, storefront: str, lang: str):
@retry(retry=retry_if_exception_type((httpx.TimeoutException, httpcore.ConnectError, SSLError, FileNotFoundError)), @retry(retry=retry_if_exception_type((httpx.TimeoutException, httpcore.ConnectError, SSLError, FileNotFoundError)),
stop=stop_after_attempt(5), stop=stop_after_attempt(5),
before_sleep=before_sleep_log(logger, logging.WARN)) before_sleep=before_sleep_log(logger, logging.WARN))
async def get_cover(url: str, cover_format: str): async def get_cover(url: str, cover_format: str, cover_size: str):
formatted_url = regex.sub('bb.jpg', f'bb.{cover_format}', url) formatted_url = regex.sub('bb.jpg', f'bb.{cover_format}', url)
req = await client.get(formatted_url.replace("{w}x{h}", "10000x10000"), req = await client.get(formatted_url.replace("{w}x{h}", cover_size),
headers={"User-Agent": user_agent_browser}) headers={"User-Agent": user_agent_browser})
return req.content return req.content

@ -26,6 +26,7 @@ class Download(BaseModel):
saveLyrics: bool saveLyrics: bool
saveCover: bool saveCover: bool
coverFormat: str coverFormat: str
coverSize: str
afterDownloaded: str afterDownloaded: str
check: str check: str

@ -58,5 +58,5 @@ class SongMetadata(BaseModel):
def set_lyrics(self, lyrics: str): def set_lyrics(self, lyrics: str):
self.lyrics = lyrics self.lyrics = lyrics
async def get_cover(self, cover_format: str): async def get_cover(self, cover_format: str, cover_size: str):
self.cover = await get_cover(self.cover_url, cover_format) self.cover = await get_cover(self.cover_url, cover_format, cover_size)

@ -26,7 +26,7 @@ async def rip_song(song: Song, auth_params: GlobalAuthParams, codec: str, config
if not force_save and check_song_exists(song_metadata, config.download, codec): if not force_save and check_song_exists(song_metadata, config.download, codec):
logger.info(f"Song: {song_metadata.artist} - {song_metadata.title} already exists") logger.info(f"Song: {song_metadata.artist} - {song_metadata.title} already exists")
return return
await song_metadata.get_cover(config.download.coverFormat) await song_metadata.get_cover(config.download.coverFormat, config.download.coverSize)
if song_data.attributes.hasTimeSyncedLyrics: if song_data.attributes.hasTimeSyncedLyrics:
lyrics = await get_song_lyrics(song.id, song.storefront, auth_params.accountAccessToken, lyrics = await get_song_lyrics(song.id, song.storefront, auth_params.accountAccessToken,
auth_params.dsid, auth_params.accountToken, config.region.language) auth_params.dsid, auth_params.accountToken, config.region.language)

Loading…
Cancel
Save