go-torrent-helper/devuan/main.go

47 lines
1007 B
Go
Raw Normal View History

2023-12-11 09:03:48 +01:00
package devuan
import (
"fmt"
"log"
2024-03-30 06:23:56 +01:00
"codeberg.org/hyperreal/go-torrent-helper/common"
2023-12-11 09:03:48 +01:00
"github.com/hekmon/transmissionrpc"
)
type Devuan struct {
NameSubstr string
Relver string
URL string
}
func (d Devuan) AddNewTorrents(transmissionbt *transmissionrpc.Client) error {
// Set torrentURLs for Devuan GNU+Linux mirror
// https://files.devuan.org/devuan_daedalus.torrent
d.URL = "https://files.devuan.org/devuan"
torrentURLs := []string{
fmt.Sprintf("%s_%s.torrent", d.URL, d.Relver),
}
// Add torrents to Transmission instance
for _, torrentURL := range torrentURLs {
torrent, err := transmissionbt.TorrentAdd(&transmissionrpc.TorrentAddPayload{
Filename: &torrentURL,
})
if err != nil {
return err
}
log.Printf("%s added\n", *torrent.Name)
}
return nil
}
func (d Devuan) RemoveOldTorrents(transmissionbt *transmissionrpc.Client) error {
if err := common.RemoveTorrents(d.NameSubstr, d.Relver, transmissionbt); err != nil {
return err
}
return nil
}