Lets start by loading CL-TRANSMISSION
and defining our connection. Connections
are thread-safe in the way that you can use a one or more connection in multiple
threads.
(ql:quickload :cl-transmission)
(defvar *conn* (make-instance 'cl-transmission:transmission-connection
:host "your.ip" ;; the host is "localhost" by default.
:credentials '("libreman" "super-secret-password")))
*CONN*
Please note that this package is not (yet) in Quicklisp so you will have to add it to your local projects to be able to load it. See the Quicklisp FAQ on how to do this.
So lets get some torrents. First lets get all torrents and of every torrent get
the id, name and eta. This is done by using the
CL-TRANSMISSION:TRANSMISSION-GET
method.
(cl-transmission:transmission-get *conn* #(:name :id :eta) :strict t)
(#<HASH-TABLE :TEST EQUAL :COUNT 3 {1014218D23}> #<HASH-TABLE :TEST EQUAL :COUNT 3 {10142193B3}> #<HASH-TABLE :TEST EQUAL :COUNT 3 {1014241C83}>) NIL
As shown for every live torrent a hash-table is returned. So lets see how it is structured:
(alexandria:hash-table-plist
(elt (cl-transmission:transmission-get *conn* #(:name :id :eta) :strict t)
0))
:NAME | debian-8.7.1-amd64-DVD-1.iso | :ID | 72 | :ETA | 1368 |
So it simply contains the fields we specified. Searching is done by or passing a id, if you know it this is the fastest way, or mapping over the return value.
Adding torrents is done by the CL-TRANSMISSION:TRANSMISSION-ADD
function. It accepts a :FILENAME
argument which should be a filename
to a torrent file or a magnet link, and :METAINFO
which should be a
base64-encoded torrent file.
So lets say we want to add a nice debian torrent to seed:
(cl-transmission:transmission-add *conn* :filename "http://cdimage.debian.org/debian-cd/current/amd64/bt-dvd/debian-8.7.1-amd64-DVD-2.iso.torrent")
#<HASH-TABLE :TEST EQUAL :COUNT 3 {10174B6333}> :TORRENT-ADDED
We get a hash-table of our new torrent with an ID
, NAME
and HASH-STRING
,
and the second return value is indicating this is a new torrent. So if we would
add the same torrent again this would be :TORRENT-DUPLICATE
.
At the moment the entire section 3 of the RPC spec is implemented. Simply see the exported method and their docstrings. Development is active and section 4 will be implemented.
- Thomas Schaper ([email protected])
Copyright (c) 2017 Thomas Schaper ([email protected])