mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
30 lines
509 B
Go
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
|
|
}
|