go-torrent-helper/parrot/main.go

54 lines
1.7 KiB
Go
Raw Normal View History

2023-06-24 04:33:24 +02:00
package parrot
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 Parrot struct {
NameSubstr string
Relver string
URL string
}
func (p Parrot) AddNewTorrents(transmissionbt *transmissionrpc.Client) error {
// Set torrentURLs for Parrot Security
p.URL = "https://deb.parrot.sh/parrot/"
torrentURLs := []string{
fmt.Sprintf("%s/iso/%s/Parrot-security-%s_amd64.iso.torrent", p.URL, p.Relver, p.Relver),
fmt.Sprintf("%s/iso/%s/Parrot-security-%s_amd64.ova.torrent", p.URL, p.Relver, p.Relver),
fmt.Sprintf("%s/iso/%s/Parrot-security-%s_arm64.utm.torrent", p.URL, p.Relver, p.Relver),
fmt.Sprintf("%s/iso/%s/Parrot-home-%s_amd64.iso.torrent", p.URL, p.Relver, p.Relver),
fmt.Sprintf("%s/iso/%s/Parrot-home-%s_amd64.ova.torrent", p.URL, p.Relver, p.Relver),
fmt.Sprintf("%s/iso/%s/Parrot-home-%s_arm64.utm.torrent", p.URL, p.Relver, p.Relver),
fmt.Sprintf("%s/iso/%s/Parrot-htb-%s_amd64.iso.torrent", p.URL, p.Relver, p.Relver),
fmt.Sprintf("%s/iso/%s/Parrot-architect-%s_arm64.iso.torrent", p.URL, p.Relver, p.Relver),
fmt.Sprintf("%s/iso/%s/Parrot-architect-%s_amd64.iso.torrent", p.URL, p.Relver, p.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 (p Parrot) RemoveOldTorrents(transmissionbt *transmissionrpc.Client) error {
if err := common.RemoveTorrents(p.NameSubstr, p.Relver, transmissionbt); err != nil {
return err
}
return nil
}