imported tmdb module

This commit is contained in:
2026-01-01 20:42:50 +11:00
parent c466cd3163
commit c4574e32c7
10 changed files with 352 additions and 0 deletions

28
tmdb/request.go Normal file
View File

@@ -0,0 +1,28 @@
package tmdb
import (
"fmt"
"io"
"net/http"
"github.com/pkg/errors"
)
func tmdbGet(url string, token string) ([]byte, error) {
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, errors.Wrap(err, "http.NewRequest")
}
req.Header.Add("accept", "application/json")
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token))
res, err := http.DefaultClient.Do(req)
if err != nil {
return nil, errors.Wrap(err, "http.DefaultClient.Do")
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
return nil, errors.Wrap(err, "io.ReadAll")
}
return body, nil
}