47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
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(testType string) {
|
|
realdebrid.RunTest(testType)
|
|
}
|
|
|
|
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
|
|
}
|