package clear import ( "fmt" "io" "net/http" "strings" "time" ) func ClearTorrents(authCode string) { for { req, err := http.NewRequest(http.MethodGet, "https://real-debrid.com/torrents?del-all=1&p=1", nil) if err != nil { fmt.Println("Error creating request:", err) return } // Set the necessary headers req.Header.Set("Cookie", "auth="+authCode+"; lang=en; https=1") req.Header.Set("TE", "trailers") resp, err := http.DefaultClient.Do(req) if err != nil { fmt.Println("Error sending request:", err) return } body, err := io.ReadAll(resp.Body) if err != nil { fmt.Println("Error reading response body:", err) return } resp.Body.Close() responseBody := string(body) // Check if "login.php" is in the response if strings.Contains(responseBody, "login.php") { fmt.Println("Error: The auth code is invalid.") return } // Condition to break the loop if !strings.Contains(responseBody, "p=1&del=") { break } fmt.Println("Clearing torrents...") time.Sleep(time.Millisecond * 100) // Adding delay to avoid overwhelming the server } fmt.Println("Torrents cleared.") }