package internal import ( "bufio" "fmt" "os" "strings" "github.com/debridmediamanager/zurg/internal/clear" "github.com/debridmediamanager/zurg/internal/version" "github.com/debridmediamanager/zurg/pkg/http" "github.com/debridmediamanager/zurg/pkg/logutil" "github.com/debridmediamanager/zurg/pkg/utils" ) func ShowVersion() { fmt.Printf("zurg\nBuilt At: %s\nCommit: %s\nVersion: %s\n", version.GetBuiltAt(), version.GetGitCommit(), version.GetVersion()) } func NetworkTest(testURL string) { utils.EnsureDirExists("logs") utils.EnsureDirExists("data") log := logutil.NewLogger("logs/network-test.log") proxyURL := os.Getenv("PROXY") if proxyURL != "" { log.Infof("Using proxy: %s", proxyURL) } else { log.Info("You can set a proxy by setting the PROXY environment variable") } repoClient4 := http.NewHTTPClient("", 0, 1, false, []string{}, proxyURL, log.Named("network_test")) repoClient6 := http.NewHTTPClient("", 0, 1, true, []string{}, proxyURL, log.Named("network_test")) repo := http.NewIPRepository(repoClient4, repoClient6, testURL, log.Named("network_test")) repo.NetworkTest(true, true) } 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 }