Add clear downloads and clear torrents command
This commit is contained in:
46
internal/commands.go
Normal file
46
internal/commands.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user