{"id":16393010,"url":"https://github.com/yjl9903/naria2","last_synced_at":"2025-03-16T16:31:22.658Z","repository":{"id":180332667,"uuid":"664973251","full_name":"yjl9903/naria2","owner":"yjl9903","description":"Convenient BitTorrent Client based on the aria2 JSON-RPC","archived":false,"fork":false,"pushed_at":"2025-03-07T12:48:13.000Z","size":59576,"stargazers_count":21,"open_issues_count":4,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-07T15:01:57.916Z","etag":null,"topics":["animegarden","animespace","aria2","aria2-webui","aria2c","aria2c-rpc","browser","cli","node","torrent"],"latest_commit_sha":null,"homepage":"https://naria2.onekuma.cn/connect","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yjl9903.png","metadata":{"files":{"readme":"README.md","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},"funding":{"github":["yjl9903"]}},"created_at":"2023-07-11T06:54:57.000Z","updated_at":"2025-02-03T19:22:27.000Z","dependencies_parsed_at":"2023-12-28T14:25:18.873Z","dependency_job_id":"e5b7c3c4-ee7f-4667-81ad-3c4f171537f0","html_url":"https://github.com/yjl9903/naria2","commit_stats":{"total_commits":891,"total_committers":4,"mean_commits":222.75,"dds":0.3546576879910214,"last_synced_commit":"f74093278da6821b50184ce8b6a5705bd97bd9bd"},"previous_names":["yjl9903/naria2"],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjl9903%2Fnaria2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjl9903%2Fnaria2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjl9903%2Fnaria2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjl9903%2Fnaria2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yjl9903","download_url":"https://codeload.github.com/yjl9903/naria2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243597834,"owners_count":20316844,"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":["animegarden","animespace","aria2","aria2-webui","aria2c","aria2c-rpc","browser","cli","node","torrent"],"created_at":"2024-10-11T04:52:07.133Z","updated_at":"2025-03-16T16:31:17.628Z","avatar_url":"https://github.com/yjl9903.png","language":"TypeScript","funding_links":["https://github.com/sponsors/yjl9903"],"categories":[],"sub_categories":[],"readme":"# naria2\n\n[![version](https://img.shields.io/npm/v/naria2?label=naria2)](https://www.npmjs.com/package/naria2)\n[![version](https://img.shields.io/npm/v/naria2c?label=naria2c)](https://www.npmjs.com/package/naria2c)\n[![CI](https://github.com/yjl9903/naria2/actions/workflows/ci.yml/badge.svg)](https://github.com/yjl9903/naria2/actions/workflows/ci.yml)\n\nConvenient BitTorrent Client based on the [aria2 JSON RPC Interface](https://aria2.github.io/manual/en/html/aria2c.html#rpc-interface) and [aria2c](https://aria2.github.io/manual/en/html/aria2c.html#aria2c-1) CLI application with Web UI.\n\n+ Download aria2 prebuilt binary according to your architecture and platform\n+ Convenient BitTorrent downloading API\n+ Event bus used for watching progress, state change, error handling\n+ Vite plugin which helps you develop aria2 client application\n+ Web UI for aria2c and naria2c\n\n\u003e Introduction blog post [构建一个易用的 aria2 客户端包和 CLI 应用](https://blog.onekuma.cn/build-a-convenient-aria2-cli) in Chinese.\n\n![home](./assets/home.png)\n\n## Cross-platform aria2c\n\nIt is used in the same way as [aria2c](https://aria2.github.io/manual/en/html/aria2c.html#aria2c-1).\n\n```bash\n$ npm i -g naria2c\n\n$ naria2c --version\nnaria2c/0.0.26\n--------------\n...\n\n$ naria2c --help\n```\n\nYou can also launch a Web UI to manage aria2 using the `--ui` option. This feature is provided by this package, not the original aria2.\n\n```bash\n$ naria2c --ui\n...\n10/29 21:22:46 [NOTICE] WebUI is listening on the http://127.0.0.1:6801?port=6800\u0026secret=123456\n...\n```\n\n## Quickstart\n\n### Browser\n\n```bash\nnpm i naria2\n```\n\nUsing WebSocket:\n\n```ts\nimport { createClient } from 'naria2'\n\nconst client = await createClient(\n  new WebSocket('ws://localhost:6800/jsonrpc')\n)\n```\n\nUsing HTTP:\n\n```ts\nimport { createClient } from 'naria2'\nimport { createHTTP } from 'naria2/transport'\n\nconst client = await createClient(\n  createHTTP('http://localhost:6800/jsonrpc')\n)\n```\n\n### Node.js standalone\n\nIf you want to use naria2 in the Node.js standalone, you can install `@naria2/node`. It has included a [prebuilt aria2 binary](https://github.com/agalwood/Motrix/tree/master/extra) according to your architecture, so that there is no need to install a [aria2](https://github.com/aria2/aria2) on your own.\n\n```bash\nnpm i naria2 @naria2/node\n```\n\nYou can use the `createChildProcess` API to spawn an aria2 child process, and connect to it in WebScoket under the hood.\n\n```ts\nimport { createClient } from 'naria2'\nimport { createChildProcess } from '@naria2/node'\n\nconst client = await createClient(createChildProcess())\n```\n\n\u003e **Warning**\n\u003e\n\u003e You should **close the client on your own**, otherwise the aria2 process **may not be killed** even if your program finished or crashed.\n\u003e\n\u003e See [my blog post (in Chinese)](https://blog.onekuma.cn/death-of-a-node-process) or [The Death of a Node.js Process (in English)](https://thomashunter.name/posts/2021-03-08-the-death-of-a-nodejs-process) on how to handle the exit of a Node.js process.\n\n## Usage\n\n```ts\nimport { createClient } from 'naria2'\nimport { createChildProcess } from '@naria2/node'\n\n// Initialize a client\nconst client = await createClient(createChildProcess())\n\n// Start downloading a magnet\nconst torrent = await client.downloadUri('...')\n\n// Wait for torrent download finished\nawait torrent.watchTorrent(\n  // Watch metadata progress\n  (task) =\u003e {\n    console.log(`Downloading [MEATADATA]`)\n  },\n  // Watch torrent progress\n  (task) =\u003e {\n    console.log(`Downloading torrent`)\n  },\n  // Wait for the target event being fired\n  // 'bt-complete': downloading finished\n  // 'complete':    seeding finished\n  'bt-complete'\n)\n\n// Shutdown client\nawait client.shutdown()\n```\n\nYou can find detailed examples using Node.js here: [examples/magnet.mjs](https://github.com/yjl9903/naria2/blob/main/examples/magnet.mjs), [examples/torrent.mjs](https://github.com/yjl9903/naria2/blob/main/examples/torrent.mjs), [examples/http.mjs](https://github.com/yjl9903/naria2/blob/main/examples/http.mjs).\n\n\u003e Due to the implementation of [aria2](https://aria2.github.io/manual/en/html/index.html), the downloading progress of a magnet uri includes **two steps**:\n\u003e\n\u003e 1. Download the torrent metadata which contains a special file name with prefix `[METADATA]`;\n\u003e 2. Download the torrent content itself.\n\u003e\n\u003e So that, in the above code, the first callback is to wait for downloading metadata, and then the second callback is to wait for downloading the followed by task which is the torrent content itself.\n\n## Credits\n\n+ [aria2](https://github.com/aria2/aria2): A lightweight multi-protocol \u0026 multi-source, cross platform download utility operated in command-line\n+ [maria2](https://github.com/hydrati/maria2): Modern \u0026 Simple RPC Library for aria2c made by [@hydrati](https://github.com/hydrati)\n+ [aria2-static-builds](https://git.q3aql.dev/q3aql/aria2-static-builds) and [Motrix](https://github.com/agalwood/Motrix): Build aria2 binaries for different platforms\n\n## License\n\nMIT License © 2024 [XLor](https://github.com/yjl9903)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyjl9903%2Fnaria2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyjl9903%2Fnaria2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyjl9903%2Fnaria2/lists"}