Skip to content

Commit

Permalink
feat: m3u8api
Browse files Browse the repository at this point in the history
  • Loading branch information
WorldObservationLog committed May 6, 2024
1 parent fd78445 commit fc43a72
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
4 changes: 2 additions & 2 deletions src/rip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit fc43a72

Please sign in to comment.