This repository it's a wrapper for transmission RPC API
.
- torrent-start
- torrent-start-now
- torrent-stop
- torrent-verify
- torrent-reannounce
- torrent-set
- torrent-get
- torrent-add
- torrent-remove
- torrent-set-location
- torrent-rename-path
- session-close
- session-get
- session-set
- session-stats
- queue-move-top
- queue-move-up
- queue-move-down
- queue-move-bottom
- free-space
- port-test
- blocklist-update
For more information read spec file.
go get -u github.com/mfuentesg/transmission
Check connectivity with transmission service
package main
import (
"context"
"log"
"github.com/mfuentesg/transmission"
)
func main() {
client := transmission.New(
transmission.WithURL("http://service-url.com/tranmission/rpc"),
transmission.WithBasicAuth("username", "password"),
)
// this method is not part of the spec (it just check connectivity)
if err := client.Ping(context.Background()); err != nil {
log.Fatalf("could not connect to transmission service: %+v", err)
}
log.Println("connected to the transmission service")
}
Get list of torrents
package main
import (
"context"
"fmt"
"log"
"github.com/mfuentesg/transmission"
)
func main() {
client := transmission.New(
transmission.WithURL("http://service-url.com/tranmission/rpc"),
transmission.WithBasicAuth("username", "password"),
)
// get list of torrents
// For know more about the available fields, take a look to the below link
// https://github.com/transmission/transmission/blob/20119f006ca0f3a13245b379c74254c92f372910/extras/rpc-spec.txt#L111
torrents, err := client.TorrentGet(context.Background(), transmission.TorrentGet{
Ids: 17, // search by id, you can use hashString as well
Fields: []string{"id", "hashString"},
})
if err != nil {
log.Fatalf("could not get torrent list: %+v", err)
}
for _, torrent := range torrents {
fmt.Printf("torrent with id %d and hashString %s\n", torrent.ID, torrent.HashString)
}
}
- Improve README file
- Add documentation to each function and reference to transmission fields