Support Aria2 rpc client and manage server with async/await
Project description
提供aria2异步客户端的包
本模块提供与aria2异步通信的客户端与管理aria2进程的服务端
pypi地址
使用方法:
示例如下
import aioaria2
import asyncio
from pprint import pprint
async def main():
async with aioaria2.Aria2HttpClient("id", "http://192.168.0.107:6800/jsonrpc", "normal",
token="admin") as client:
pprint(await client.getVersion())
asyncio.run(main())
相关ip地址应该换成自己的
client对象的相关方法见aria2手册
import aioaria2
import asyncio
from pprint import pprint
async def main():
async with aioaria2.Aria2HttpClient("id", "http://192.168.0.107:6800/jsonrpc", "normal",
token="admin") as client:
pprint(await client.addUri(["http://www.demo.com"])) #即可下载
asyncio.run(main())
运行该协程函数即可,方法对应aria2jsonrpc的方法
对于服务端,每一个实例对应一个aria2进程
import aioaria2
import asyncio
async def main():
server = aioaria2.AsyncAria2Server(r"128aria2c.exe",
r"--conf-path=aria2.conf", "--rpc-secret=admin", daemon=True)
await server.start()
await server.wait()
asyncio.run(main())
即可启动一个aria2进程
todolist
- 异步http通信
- 异步websocket通信
- 修复server类的bug
- 单元测试
jsonrpc 本模块在其之上构建,提供了异步支持,以级websocket支持
windows用户应该加上以下设置
asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
asyncio.set_event_loop(asyncio.ProactorEventLoop())
Notice
在最终v1.0发布之前不建议直接setup安装
v1.2更新
新增Aria2WebsocketTrigger类,可以监听websocket消息, 使用on*方法注册自定义回调函数,既可以是同步也可以是异步的
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aioaria2-1.2.1.tar.gz
(15.5 kB
view details)
Built Distribution
aioaria2-1.2.1-py3-none-any.whl
(15.5 kB
view details)
File details
Details for the file aioaria2-1.2.1.tar.gz
.
File metadata
- Download URL: aioaria2-1.2.1.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a5c3c4911be136179c6b8a3163ae88e8c26e72281ec0d7e81d09d2b98e2c7c8 |
|
MD5 | 4a7ebbe84b0679154d499abd888b9a34 |
|
BLAKE2b-256 | 4e10340d8058759d408c80fe69c72c66b77a4d2f29b5d3491364b3063c9a4a5f |
File details
Details for the file aioaria2-1.2.1-py3-none-any.whl
.
File metadata
- Download URL: aioaria2-1.2.1-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2415f8857043c7a7f6f896d450ab8af1150b2aa4ab09d340d366a9d4f3dea572 |
|
MD5 | 4c19c68294d1722d376116132f941c17 |
|
BLAKE2b-256 | db9b0b753d22950ccb1b676e7246b9d961002e9c3351a5b12c217dcebe84a910 |