mirror of
https://github.com/zhaarey/AppleMusicDecrypt.git
synced 2025-10-23 15:11:06 +00:00
feat: proxy and set song download parallelNum
This commit is contained in:
@@ -9,6 +9,8 @@ agentPort = 10020
|
|||||||
suMethod = "su -c"
|
suMethod = "su -c"
|
||||||
|
|
||||||
[download]
|
[download]
|
||||||
|
proxy = ""
|
||||||
|
parallelNum = 1
|
||||||
codecAlternative = true
|
codecAlternative = true
|
||||||
codecPriority = ["alac", "ec3", "ac3", "aac"]
|
codecPriority = ["alac", "ec3", "ac3", "aac"]
|
||||||
atmosConventToM4a = true
|
atmosConventToM4a = true
|
||||||
|
|||||||
14
src/api.py
14
src/api.py
@@ -10,11 +10,19 @@ from tenacity import retry, retry_if_exception_type, stop_after_attempt, before_
|
|||||||
|
|
||||||
from src.models import *
|
from src.models import *
|
||||||
|
|
||||||
client = httpx.AsyncClient()
|
client: httpx.AsyncClient
|
||||||
lock = asyncio.Semaphore(1)
|
lock: asyncio.Semaphore
|
||||||
user_agent_browser = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
|
user_agent_browser = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
|
||||||
user_agent_itunes = "iTunes/12.11.3 (Windows; Microsoft Windows 10 x64 Professional Edition (Build 19041); x64) AppleWebKit/7611.1022.4001.1 (dt:2)"
|
user_agent_itunes = "iTunes/12.11.3 (Windows; Microsoft Windows 10 x64 Professional Edition (Build 19041); x64) AppleWebKit/7611.1022.4001.1 (dt:2)"
|
||||||
user_agent_app = "Music/5.7 Android/10 model/Pixel6GR1YH build/1234 (dt:66)"
|
|
||||||
|
|
||||||
|
def init_client_and_lock(proxy: str, parallel_num: int):
|
||||||
|
global client, lock
|
||||||
|
if proxy:
|
||||||
|
client = httpx.AsyncClient(proxy=proxy)
|
||||||
|
else:
|
||||||
|
client = httpx.AsyncClient()
|
||||||
|
lock = asyncio.Semaphore(parallel_num)
|
||||||
|
|
||||||
|
|
||||||
@retry(retry=retry_if_exception_type((httpx.TimeoutException, httpcore.ConnectError, SSLError, FileNotFoundError)),
|
@retry(retry=retry_if_exception_type((httpx.TimeoutException, httpcore.ConnectError, SSLError, FileNotFoundError)),
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from prompt_toolkit import PromptSession, print_formatted_text, ANSI
|
|||||||
from prompt_toolkit.patch_stdout import patch_stdout
|
from prompt_toolkit.patch_stdout import patch_stdout
|
||||||
|
|
||||||
from src.adb import Device
|
from src.adb import Device
|
||||||
from src.api import get_token
|
from src.api import get_token, init_client_and_lock
|
||||||
from src.config import Config
|
from src.config import Config
|
||||||
from src.rip import rip_song, rip_album
|
from src.rip import rip_song, rip_album
|
||||||
from src.types import GlobalAuthParams
|
from src.types import GlobalAuthParams
|
||||||
@@ -30,6 +30,7 @@ class NewInteractiveShell:
|
|||||||
def __init__(self, loop: asyncio.AbstractEventLoop):
|
def __init__(self, loop: asyncio.AbstractEventLoop):
|
||||||
self.loop = loop
|
self.loop = loop
|
||||||
self.config = Config.load_from_config()
|
self.config = Config.load_from_config()
|
||||||
|
init_client_and_lock(self.config.download.proxy, self.config.download.parallelNum)
|
||||||
self.anonymous_access_token = loop.run_until_complete(get_token())
|
self.anonymous_access_token = loop.run_until_complete(get_token())
|
||||||
|
|
||||||
self.parser = argparse.ArgumentParser(exit_on_error=False)
|
self.parser = argparse.ArgumentParser(exit_on_error=False)
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ class Device(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class Download(BaseModel):
|
class Download(BaseModel):
|
||||||
|
proxy: str
|
||||||
|
parallelNum: int
|
||||||
codecAlternative: bool
|
codecAlternative: bool
|
||||||
codecPriority: list[str]
|
codecPriority: list[str]
|
||||||
atmosConventToM4a: bool
|
atmosConventToM4a: bool
|
||||||
|
|||||||
Reference in New Issue
Block a user