Transmission RPC Client for Racket
This library provides a simple Transmission RPC client for Racket.
To install this library from github:
$ raco pkg install git://github.com/danielfm/transmission-rpc-client
To import the library:
In the next example, we'll send a
session-stats request and fetch the current
number of active torrents.
;; First, create a session that points to the desired Transmission RPC endpoint (define url "http://localhost:9091/transmission/rpc") (define session (transmission-session url)) ;; Returns a jsexpr with current session stats (define stats (transmission-request! session "session-stats" null)) ;; Retrieves a specific response argument (transmission-response-arg stats 'torrentCount)
And here's how we get the progress of all active torrents along with their name:
;; Sends a request with tag number = 1234 (define progress (transmission-request! session "torrent-get" (hash 'fields '("name" "percentDone")) 1234)) ;; Returns a list where each entry is a hash containing the keys ;; 'name (string) and 'percentDone (number 0 < n < 1) (define torrents (transmission-response-arg progress 'torrents)) ;; Fetches the first torrent's progress (hash-ref (first torrents) 'percentDone) ;; The response tag number should match the one sent in the request (1234) (transmission-response-tag progress)
Please read the Transmission RFC spec to know the supported requests, their parameters and response.
Copyright (C) Daniel Martins
Distributed under the New BSD License. See LICENSE for further details.