mirror of
https://github.com/NoCLin/LightMirrors
synced 2025-08-06 02:01: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
|
caddy/caddy_data
|
||||||
.idea
|
.idea
|
||||||
.env
|
.env
|
||||||
node_modules
|
node_modules
|
||||||
**/__pycache__
|
|
@ -1,10 +1,9 @@
|
|||||||
services:
|
services:
|
||||||
lightmirrors:
|
lightmirrors:
|
||||||
image: lightmirrors/mirrors
|
image: lightmirrors/mirrors
|
||||||
build:
|
build: ./mirrors
|
||||||
context: ./src
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./src/:/app
|
- ./mirrors:/app
|
||||||
- ./data/cache:/app/cache
|
- ./data/cache:/app/cache
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
@ -46,5 +45,4 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
app:
|
app:
|
||||||
name: lightmirrors_app
|
|
||||||
driver: bridge
|
driver: bridge
|
@ -1,7 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import uuid
|
import uuid
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
@ -34,20 +33,18 @@ async def send_request(method, params=None):
|
|||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
||||||
async def add_download(
|
async def add_download(url, save_dir="/app/cache", out_file=None):
|
||||||
url, save_dir="/app/cache", out_file=None, headers: Optional[dict] = None
|
logger.info(f"[Aria2] add_download {url=} {save_dir=} {out_file=}")
|
||||||
):
|
|
||||||
logger.info(f"[Aria2] add_download {url=} {save_dir=} {out_file=} {headers=}")
|
|
||||||
|
|
||||||
method = "aria2.addUri"
|
method = "aria2.addUri"
|
||||||
options = {
|
options = {
|
||||||
"dir": save_dir,
|
"dir": save_dir,
|
||||||
|
"header": [],
|
||||||
|
"out": out_file,
|
||||||
}
|
}
|
||||||
|
|
||||||
if out_file:
|
if out_file:
|
||||||
options["out"] = out_file
|
options["out"] = out_file
|
||||||
if headers:
|
|
||||||
options["header"] = [f"{k}: {v}" for k, v in headers.items()]
|
|
||||||
|
|
||||||
params = [[url], options]
|
params = [[url], options]
|
||||||
response = await send_request(method, params)
|
response = await send_request(method, params)
|
||||||
|
@ -100,11 +100,6 @@ async def try_file_based_cache(
|
|||||||
processed_url,
|
processed_url,
|
||||||
save_dir=cache_file_dir,
|
save_dir=cache_file_dir,
|
||||||
out_file=os.path.basename(cache_file),
|
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:
|
except Exception as e:
|
||||||
logger.error(f"Download error, return 500 for {target_url}", exc_info=e)
|
logger.error(f"Download error, return 500 for {target_url}", exc_info=e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user