aioaria2


Nameaioaria2 JSON
Version 1.2.2 PyPI version JSON
download
home_page
SummarySupport Aria2 rpc client and manage server with async/await
upload_time2020-09-16 05:59:21
maintainerv-vinson
docs_urlNone
author['帝国皇家近卫军', 'synodriver']
requires_python>=3.6
licenseGPLv3
keywords asyncio aria2
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            提供aria2异步客户端的包
===

# 本模块提供与aria2异步通信的客户端与管理aria2进程的服务端
### [pypi地址](https://pypi.org/project/aioaria2/)
## 使用方法:
### 示例如下
```python
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手册 
```python
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进程
```python
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进程
[参考选项及设置](http://aria2.github.io/manual/en/html/)
### todolist
- [x] 异步http通信
- [x] 异步websocket通信
- [x] 修复server类的bug
- [ ] 单元测试


[jsonrpc](https://xyne.archlinux.ca/projects/python3-aria2jsonrpc)
        本模块在其之上构建,提供了异步支持,以级websocket支持

### windows用户应该加上以下设置     
```
asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
asyncio.set_event_loop(asyncio.ProactorEventLoop())
```
#### Notice
##### 在最终v1.0发布之前不建议直接setup安装

#### v1.2更新
新增Aria2WebsocketTrigger类,可以监听websocket消息,
使用on*方法注册自定义回调函数,既可以是同步也可以是异步的

如下
```
@trigger.onDownloadStart
async def onDownloadStart(trigger, future):
    print("下载开始{0}".format(future.result()))
```



![title](https://konachan.com/sample/c7f565c0cd96e58908bc852dd754f61a/Konachan.com%20-%20302356%20sample.jpg)


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "aioaria2",
    "maintainer": "v-vinson",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "asyncio,Aria2",
    "author": "['\u5e1d\u56fd\u7687\u5bb6\u8fd1\u536b\u519b', 'synodriver']",
    "author_email": "diguohuangjiajinweijun@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e9/22/65f41d28e6b61e6f8494cb90713da192a1c938ae2bba86da0bae682e798d/aioaria2-1.2.2.tar.gz",
    "platform": "",
    "description": "\u63d0\u4f9baria2\u5f02\u6b65\u5ba2\u6237\u7aef\u7684\u5305\n===\n\n# \u672c\u6a21\u5757\u63d0\u4f9b\u4e0earia2\u5f02\u6b65\u901a\u4fe1\u7684\u5ba2\u6237\u7aef\u4e0e\u7ba1\u7406aria2\u8fdb\u7a0b\u7684\u670d\u52a1\u7aef\n### [pypi\u5730\u5740](https://pypi.org/project/aioaria2/)\n## \u4f7f\u7528\u65b9\u6cd5\uff1a\n### \u793a\u4f8b\u5982\u4e0b\n```python\nimport aioaria2\nimport asyncio\nfrom pprint import pprint\nasync def main():\n    async with aioaria2.Aria2HttpClient(\"id\", \"http://192.168.0.107:6800/jsonrpc\", \"normal\",\n                                        token=\"admin\") as client:\n        pprint(await client.getVersion())\nasyncio.run(main())\n```\n### \u76f8\u5173ip\u5730\u5740\u5e94\u8be5\u6362\u6210\u81ea\u5df1\u7684 \n### client\u5bf9\u8c61\u7684\u76f8\u5173\u65b9\u6cd5\u89c1aria2\u624b\u518c \n```python\nimport aioaria2\nimport asyncio\nfrom pprint import pprint\nasync def main():\n    async with aioaria2.Aria2HttpClient(\"id\", \"http://192.168.0.107:6800/jsonrpc\", \"normal\",\n                                        token=\"admin\") as client:\n        pprint(await client.addUri([\"http://www.demo.com\"])) #\u5373\u53ef\u4e0b\u8f7d\nasyncio.run(main())\n```\n    \u8fd0\u884c\u8be5\u534f\u7a0b\u51fd\u6570\u5373\u53ef\uff0c\u65b9\u6cd5\u5bf9\u5e94aria2jsonrpc\u7684\u65b9\u6cd5\n    \u5bf9\u4e8e\u670d\u52a1\u7aef\uff0c\u6bcf\u4e00\u4e2a\u5b9e\u4f8b\u5bf9\u5e94\u4e00\u4e2aaria2\u8fdb\u7a0b\n```python\nimport aioaria2\nimport asyncio\nasync def main():\n    server = aioaria2.AsyncAria2Server(r\"128aria2c.exe\",\n                                       r\"--conf-path=aria2.conf\", \"--rpc-secret=admin\", daemon=True)\n    await server.start()\n    await server.wait()\nasyncio.run(main())\n```\n#### \u5373\u53ef\u542f\u52a8\u4e00\u4e2aaria2\u8fdb\u7a0b\n[\u53c2\u8003\u9009\u9879\u53ca\u8bbe\u7f6e](http://aria2.github.io/manual/en/html/)\n### todolist\n- [x] \u5f02\u6b65http\u901a\u4fe1\n- [x] \u5f02\u6b65websocket\u901a\u4fe1\n- [x] \u4fee\u590dserver\u7c7b\u7684bug\n- [ ] \u5355\u5143\u6d4b\u8bd5\n\n\n[jsonrpc](https://xyne.archlinux.ca/projects/python3-aria2jsonrpc)\n        \u672c\u6a21\u5757\u5728\u5176\u4e4b\u4e0a\u6784\u5efa\uff0c\u63d0\u4f9b\u4e86\u5f02\u6b65\u652f\u6301\uff0c\u4ee5\u7ea7websocket\u652f\u6301\n\n### windows\u7528\u6237\u5e94\u8be5\u52a0\u4e0a\u4ee5\u4e0b\u8bbe\u7f6e     \n```\nasyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())\nasyncio.set_event_loop(asyncio.ProactorEventLoop())\n```\n#### Notice\n##### \u5728\u6700\u7ec8v1.0\u53d1\u5e03\u4e4b\u524d\u4e0d\u5efa\u8bae\u76f4\u63a5setup\u5b89\u88c5\n\n#### v1.2\u66f4\u65b0\n\u65b0\u589eAria2WebsocketTrigger\u7c7b\uff0c\u53ef\u4ee5\u76d1\u542cwebsocket\u6d88\u606f,\n\u4f7f\u7528on*\u65b9\u6cd5\u6ce8\u518c\u81ea\u5b9a\u4e49\u56de\u8c03\u51fd\u6570,\u65e2\u53ef\u4ee5\u662f\u540c\u6b65\u4e5f\u53ef\u4ee5\u662f\u5f02\u6b65\u7684\n\n\u5982\u4e0b\n```\n@trigger.onDownloadStart\nasync def onDownloadStart(trigger, future):\n    print(\"\u4e0b\u8f7d\u5f00\u59cb{0}\".format(future.result()))\n```\n\n\n\n![title](https://konachan.com/sample/c7f565c0cd96e58908bc852dd754f61a/Konachan.com%20-%20302356%20sample.jpg)\n\n",
    "bugtrack_url": null,
    "license": "GPLv3",
    "summary": "Support Aria2 rpc client and manage server with async/await",
    "version": "1.2.2",
    "split_keywords": [
        "asyncio",
        "aria2"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "b0fef46014b05d2e069ae4140c7eb5dc",
                "sha256": "7c33ead6c938cc5c6e47d310464661697c1065401b7eee5f6210acd9a0fdebf7"
            },
            "downloads": -1,
            "filename": "aioaria2-1.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b0fef46014b05d2e069ae4140c7eb5dc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 15343,
            "upload_time": "2020-09-16T05:59:09",
            "upload_time_iso_8601": "2020-09-16T05:59:09.974602Z",
            "url": "https://files.pythonhosted.org/packages/b4/5d/05ad086f164c06d2901323a1b390023d417b74bc5d344f844aa62cbb1e86/aioaria2-1.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "ee05826d20912b926c603c3a49264550",
                "sha256": "503f501221659d44749a5f0368534ab25e6e1c144c2b9750757e009bb71b3b7b"
            },
            "downloads": -1,
            "filename": "aioaria2-1.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "ee05826d20912b926c603c3a49264550",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 15368,
            "upload_time": "2020-09-16T05:59:21",
            "upload_time_iso_8601": "2020-09-16T05:59:21.806419Z",
            "url": "https://files.pythonhosted.org/packages/e9/22/65f41d28e6b61e6f8494cb90713da192a1c938ae2bba86da0bae682e798d/aioaria2-1.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-09-16 05:59:21",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "aioaria2"
}
        
Elapsed time: 0.19503s