Add yt-downloader

This commit is contained in:
2021-12-21 23:05:00 +01:00
committed by kjuulh
parent 0d3fae2ca5
commit 4b9583b08f
17 changed files with 449 additions and 134 deletions

View File

@@ -9,8 +9,7 @@ import (
)
type requestDownloadRequest struct {
Provider string `json:"provider"`
Link string `json:"link"`
Link string `json:"link"`
}
type requestDownloadResponse struct {
@@ -22,7 +21,7 @@ func (_ requestDownloadResponse) Render(_ http.ResponseWriter, _ *http.Request)
}
func (dr *requestDownloadRequest) Bind(r *http.Request) error {
if dr.Link == "" || dr.Provider == "" {
if dr.Link == "" {
return errors.New("missing required download request field")
}
@@ -36,7 +35,7 @@ func (a *api) requestDownload(w http.ResponseWriter, r *http.Request) {
return
}
download, err := a.drService.Schedule(data.Provider, data.Link)
download, err := a.drService.Schedule(data.Link)
if err != nil {
_ = render.Render(w, r, responses.ErrInvalidRequest(err))
return

View File

@@ -1,15 +1,15 @@
package download
import (
"downloader/internal/core/ports/download_request"
"downloader/internal/core/services/download"
"github.com/go-chi/chi"
)
type api struct {
drService download_request.Service
drService download.Service
}
func New(service download_request.Service) *api {
func New(service download.Service) *api {
return &api{drService: service}
}