mirror of
https://github.com/zhaarey/AppleMusicDecrypt.git
synced 2025-10-23 15:11:06 +00:00
feat: m3u8api
This commit is contained in:
@@ -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:
|
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)),
|
@retry(retry=retry_if_exception_type((httpx.TimeoutException, httpcore.ConnectError, SSLError, FileNotFoundError)),
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ async def rip_song(song: Song, auth_params: GlobalAuthParams, codec: str, config
|
|||||||
song_metadata.lyrics = lyrics
|
song_metadata.lyrics = lyrics
|
||||||
if config.m3u8Api.enable and codec == Codec.ALAC:
|
if config.m3u8Api.enable and codec == Codec.ALAC:
|
||||||
m3u8_url = await get_m3u8_from_api(config.m3u8Api.endpoint, song.id)
|
m3u8_url = await get_m3u8_from_api(config.m3u8Api.endpoint, song.id)
|
||||||
if "m3u8" in m3u8_url:
|
if m3u8_url:
|
||||||
specified_m3u8 = 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:
|
if specified_m3u8:
|
||||||
song_uri, keys = await extract_media(specified_m3u8, codec, song_metadata,
|
song_uri, keys = await extract_media(specified_m3u8, codec, song_metadata,
|
||||||
config.download.codecPriority, config.download.codecAlternative)
|
config.download.codecPriority, config.download.codecAlternative)
|
||||||
|
|||||||
Reference in New Issue
Block a user