洪水 
安装
npm install @ctrl/deluge
要求节点.js 24或更新.
使用
import { Deluge } from '@ctrl/deluge';
const client = new Deluge({
baseUrl: 'http://localhost:8112/',
password: 'deluge',
});
async function main() {
const res = await client.getAllData();
console.log(res);
}
API 密码
文档 : https://deluge.ep.works.dev 互联网档案馆的存檔,存档日期2013-12-22
Deluge API 文档 : https://deluge.readthedocs.io/en/latest/参考文献/api.html
与其他客户不同的事情:
- 支持 Deluge 2.x 软件
label需要 Dleuge 标签插件, 启用它client.enablePlugin('Label')设置标签失败- 标签设置
normalizedAddTorrent需要几秒钟才能出现结果
规范化 API
这些职能通过 @ ctrl/ 共享调用,这使得支持多个 torrent客户端更加容易. 见 下级 用于支持种子客户端.
获取全部数据
返回所有种子数据和一系列标签对象。 数据已经正常化, 不符合本地输出 listTorrents()。 。 。 .
const data = await client.getAllData();
console.log(data.torrents);
获取Torrent
从种子散列返回一个种子数据h
const data = await client.getTorrent('torrent-hash');
console.log(data);
暂停 Torrent 并恢复 Torrent
暂停或恢复一个或多个种子
await client.pauseTorrent('torrent-hash');
await client.resumeTorrent(['torrent-hash', 'other-torrent-hash']);
删除Torrent
删除一个或多个种子, 如果种子不存在则丢出 。 不默认删除磁盘上的数据 .
// does not remove data on disk
await client.removeTorrent('torrent-hash', false);
// remove data on disk
await client.removeTorrent(['torrent-hash', 'other-torrent-hash'], true);
上下队列
上下移动种子队列
await client.queueUp('torrent-hash');
await client.queueDown('torrent-hash');
添加托伦特
从磁铁链接或种子文件中添加种子, 有客户端特定选项 。 另见已规范的Add-Torrent
import { readFileSync } from 'node:fs';
const result = await client.addTorrent(new Uint8Array(readFileSync('./linux.torrent')));
console.log(result);
已正常化 添加托伦特
添加 torrent并返回已归正的 torrent 数据, 可以启动已暂停的 torrent并添加标签
const result = await client.normalizedAddTorrent('magnet:?xt=urn:btih:...', {
startPaused: false,
label: 'linux',
});
console.log(result);
错误
请求抛出失败 TorrentClientError 从 @ ctrl/ 共享调用 带有 code 联 合 国 torrent_not_found, (中文(简体) ), unauthorized, (中文(简体) ), request_failed 或者说 client_error,该网址 status 当有一个, 原始错误作为 cause。 。 。 .
import { TorrentClientError } from '@ctrl/deluge';
try {
await client.getTorrent('torrent-hash');
} catch (error) {
if (error instanceof TorrentClientError && error.code === 'torrent_not_found') {
// not in the client
}
}
从国家导出并创建
如果您经常关闭服务器( 无服务器 ) , 您可以导出状态
const state = client.exportState();
const restored = Deluge.createFromState(config, state);
另见
以下 npm 模块都提供相同的正态函数,同时为每个客户端支持独特的apis.
- 共享类型 - @ ctrl/ 共享调用
- 传输 - @ctrl/ 转发
- 克比特伦特 - @ ctrl/ qbittorrent (中文(简体) )
- 餐饮 @ ctrl/ 用户
- 特伦特 - @ ctrl/ 特伦特
- 克比特语 - @ ctrl/ rqbit
Usenet 客户端采用相同的常态化方法:
- 用户网共享类型 - @ctrl/ 共享用户网
- nzbget - (英语) @ ctrl/ nzbget (英语)
- 萨布兹布德 - @ctrl/sabnzbd (英语)
启动一个测试嵌入容器
docker run -d \
--name=deluge \
-e PUID=1000 \
-e PGID=1000 \
-e TZ=Etc/UTC \
-e DELUGE_LOGLEVEL=error `#optional` \
-p 8112:8112 \
-p 6881:6881 \
-p 6881:6881/udp \
--restart unless-stopped \
lscr.io/linuxserver/deluge:latest