go-torrent-helper/qubes/main.go

42 lines
888 B
Go
Raw Normal View History

2023-06-24 04:33:24 +02:00
package qubes
import (
"fmt"
"log"
"codeberg.org/hyperreal/go-torrent-helper/common"
"github.com/hekmon/transmissionrpc"
)
type Qubes struct {
NameSubstr string
Relver string
URL string
}
func (q Qubes) AddNewTorrents(transmissionbt *transmissionrpc.Client) error {
// Set torrentURLs for Qubes OS
q.URL = "https://mirrors.edge.kernel.org/qubes/iso/Qubes"
torrentURL := fmt.Sprintf("%s-%s-x86_64.torrent", q.URL, q.Relver)
// Add torrent to Transmission instance
torrent, err := transmissionbt.TorrentAdd(&transmissionrpc.TorrentAddPayload{
Filename: &torrentURL,
})
if err != nil {
return err
}
log.Printf("%s added\n", *torrent.Name)
return nil
}
func (q Qubes) RemoveOldTorrents(transmissionbt *transmissionrpc.Client) error {
if err := common.RemoveTorrents(q.NameSubstr, q.Relver, transmissionbt); err != nil {
return err
}
return nil
}