From eb6764538b44d875cddd38b6230ef4a89fba13aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Majdand=C5=BEi=C4=87?= Date: Tue, 18 Jun 2024 18:09:28 +0200 Subject: [PATCH] Rework DL to use new endpoint --- dl/dl.go | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/dl/dl.go b/dl/dl.go index 9018e9b..14e61eb 100644 --- a/dl/dl.go +++ b/dl/dl.go @@ -11,28 +11,12 @@ import ( "sync" ) -const POCKETBASE_URL = `https://pocketbase-scratch.site.quack-lab.dev/api/collections` -const POCKETBASE_REALTIME = `https://pocketbase-scratch.site.quack-lab.dev/api/realtime` -const COLLECTION_NAME = "youtubedownload" -const FULL_URL = POCKETBASE_URL + "/" + COLLECTION_NAME + "/records" +const URL = `https://youtube-download-ws-server.site.quack-lab.dev/download` type Item struct { Link string `json:"link"` } -type APIError struct { - Code int `json:"code"` - Message string `json:"message"` - Data APIErrorData `json:"data"` -} -type APIErrorData struct { - Link APIErrorLink `json:"link"` -} -type APIErrorLink struct { - Code string `json:"code"` - Message string `json:"message"` -} - var wg sync.WaitGroup func main() { @@ -49,7 +33,7 @@ func main() { func Download(url string) { defer wg.Done() - req, err := http.NewRequestWithContext(context.Background(), "POST", FULL_URL, nil) + req, err := http.NewRequestWithContext(context.Background(), "POST", URL, nil) if err != nil { log.Printf("Error creating POST request: %++v", err) return @@ -82,14 +66,6 @@ func Download(url string) { log.Printf("Error reading response body: %++v", err) return } - var data APIError - err = json.Unmarshal(body, &data) - if err != nil { - log.Printf("Error unmarshaling JSON: %++v", err) - return - } - - log.Printf("API error: %++v", data) return } else { log.Printf("Enqueued %s", url)