package internal import ( "bufio" "fmt" "os" "strings" "time" "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() { utils.EnsureDirExists("logs") utils.EnsureDirExists("data") dateStr := time.Now().Format(time.DateOnly) timeStr := strings.ReplaceAll(time.Now().Format(time.TimeOnly), ":", "-") logPath := fmt.Sprintf("logs/network-test-%s-%s.log", dateStr, timeStr) log := logutil.NewLogger(logPath) proxyURL := os.Getenv("PROXY") 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, log.Named("network_test")) repo.NetworkTest(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 }