diff --git a/src/api.py b/src/api.py index aa12001..df37607 100644 --- a/src/api.py +++ b/src/api.py @@ -27,7 +27,10 @@ def init_client_and_lock(proxy: str, parallel_num: int): async def get_m3u8_from_api(endpoint: str, song_id: str) -> str: - return (await client.get(endpoint, params={"songid": song_id})).text + resp = (await client.get(endpoint, params={"songid": song_id})).text + if resp == "no_found": + return "" + return resp @retry(retry=retry_if_exception_type((httpx.TimeoutException, httpcore.ConnectError, SSLError, FileNotFoundError)), diff --git a/src/rip.py b/src/rip.py index 7c67c0a..fecdccc 100644 --- a/src/rip.py +++ b/src/rip.py @@ -32,9 +32,9 @@ async def rip_song(song: Song, auth_params: GlobalAuthParams, codec: str, config song_metadata.lyrics = lyrics if config.m3u8Api.enable and codec == Codec.ALAC: m3u8_url = await get_m3u8_from_api(config.m3u8Api.endpoint, song.id) - if "m3u8" in m3u8_url: + if m3u8_url: specified_m3u8 = m3u8_url - logger.info("Use m3u8 from API") + logger.info(f"Use m3u8 from API for song: {song_metadata.artist} - {song_metadata.title}") if specified_m3u8: song_uri, keys = await extract_media(specified_m3u8, codec, song_metadata, config.download.codecPriority, config.download.codecAlternative)