2023-06-24 04:33:24 +02:00
|
|
|
package qubes
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
|
2023-07-02 22:12:46 +02:00
|
|
|
"tildegit.org/hyperreal/go-torrent-helper/common"
|
2023-06-24 04:33:24 +02:00
|
|
|
"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
|
|
|
|
}
|