libre-man / cl-transmission

A Common Lisp library to interface with transmission using its rpc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CL-Transmission

Usage

Loading

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.

Searching

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))
:NAMEdebian-8.7.1-amd64-DVD-1.iso:ID72:ETA1368

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

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.

Others

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.

Author

  • Thomas Schaper (Thomas@libremail.nl)

Copyright

Copyright (c) 2017 Thomas Schaper (Thomas@libremail.nl)

About

A Common Lisp library to interface with transmission using its rpc

License:MIT License


Languages

Language:Common Lisp 100.0%