feat: proxy and set song download parallelNum

pull/1/head
WorldObservationLog 5 months ago
parent 5213e77f2b
commit 69e67fefd2
  1. 2
      config.toml
  2. 14
      src/api.py
  3. 3
      src/cmd.py
  4. 2
      src/config.py

@ -9,6 +9,8 @@ agentPort = 10020
suMethod = "su -c"
[download]
proxy = ""
parallelNum = 1
codecAlternative = true
codecPriority = ["alac", "ec3", "ac3", "aac"]
atmosConventToM4a = true

@ -10,11 +10,19 @@ from tenacity import retry, retry_if_exception_type, stop_after_attempt, before_
from src.models import *
client = httpx.AsyncClient()
lock = asyncio.Semaphore(1)
client: httpx.AsyncClient
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_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)),

@ -9,7 +9,7 @@ from prompt_toolkit import PromptSession, print_formatted_text, ANSI
from prompt_toolkit.patch_stdout import patch_stdout
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.rip import rip_song, rip_album
from src.types import GlobalAuthParams
@ -30,6 +30,7 @@ class NewInteractiveShell:
def __init__(self, loop: asyncio.AbstractEventLoop):
self.loop = loop
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.parser = argparse.ArgumentParser(exit_on_error=False)

@ -16,6 +16,8 @@ class Device(BaseModel):
class Download(BaseModel):
proxy: str
parallelNum: int
codecAlternative: bool
codecPriority: list[str]
atmosConventToM4a: bool

Loading…
Cancel
Save