mirror of
https://codeberg.org/hyperreal/go-torrent-helper
synced 2024-11-01 16:53:09 +01:00
42 lines
888 B
Go
42 lines
888 B
Go
|
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
|
||
|
}
|