files search added (wip)

This commit is contained in:
partisan 2024-05-23 10:56:26 +02:00
parent 585684f15b
commit 31460ee6be
13 changed files with 431 additions and 44 deletions

View file

@ -7,7 +7,6 @@ import (
"log"
"net/http"
"net/url"
"strconv"
"sync"
"time"
)
@ -163,20 +162,6 @@ func makeHTMLRequest(query string) (*VideoAPIResponse, error) {
return nil, fmt.Errorf("all instances failed, last error: %v", lastError)
}
func videoSearchEndpointHandler(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query().Get("q")
safe := r.URL.Query().Get("safe") // Assuming "safe" is a query parameter
lang := r.URL.Query().Get("lang") // Assuming "lang" is a query parameter
pageStr := r.URL.Query().Get("page")
page, err := strconv.Atoi(pageStr)
if err != nil {
// Handle error, perhaps set page to a default value if it's not critical
page = 1 // Default page
}
handleVideoSearch(w, query, safe, lang, page)
}
// handleVideoSearch adapted from the Python `videoResults`, handles video search requests
func handleVideoSearch(w http.ResponseWriter, query, safe, lang string, page int) {
start := time.Now()