Last active
June 26, 2024 18:30
-
-
Save jayachandraoggy/d9f94240a2d83ee76961e66906313728 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"net/url" | |
"os" | |
"github.com/hekmon/transmissionrpc/v3" | |
) | |
func main() { | |
endpoint, err := url.Parse("http://transmission:transmission@127.0.0.1:9091/transmission/rpc") | |
if err != nil { | |
panic(err) | |
} | |
client, err := transmissionrpc.New(endpoint, nil) | |
if err != nil { | |
panic(err) | |
} | |
// fmt.Println(client.SessionStats(context.TODO())) | |
// fmt.Println(client.TorrentGetAll(context.TODO())) | |
// torrents, err := client.TorrentGet(context.TODO(), []string{"status"}, []int64{54, 55}) | |
// if err != nil { | |
// fmt.Fprintln(os.Stderr, err) | |
// } else { | |
// for _, torrent := range torrents { | |
// fmt.Println(torrent.Status) // the only instanciated field, as requested | |
// } | |
// } | |
freeSpace, totalSpace, err := client.FreeSpace(context.TODO(), "/var/lib/transmission-daemon/downloads") | |
if err != nil { | |
fmt.Fprintln(os.Stderr, err) | |
} else { | |
fmt.Printf("Free space: %s | %d | %v\n", freeSpace, freeSpace, freeSpace) | |
fmt.Printf("Total space: %s | %d | %v\n", totalSpace, totalSpace, totalSpace) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/transmission/transmission/tree/4.0.3/docs
https://github.com/transmission/transmission/blob/main/docs/Headless-Usage.md
http://127.0.0.1:9091/transmission/web/