Skip to content

Commit

Permalink
Merge pull request #8 from bling0390/master
Browse files Browse the repository at this point in the history
feat: 支持离线下载任务
  • Loading branch information
z-mio authored May 18, 2024
2 parents 25ff1d5 + 1f8b720 commit 8c9c7fd
Show file tree
Hide file tree
Showing 5 changed files with 413 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- [x] Alist配置备份&定时备份
- [x] Alist图床
- [x] 随机推荐
- [x] 离线下载



Expand Down Expand Up @@ -355,6 +356,7 @@ EOF
/bc - 备份Alist配置
/sbt - 设置定时备份
/sr - 随机推荐设置
/od - 离线下载
/help - 查看帮助
```

Expand Down
36 changes: 36 additions & 0 deletions api/alist_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,39 @@ async def get_driver():
url = f"{alist_host}/api/admin/driver/list"
header = {"Authorization": alist_token}
return await AListAPI._send_request("GET", url, headers=header)

# 获取离线下载工具
@staticmethod
async def get_offline_download_tools():
url = f"{alist_host}/api/public/offline_download_tools"
header = {"Authorization": alist_token}
return await AListAPI._send_request("GET", url, headers=header)

# 离线下载
@staticmethod
async def offline_download(urls, tool, path, delete_policy):
url = f"{alist_host}/api/fs/add_offline_download"
header = {"Authorization": alist_token}
body = {"delete_policy": delete_policy, "path": path, "tool": tool, "urls": urls}
return await AListAPI._send_request("POST", url, headers=header, json=body)

# 获取离线下载未完成任务
@staticmethod
async def get_offline_download_undone_task():
url = f"{alist_host}/api/admin/task/offline_download/undone"
header = {"Authorization": alist_token}
return await AListAPI._send_request("GET", url, headers=header)

# 获取离线下载已完成任务
@staticmethod
async def get_offline_download_done_task():
url = f"{alist_host}/api/admin/task/offline_download/done"
header = {"Authorization": alist_token}
return await AListAPI._send_request("GET", url, headers=header)

# 清空离线下载已完成任务(包含成功/失败)
@staticmethod
async def clear_offline_download_done_task():
url = f"{alist_host}/api/admin/task/offline_download/clear_done"
header = {"Authorization": alist_token}
return await AListAPI._send_request("POST", url, headers=header)
1 change: 1 addition & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ async def menu(_, message: Message):
BotCommand(command="bc", description="备份Alist配置"),
BotCommand(command="sbt", description="设置定时备份"),
BotCommand(command="sr", description="随机推荐设置"),
BotCommand(command="od", description="离线下载"),
BotCommand(command="help", description="查看帮助"),
]

Expand Down
Loading

0 comments on commit 8c9c7fd

Please sign in to comment.