Open jvacek opened 4 years ago
rtorrent already exposes an API over XML-RPC which is what Flood uses. Adding something like this into Flood seems redundant?
rtorrent's XML-RPC API talks SCGI, which is not widely supported and difficult to query.
As far as I know it would be impossible to write a userscript that talks directly to this API because you need to be able to open a socket and immediately send SCGI headers instead of an HTTP request line.
Even in a command-line environment, if rtorrent is in daemon mode without pyrocore and you just need to send a command to it and correctly receive the response, I think the quickest way to do that currently is to go find somebody's toy SCGI client library and write some code against it to send a hand-crafted XML-RPC request.
In order for a client to talk to rtorrent (or any SCGI server) easily you really need to be running a server that accepts HTTP requests and proxies them as SCGI requests. ngx_http_scgi_module does this for nginx, and mod_proxy_scgi does this for apache. But since Flood is already running, and already understands SCGI and connects to rtorrent, it seems duplicative to run a separate server. It would definitely be convenient to be able to curl a Flood endpoint and be able to write a userscript that does the same thing from the browser. I think @jvacek's suggestion is a good idea, provided the feature is disabled by default and Flood just transliterates JSON requests directly into rtorrent API calls rather than inventing its own API.
(By the way, ruTorrent basically already provides this feature as a plugin. The API is undocumented but it looks like among the logic coupled to their frontend is a code path that lets you pass commands directly through to rtorrent. I'd personally rather not use ruTorrent though, because I like Flood better and running them both simultaneously against the one rtorrent socket seems to break rtorrent somehow.)
Flood API is well documented with inline comments and TypeScript types. Additionally, Flood now guarantees API backward compatibility, per conventions of Sematic Versioning. Please try the latest version of Flood.
For instance, /api/torrents/add-urls: https://github.com/jesec/flood/blob/2c747d771ea66dbe8c906e1eb1904f4a801d052f/server/routes/api/torrents.ts#L108-L116
Feel free to close the issue if it is no longer relevant.
Type: Feature Request
Summary
It would be nice to interact with flood using a Restful API. This way you could directly add torrents via plugins or userscripts, could make a mobile client for Android/iOS, basically whatever.
Idea of implementation
I'm not coming from a JS background but it seems a pcakage like this could essentially implement this functionality quite well. https://www.npmjs.com/package/express-nedb-rest.