mirror of
https://codeberg.org/hyperreal/go-torrent-helper
synced 2024-11-01 16:53:09 +01:00
Add Kali; update repo url
This commit is contained in:
parent
aeccf8d7c2
commit
ef98499aa9
@ -11,7 +11,7 @@ export TRANSMISSION_RPC_URL=10.0.0.42
|
||||
Install with Go:
|
||||
|
||||
``` bash
|
||||
go install git.sr.ht/~hyperreal/go-torrent-helper@latest
|
||||
go install git.hyperreal.coffee/go-torrent-helper@latest
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
31
README.org
31
README.org
@ -1,31 +0,0 @@
|
||||
* go-torrent-helper
|
||||
|
||||
This is a helper program to add and remove torrents from a transmission-daemon instance.
|
||||
|
||||
To use, make sure `TRANSMISSION_RPC_URL` is exported in the shell:
|
||||
#+begin_src shell
|
||||
export TRANSMISSION_RPC_URL=10.0.0.42
|
||||
#+end_src
|
||||
|
||||
Install with Go:
|
||||
#+begin_src shell
|
||||
go install git.sr.ht/~hyperreal/go-torrent-helper@latest
|
||||
#+end_src
|
||||
|
||||
Example usage:
|
||||
#+begin_src shell
|
||||
# Add Fedora torrents
|
||||
go-torrent-helper add -distro fedora -relver 38
|
||||
|
||||
# Remove NixOS torrents
|
||||
go-torrent-helper remove -distro nixos
|
||||
|
||||
# Add Rocky Linux torrents
|
||||
go-torrent-helper add -distro rocky -relver 9.2
|
||||
|
||||
# Remove older Rocky Linux torrents
|
||||
go-torrent-helper remove -distro rocky -relver 8.1
|
||||
|
||||
# If not -relver flag is supplied for the remove subcommand, remove all torrents for given distro
|
||||
go-torrent-helper remove -distro debian
|
||||
#+end_src
|
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/common"
|
||||
"git.hyperreal.coffee/go-torrent-helper/common"
|
||||
"github.com/hekmon/transmissionrpc"
|
||||
)
|
||||
|
||||
|
@ -6,16 +6,17 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/almalinux"
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/debian"
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/devuan"
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/fedora"
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/freebsd"
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/nixos"
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/parrot"
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/qubes"
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/rocky"
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/tails"
|
||||
"git.hyperreal.coffee/go-torrent-helper/almalinux"
|
||||
"git.hyperreal.coffee/go-torrent-helper/debian"
|
||||
"git.hyperreal.coffee/go-torrent-helper/devuan"
|
||||
"git.hyperreal.coffee/go-torrent-helper/fedora"
|
||||
"git.hyperreal.coffee/go-torrent-helper/freebsd"
|
||||
"git.hyperreal.coffee/go-torrent-helper/kali"
|
||||
"git.hyperreal.coffee/go-torrent-helper/nixos"
|
||||
"git.hyperreal.coffee/go-torrent-helper/parrot"
|
||||
"git.hyperreal.coffee/go-torrent-helper/qubes"
|
||||
"git.hyperreal.coffee/go-torrent-helper/rocky"
|
||||
"git.hyperreal.coffee/go-torrent-helper/tails"
|
||||
"github.com/hekmon/transmissionrpc"
|
||||
)
|
||||
|
||||
@ -131,6 +132,7 @@ func (l *ListCmd) Run(d Distro) error {
|
||||
"devuan",
|
||||
"fedora",
|
||||
"freebsd",
|
||||
"kali",
|
||||
"nixos",
|
||||
"parrot",
|
||||
"qubes",
|
||||
@ -211,6 +213,10 @@ func Root(args []string) error {
|
||||
fb := &freebsd.FreeBSD{NameSubstr: "FreeBSD", Relver: relver}
|
||||
return cmd.Run(fb)
|
||||
|
||||
case "kali":
|
||||
k := &kali.Kali{NameSubstr: "kali-linux", Relver: relver}
|
||||
return cmd.Run(k)
|
||||
|
||||
case "nixos":
|
||||
n := &nixos.Nixos{NameSubstr: "nixos"}
|
||||
return cmd.Run(n)
|
||||
|
2
debian/main.go
vendored
2
debian/main.go
vendored
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/common"
|
||||
"git.hyperreal.coffee/go-torrent-helper/common"
|
||||
"github.com/hekmon/transmissionrpc"
|
||||
)
|
||||
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/common"
|
||||
"git.hyperreal.coffee/go-torrent-helper/common"
|
||||
"github.com/hekmon/transmissionrpc"
|
||||
)
|
||||
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/common"
|
||||
"git.hyperreal.coffee/go-torrent-helper/common"
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/hekmon/transmissionrpc"
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/common"
|
||||
"git.hyperreal.coffee/go-torrent-helper/common"
|
||||
"github.com/hekmon/transmissionrpc"
|
||||
)
|
||||
|
||||
|
2
go.mod
2
go.mod
@ -1,4 +1,4 @@
|
||||
module git.sr.ht/~hyperreal/go-torrent-helper
|
||||
module git.hyperreal.coffee/go-torrent-helper
|
||||
|
||||
go 1.20
|
||||
|
||||
|
62
kali/main.go
Normal file
62
kali/main.go
Normal file
@ -0,0 +1,62 @@
|
||||
package kali
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"git.hyperreal.coffee/go-torrent-helper/common"
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/hekmon/transmissionrpc"
|
||||
)
|
||||
|
||||
type Kali struct {
|
||||
NameSubstr string
|
||||
Relver string
|
||||
URL string
|
||||
}
|
||||
|
||||
func (k Kali) AddNewTorrents(transmissionbt *transmissionrpc.Client) error {
|
||||
// Send HTTP GET request and receive response
|
||||
k.URL = fmt.Sprintf("https://cdimage.kali.org/kali-%s/", k.Relver)
|
||||
respBody, err := common.GetResponse(k.URL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Get a goquery doc from response body
|
||||
doc, err := goquery.NewDocumentFromReader(respBody)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Extract torrent URLs from web page source
|
||||
var torrentURLs []string
|
||||
doc.Find("a").Each(func(i int, s *goquery.Selection) {
|
||||
if strings.Contains(s.Text(), ".torrent") {
|
||||
torrentURLs = append(torrentURLs, fmt.Sprintf("%s/kali-linux-%s-%s.torrent", k.URL, k.Relver, s.Text()))
|
||||
}
|
||||
})
|
||||
|
||||
// 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 (k Kali) RemoveOldTorrents(transmissionbt *transmissionrpc.Client) error {
|
||||
if err := common.RemoveTorrents(k.NameSubstr, k.Relver, transmissionbt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
2
main.go
2
main.go
@ -4,7 +4,7 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/command"
|
||||
"git.hyperreal.coffee/go-torrent-helper/command"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/common"
|
||||
"git.hyperreal.coffee/go-torrent-helper/common"
|
||||
"github.com/hekmon/transmissionrpc"
|
||||
)
|
||||
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/common"
|
||||
"git.hyperreal.coffee/go-torrent-helper/common"
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/hekmon/transmissionrpc"
|
||||
)
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/common"
|
||||
"git.hyperreal.coffee/go-torrent-helper/common"
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/hekmon/transmissionrpc"
|
||||
)
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/common"
|
||||
"git.hyperreal.coffee/go-torrent-helper/common"
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/hekmon/transmissionrpc"
|
||||
)
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"git.sr.ht/~hyperreal/go-torrent-helper/common"
|
||||
"git.hyperreal.coffee/go-torrent-helper/common"
|
||||
"github.com/hekmon/transmissionrpc"
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user