From 49446c412055c44cb8086e79c1a5de853e8d7bc9 Mon Sep 17 00:00:00 2001 From: Al Beano Date: Tue, 30 May 2017 17:45:30 +0100 Subject: [PATCH] make torrent files --- magic.json.default | 3 ++- wimp-get.go | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/magic.json.default b/magic.json.default index 1417214..b013af2 100644 --- a/magic.json.default +++ b/magic.json.default @@ -1,5 +1,6 @@ { "sessionId" : "insert", "ffmpeg" : "ffmpeg", - "sox" : "sox" + "sox" : "sox", + "mktorrent" : "mktorrent" } diff --git a/wimp-get.go b/wimp-get.go index d7fb147..3cfc47a 100644 --- a/wimp-get.go +++ b/wimp-get.go @@ -203,4 +203,29 @@ func main() { println("SpecZoom.png written") } } + + // Make .torrent file + choice = "" + for !(choice == "y" || choice == "n") { + print("Create .torrent file? [y/n] ") + fmt.Scanln(&choice) + choice = strings.TrimRight(choice, "\n") + } + + if choice == "y" { + print("Announce URL: ") + var announce string + fmt.Scanln(&announce) + announce = strings.TrimRight(announce, "\n") + + torrent := exec.Command(magic["mktorrent"].(string), "-l", "20", "-a", announce, dirName) + e = torrent.Run() + if e != nil { + println("Error creating .torrent file!") + } else { + fmt.Printf("%s.torrent created\n", dirName) + } + } + + println("All done, exiting") }