crunchy-cli/subtitle.go
2022-03-21 16:55:27 +01:00

30 lines
509 B
Go

package crunchyroll
import (
"io"
"net/http"
)
type Subtitle struct {
crunchy *Crunchyroll
Locale LOCALE `json:"locale"`
URL string `json:"url"`
Format string `json:"format"`
}
func (s Subtitle) Save(writer io.Writer) error {
req, err := http.NewRequestWithContext(s.crunchy.Context, http.MethodGet, s.URL, nil)
if err != nil {
return err
}
resp, err := s.crunchy.Client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
_, err = io.Copy(writer, resp.Body)
return err
}