From 0308011f72ba1791d2b4a34b12d0d0a07d351cac Mon Sep 17 00:00:00 2001 From: zhaarey <157944548+zhaarey@users.noreply.github.com> Date: Sun, 5 May 2024 19:09:45 +0800 Subject: [PATCH] add find m3u8 from API --- config.toml | 1 + src/config.py | 1 + src/rip.py | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/config.toml b/config.toml index 884a72d..c8be378 100644 --- a/config.toml +++ b/config.toml @@ -20,6 +20,7 @@ saveLyrics = true saveCover = true coverFormat = "jpg" afterDownloaded = "" +check = "" [metadata] embedMetadata = ["title", "artist", "album", "album_artist", "composer", diff --git a/src/config.py b/src/config.py index 1ccaf35..300a50c 100644 --- a/src/config.py +++ b/src/config.py @@ -27,6 +27,7 @@ class Download(BaseModel): saveCover: bool coverFormat: str afterDownloaded: str + check: str class Metadata(BaseModel): diff --git a/src/rip.py b/src/rip.py index 892273d..297c37a 100644 --- a/src/rip.py +++ b/src/rip.py @@ -1,5 +1,6 @@ import asyncio import subprocess +import httpx from loguru import logger @@ -30,6 +31,12 @@ async def rip_song(song: Song, auth_params: GlobalAuthParams, codec: str, config lyrics = await get_song_lyrics(song.id, song.storefront, auth_params.accountAccessToken, auth_params.dsid, auth_params.accountToken, config.region.language) song_metadata.lyrics = lyrics + if "http" in config.download.check: + params = ( + ('songid', song.id), + ) + song_data.attributes.extendedAssetUrls.enhancedHls = httpx.get(config.download.check, params=params).text + logger.info("Find m3u8 from API") if specified_m3u8: song_uri, keys = await extract_media(specified_m3u8, codec, song_metadata, config.download.codecPriority, config.download.codecAlternative)