mirror of
https://codeberg.org/hyperreal/go-torrent-helper
synced 2024-11-01 16:53:09 +01:00
Add support for Tails
This commit is contained in:
parent
d77638cba1
commit
5580a859a2
46
tails/main.go
Normal file
46
tails/main.go
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
package tails
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"git.sr.ht/~hyperreal/go-torrent-helper/common"
|
||||||
|
"github.com/hekmon/transmissionrpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Tails struct {
|
||||||
|
NameSubstr string
|
||||||
|
Relver string
|
||||||
|
URL string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t Tails) AddNewTorrents(transmissionbt *transmissionrpc.Client) error {
|
||||||
|
// Set torrentURLs for Tails mirror
|
||||||
|
t.URL = "https://tails.net/torrents/files/"
|
||||||
|
torrentURLs := []string{
|
||||||
|
fmt.Sprintf("%s/tails-amd64-%s.img.torrent", t.URL, t.Relver),
|
||||||
|
fmt.Sprintf("%s/tails-amd64-%s.iso.torrent", t.URL, t.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 (t Tails) RemoveOldTorrents(transmissionbt *transmissionrpc.Client) error {
|
||||||
|
if err := common.RemoveTorrents(t.NameSubstr, t.Relver, transmissionbt); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user