feat: m3u8api

pull/8/head
WorldObservationLog 5 months ago
parent fd78445967
commit fc43a72ebf
  1. 5
      src/api.py
  2. 4
      src/rip.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)),

@ -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)

Loading…
Cancel
Save