mirror of
https://github.com/NoCLin/LightMirrors
synced 2025-08-05 17:51:33 +08:00
Compare commits
No commits in common. "1bc250d33c14c651540e06f8d6265a0745192cd1" and "09f4eae6df12f3133b67921ad0b00bbeb4a3dc08" have entirely different histories.
1bc250d33c
...
09f4eae6df
3
.gitignore
vendored
3
.gitignore
vendored
@ -4,5 +4,4 @@ data/*
|
||||
caddy/caddy_data
|
||||
.idea
|
||||
.env
|
||||
node_modules
|
||||
**/__pycache__
|
||||
node_modules
|
@ -1,10 +1,9 @@
|
||||
services:
|
||||
lightmirrors:
|
||||
image: lightmirrors/mirrors
|
||||
build:
|
||||
context: ./src
|
||||
build: ./mirrors
|
||||
volumes:
|
||||
- ./src/:/app
|
||||
- ./mirrors:/app
|
||||
- ./data/cache:/app/cache
|
||||
env_file:
|
||||
- .env
|
||||
@ -46,5 +45,4 @@ services:
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
app:
|
||||
name: lightmirrors_app
|
||||
driver: bridge
|
@ -1,7 +1,6 @@
|
||||
import json
|
||||
import logging
|
||||
import uuid
|
||||
from typing import Optional
|
||||
|
||||
import httpx
|
||||
|
||||
@ -34,20 +33,18 @@ async def send_request(method, params=None):
|
||||
raise e
|
||||
|
||||
|
||||
async def add_download(
|
||||
url, save_dir="/app/cache", out_file=None, headers: Optional[dict] = None
|
||||
):
|
||||
logger.info(f"[Aria2] add_download {url=} {save_dir=} {out_file=} {headers=}")
|
||||
async def add_download(url, save_dir="/app/cache", out_file=None):
|
||||
logger.info(f"[Aria2] add_download {url=} {save_dir=} {out_file=}")
|
||||
|
||||
method = "aria2.addUri"
|
||||
options = {
|
||||
"dir": save_dir,
|
||||
"header": [],
|
||||
"out": out_file,
|
||||
}
|
||||
|
||||
if out_file:
|
||||
options["out"] = out_file
|
||||
if headers:
|
||||
options["header"] = [f"{k}: {v}" for k, v in headers.items()]
|
||||
|
||||
params = [[url], options]
|
||||
response = await send_request(method, params)
|
||||
|
@ -100,11 +100,6 @@ async def try_file_based_cache(
|
||||
processed_url,
|
||||
save_dir=cache_file_dir,
|
||||
out_file=os.path.basename(cache_file),
|
||||
headers={
|
||||
key: value
|
||||
for key, value in request.headers.items()
|
||||
if key in ["user-agent", "accept", "authorization"]
|
||||
},
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Download error, return 500 for {target_url}", exc_info=e)
|
||||
|
Loading…
x
Reference in New Issue
Block a user