{"id":16217233,"url":"https://github.com/synodriver/aioaria2","last_synced_at":"2025-07-02T03:05:12.200Z","repository":{"id":39919268,"uuid":"266386137","full_name":"synodriver/aioaria2","owner":"synodriver","description":"An async/await wrapper around aria2-json-rpc with websocket support","archived":false,"fork":false,"pushed_at":"2025-03-01T08:27:49.000Z","size":206,"stargazers_count":34,"open_issues_count":2,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-24T02:41:35.888Z","etag":null,"topics":["aria2","async","asyncio","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/synodriver.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-05-23T17:28:44.000Z","updated_at":"2025-06-05T08:55:48.000Z","dependencies_parsed_at":"2025-01-03T05:21:41.537Z","dependency_job_id":"46b9655c-395d-4aca-b277-2fdf1da8b1b7","html_url":"https://github.com/synodriver/aioaria2","commit_stats":{"total_commits":53,"total_committers":3,"mean_commits":"17.666666666666668","dds":"0.24528301886792447","last_synced_commit":"c4c3dbf64fe47c67f452e08d6290c97f30b694b2"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/synodriver/aioaria2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synodriver%2Faioaria2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synodriver%2Faioaria2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synodriver%2Faioaria2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synodriver%2Faioaria2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/synodriver","download_url":"https://codeload.github.com/synodriver/aioaria2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synodriver%2Faioaria2/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263066557,"owners_count":23408387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aria2","async","asyncio","python"],"created_at":"2024-10-10T11:26:12.561Z","updated_at":"2025-07-02T03:05:12.148Z","avatar_url":"https://github.com/synodriver.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aioaria2\n\n\n[![pypi](https://img.shields.io/pypi/v/aioaria2.svg)](https://pypi.org/project/aioaria2/)\n![python](https://img.shields.io/pypi/pyversions/aioaria2)\n![implementation](https://img.shields.io/pypi/implementation/aioaria2)\n![wheel](https://img.shields.io/pypi/wheel/aioaria2)\n![license](https://img.shields.io/github/license/synodriver/aioaria2.svg)\n\n## Support async rpc call with aria2 and process management\n\n## Usage:\n\n### example\n\n```python\nimport asyncio\nfrom pprint import pprint\n\nimport aioaria2\n\n\nasync def main():\n    async with aioaria2.Aria2HttpClient(\"http://117.0.0.1:6800/jsonrpc\",\n                                        token=\"token\") as client:\n        pprint(await client.getVersion())\n\n\nasyncio.run(main())\n```\n\n### The ip address should be replaced with your own\n\n### See [aria2 manual](http://aria2.github.io/manual/en/html/) for more detail about client methods\n\n```python\n# exampe of http\nimport asyncio\nfrom pprint import pprint\n\nimport aioaria2\nimport ujson\n\n\nasync def main():\n    async with aioaria2.Aria2HttpClient(\"http://127.0.0.1:6800/jsonrpc\",\n                                        token=\"token\",\n                                        loads=ujson.loads,\n                                        dumps=ujson.dumps) as client:\n        pprint(await client.addUri([\"http://www.demo.com\"]))  # that would start downloading\n\n\nasyncio.run(main())\n```\n\n```python\n# exampe of websocket\nimport asyncio\nfrom pprint import pprint\n\nimport aioaria2\nimport ujson\n\n\n@aioaria2.run_sync\ndef on_download_complete(trigger, data):\n    print(f\"downlaod complete {data}\")\n\n\nasync def main():\n    client: aioaria2.Aria2WebsocketClient = await aioaria2.Aria2WebsocketClient.new(\"http://127.0.0.1:6800/jsonrpc\",\n                                                                                      token=\"token\",\n                                                                                      loads=ujson.loads,\n                                                                                      dumps=ujson.dumps)\n    client.onDownloadComplete(on_download_complete)\n    pprint(await client.addUri([\"http://www.demo.com\"]))\n\n\nloop = asyncio.get_event_loop()\nloop.create_task(main())\nloop.run_forever()\n```\n\n- Run that coroutine function and each method represent an aria2-rpc call. As for server, each instance represent an aria2 process.\n\n```python\nimport aioaria2\nimport asyncio\n\n\nasync def main():\n    server = aioaria2.AsyncAria2Server(r\"aria2c.exe\",\n                                       r\"--conf-path=aria2.conf\", \"--rpc-secret=admin\", daemon=True)\n    await server.start()\n    await server.wait()\n\n\nasyncio.run(main())\n```\n\n#### this start an aria2 process\n\n[Aria2 Manual](http://aria2.github.io/manual/en/html/)\n\n### todolist\n\n- [x] async http\n- [x] async websocket\n- [x] async process management\n- [x] unitest\n\nThis module is built on top of [aria2jsonrpc](https://xyne.archlinux.ca/projects/python3-aria2jsonrpc)\nwith async and websocket support.\n\n### For windows users, you should\n\n```\n# for start async aria2 process\nasyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())\nasyncio.set_event_loop(asyncio.ProactorEventLoop())\n```\n\nFor python version greater than 3.8, asyncio uses ProactorEventLoop by default, so there is no need to modify\n\n#### v1.2.0\n\nnew Aria2WebsocketTrigger class for websocket events, use on* methods to add callbacks\n\nLike\n\n```\n@trigger.onDownloadStart\nasync def onDownloadStart(trigger, future):\n    print(\"下载开始{0}\".format(future.result()))\n```\n\n#### v1.2.3\n\nNow you can add multiple callbacks for one event ,must be coroutine function or an async callable, use ```aioaria2.run_sync``` to wrap a sync function\n\n```\n@trigger.onDownloadStart\nasync def callback1(trigger, future):\n    print(\"第一个回调{0}\".format(future.result()))\n\n@trigger.onDownloadStart\n@run_sync\ndef callback2(trigger, future):\n    print(\"第二个回调{0}\".format(future.result()))\n```\n\n#### v1.3.0\n\n* Big changes for class```Aria2WebsocketTrigger```\n\n* Callbacks now accept```dict```as second parameter instead of```asyncio.Future```\n* methods of class```Aria2WebsocketTrigger``` now have same return value as ```Aria2HttpClient```\n* ```id``` parameter now accept a callable as idfactory to generate uuid, otherwise default uuid factory is used.\n\n\n```\n@trigger.onDownloadStart\nasync def callback1(trigger, data:dict):\n    print(\"第一个回调{0}\".format(data))\n\n@trigger.onDownloadStart\n@run_sync\ndef callback2(trigger, data:dict):\n    print(\"第二个回调{0}\".format(data))\n```\n\n### v1.3.1\n\n* custom json library with keyword arguments ```loads``` ```dumps```\n\n### v1.3.2\n\n* fix  unclosed client_session when exception occurs during ws_connect\n* alias for ```Aria2WebsocketTrigger```,named ```Aria2WebsocketClient```\n\n### v1.3.3\n\n* fix method problems in client\n\n### v1.3.4rc1\n\n* handle reconnect simply\n* handle InvalidstateError while trying to ping aria2\n\n### v1.3.4\n\n* add async id factory support\n* allow unregister callbacks in websocketclient\n* add contextvars support in ```run_sync```\n\n### v1.3.5rc1\n\n* graceful shutdown\n\n### v1.3.5rc2\n\n* add parser for aria2 files\n\n```python\nfrom pprint import pprint\nfrom aioaria2 import DHTFile\n\npprint(DHTFile.from_file2(\"dht.dat\"))\n```\n\n### v1.3.5rc3\n\n* add strong ref to pending tasks\n\n### v1.3.6\n\n* update latest aiohttp version","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynodriver%2Faioaria2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsynodriver%2Faioaria2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynodriver%2Faioaria2/lists"}