https://github.com/mfuentesg/transmission
transmission torrent wrapper written in go
https://github.com/mfuentesg/transmission
golang rpc transmission transmission-rpc
Last synced: 9 months ago
JSON representation
transmission torrent wrapper written in go
- Host: GitHub
- URL: https://github.com/mfuentesg/transmission
- Owner: mfuentesg
- License: mit
- Created: 2020-03-21T20:17:02.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-05-30T02:55:19.000Z (almost 5 years ago)
- Last Synced: 2024-05-01T14:42:24.245Z (almost 2 years ago)
- Topics: golang, rpc, transmission, transmission-rpc
- Language: Go
- Homepage:
- Size: 154 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# transmission




This repository it's a wrapper for [`transmission RPC API`](https://github.com/transmission/transmission/blob/master/extras/rpc-spec.txt).
## Available methods
- [x] torrent-start
- [x] torrent-start-now
- [x] torrent-stop
- [x] torrent-verify
- [x] torrent-reannounce
- [x] torrent-set
- [x] torrent-get
- [x] torrent-add
- [x] torrent-remove
- [x] torrent-set-location
- [x] torrent-rename-path
- [x] session-close
- [x] session-get
- [x] session-set
- [x] session-stats
- [x] queue-move-top
- [x] queue-move-up
- [x] queue-move-down
- [x] queue-move-bottom
- [x] free-space
- [x] port-test
- [x] blocklist-update
For more information read [spec file](https://github.com/transmission/transmission/blob/master/extras/rpc-spec.txt).
## Installation
```bash
go get -u github.com/mfuentesg/transmission
```
## Examples
> Check connectivity with transmission service
```go
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
```go
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)
}
}
```
## TODO
- [ ] Improve README file
- [ ] Add documentation to each function and reference to transmission fields