forked from qianlong520/Telegram_MistRelay
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasync_aria2_client.py
More file actions
63 lines (54 loc) · 1.58 KB
/
Copy pathasync_aria2_client.py
File metadata and controls
63 lines (54 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
Aria2异步客户端 - 向后兼容入口
此文件保留用于向后兼容,所有功能已迁移到 aria2_client 包中。
建议使用: from aria2_client import AsyncAria2Client
原始功能已拆分为以下模块:
- aria2_client.constants - 常量和配置
- aria2_client.utils - 工具函数
- aria2_client.download_handler - 下载事件处理
- aria2_client.upload_handler - 上传处理
- aria2_client.client - 核心客户端类
"""
import asyncio
from pprint import pprint
# 从新模块导入所有内容,保持向后兼容
from aria2_client import AsyncAria2Client
from aria2_client.constants import (
DOWNLOAD_PROGRESS_UPDATE_INTERVAL,
FILE_MODIFIED_TIME_WINDOW,
PROGRESS_UPDATE_FREQUENCY,
RCLONE_MAX_RETRIES,
RCLONE_RETRY_BASE_DELAY,
RCLONE_RETRY_EXTRA_DELAY,
PROCESS_TERMINATE_TIMEOUT,
upload_work_loads,
pyrogram_clients,
channel_accessible_clients,
logger
)
from aria2_client.utils import (
format_progress_bar,
format_upload_message,
parse_rclone_progress
)
from configer import RPC_URL, RPC_SECRET
# 导出所有公共接口
__all__ = [
'AsyncAria2Client',
'format_progress_bar',
'format_upload_message',
'parse_rclone_progress',
]
async def main():
"""测试主函数"""
client = AsyncAria2Client(RPC_SECRET, f'ws://{RPC_URL}', None)
await client.connect()
result = await client.get_global_option()
pprint(result)
if __name__ == '__main__':
loop = asyncio.get_event_loop()
try:
loop.create_task(main())
loop.run_forever()
except KeyboardInterrupt:
pass