Initial commit: LookingWeb project
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import requests
|
||||
from loguru import logger
|
||||
|
||||
def download_by_seed(seed_info):
|
||||
url = "http://192.168.123.199:6800/jsonrpc"
|
||||
payload = {
|
||||
"jsonrpc": "2.0",
|
||||
"method": "aria2.addUri",
|
||||
"id": "QXJpYU5nXzE3MTczMTQ0NjBfMC41Nzc4ODU5Mjc2NjQ2MzE4",
|
||||
"params": [
|
||||
"token:guoxy5157",
|
||||
[seed_info.seedUrl],
|
||||
{}
|
||||
]
|
||||
}
|
||||
|
||||
logger.debug("开始向 Aria2 发送请求,种子URL: {}", seed_info.seedUrl)
|
||||
|
||||
try:
|
||||
response = requests.post(url, json=payload)
|
||||
|
||||
if response.status_code == 200:
|
||||
logger.info("请求成功,种子 {} 已添加至下载队列", seed_info.seedUrl)
|
||||
return "1"
|
||||
else:
|
||||
logger.warning("请求返回非200状态码,种子 {} 添加失败。状态码: {}", seed_info.seedUrl, response.status_code)
|
||||
return "-1" # 请求成功,但失败了
|
||||
except Exception as e:
|
||||
logger.error("请求过程中出现异常,种子 {} 添加失败。错误信息: {}", seed_info.seedUrl, str(e))
|
||||
return "0" # 请求过程中发生异常
|
||||
Reference in New Issue
Block a user