Add clear downloads and clear torrents command

This commit is contained in:
Ben Sarmiento
2024-01-08 12:30:38 +01:00
parent 62de3723c1
commit b1116dfcca
6 changed files with 171 additions and 20 deletions

46
internal/commands.go Normal file
View File

@@ -0,0 +1,46 @@
package internal
import (
"bufio"
"fmt"
"os"
"strings"
"github.com/debridmediamanager/zurg/internal/clear"
"github.com/debridmediamanager/zurg/internal/version"
"github.com/debridmediamanager/zurg/pkg/realdebrid"
)
func ShowVersion() {
fmt.Printf("zurg\nBuilt At: %s\nCommit: %s\nVersion: %s\n",
version.GetBuiltAt(), version.GetGitCommit(), version.GetVersion())
}
func NetworkTest() {
realdebrid.RunTest()
}
func ClearDownloads() {
authCode := getAuthCode()
clear.ClearDownloads(authCode)
}
func ClearTorrents() {
authCode := getAuthCode()
clear.ClearTorrents(authCode)
}
func getAuthCode() string {
fmt.Println("Warning: This will clear all downloads in your account. This cannot be undone.")
fmt.Println("To continue, please enter your auth code. You can find this by logging into your Real-Debrid account, opening the developer console, and running the following javascript code:")
fmt.Println()
fmt.Println(" alert(document.cookie.match(/auth=([^;]+)/)?.[1]||'')")
fmt.Println()
reader := bufio.NewReader(os.Stdin)
fmt.Print("Enter auth code: ")
authCode, _ := reader.ReadString('\n')
authCode = strings.TrimSpace(authCode) // Remove newline character
return authCode
}