aria2c的RPC接口中的aria2.addTorrent方法忽略了”dir”选项。

huangapple go评论69阅读模式
英文:

The aria2.addTorrent method in aria2c's RPC interface ignores "dir" option

问题

我正在服务器上将 aria2c 作为守护进程(RPC 接口)使用,并且当我使用 aria2.addTorrent 方法添加种子 + 指定的目录来下载文件时,aria2c 下载了文件,但不在我指定的目录中。

这是我运行守护进程的方式:

aria2c --log="the.log" --disable-ipv6 \
--enable-rpc --rpc-listen-all --rpc-listen-port=7777 \
--seed-time=0 --bt-tracker-connect-timeout=30 --bt-tracker-timeout=10

这是我本地发送给 aria2c 服务器的数据(以 JSON 格式):

{
	"jsonrpc":"2.0",
	"id":user_id,
	"method":"aria2.addTorrent",
	"params":[mfile_base64,[{"dir":outdir_str}]],
}

# user_id = 一些随机的用户名或 ID
# mfile_base64 = 元文件(.torrent 文件)的 Base64 编码内容
# outdir_str = 我希望文件下载到的目录

而且,文件确实被正确下载,但不在我想要的目录中:它被下载到了我的当前工作目录中。

如果有人问,我的读/写访问权限没有问题,下载开始之前目录已存在,它是一个普通的目录,不是挂载到另一个分区或任何其他网络资源上的挂载点等等。

编辑 1

# 我尝试了这个:
{
    "jsonrpc":"2.0",
    "id":user_id,
    "method":"aria2.addTorrent",
    "params":[mfile_base64,{"dir":outdir_str}],
}

# 但下载甚至不会开始,它会抛出一个错误,这是 JSON 响应:
{'id': 'user1', 'jsonrpc': '2.0', 'error': {'code': 1, 'message': 'The parameter at 1 has wrong type.'}}

希望这可以帮助你解决问题。

英文:

I am using aria2c as a daemon (the RPC interface) on a server, and when I use aria2.addTorrent method to add a torrent + a specific directory where the files have to be downloaded, aria2c downloads the file but not in the directory that I specified

This is how I am running the daemon:

aria2c --log="the.log" --disable-ipv6 \
--enable-rpc --rpc-listen-all --rpc-listen-port=7777 \
--seed-time=0 --bt-tracker-connect-timeout=30 --bt-tracker-timeout=10

And this is the data (as a JSON) that I am sending to the aria2c server locally:

{
	"jsonrpc":"2.0",
	"id":user_id,
	"method":"aria2.addTorrent",
	"params":[mfile_base64,[{"dir":outdir_str}]],
}

# user_id = Some random username or id
# mfile_base64 = Base64 encoded contents of the metafile (the .torrent file)
# outdir_str = The directory were I want the file(s) to be downloaded

And again, the file is downloaded correctly but not in the directory that I want: It is being downloaded in my Current Working Directory

And in case someone asks, my read/write access is fine, the directory exists before the download even starts, it is a normal directory, it's not a mountpoint to another partition or any other resource over a network, etc... etc... etc...

EDIT 1

# I tried this:
{
    "jsonrpc":"2.0",
    "id":user_id,
    "method":"aria2.addTorrent",
    "params":[mfile_base64,{"dir":outdir_str}],
}

# And the download does not even start, it throws an error, this is the JSON response:
{'id': 'user1', 'jsonrpc': '2.0', 'error': {'code': 1, 'message': 'The parameter at 1 has wrong type.'}}

答案1

得分: 0

已修复

在参数列表中缺少一个元素:URIs 列表
在我的情况下,我将其留空,因为我没有东西放在那里

{
    "jsonrpc": "2.0",
    "id": user_id,
    "method": "aria2.addTorrent",
    "params": [mfile_base64, [], { "dir": outdir_str }],
}

而且它有效:选项字典不再被忽略,因此文件被下载到我想要的目录中。

英文:

FIXED IT

There was a missing element in the params list: the URIs list
In my case, I left it empty since i got nothing to put in there

{
    "jsonrpc":"2.0",
    "id":user_id,
    "method":"aria2.addTorrent",
    "params":[mfile_base64,[],{"dir":outdir_str}],
}

And it works: the options dict is no longer ignored and therefore, the files are downloaded in the directory that I want

huangapple
  • 本文由 发表于 2023年7月11日 07:37:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76657914.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定