diff --git a/cmd/crunchyroll-go/cmd/login.go b/cmd/crunchyroll-go/cmd/login.go index fa55020..3bd4004 100644 --- a/cmd/crunchyroll-go/cmd/login.go +++ b/cmd/crunchyroll-go/cmd/login.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/ByteDream/crunchyroll-go" "github.com/spf13/cobra" - "io/ioutil" "os" "os/user" "path/filepath" @@ -46,7 +45,7 @@ func loginCredentials(user, password string) error { os.Exit(1) } - return ioutil.WriteFile(loginStorePath(), []byte(fmt.Sprintf("%s\n%s", user, password)), 0600) + return os.WriteFile(loginStorePath(), []byte(fmt.Sprintf("%s\n%s", user, password)), 0600) } func loginSessionID(sessionID string) error { @@ -56,7 +55,7 @@ func loginSessionID(sessionID string) error { os.Exit(1) } - return ioutil.WriteFile(loginStorePath(), []byte(sessionID), 0600) + return os.WriteFile(loginStorePath(), []byte(sessionID), 0600) } func loginStorePath() string { diff --git a/crunchyroll.go b/crunchyroll.go index 8c456a4..f59fb30 100644 --- a/crunchyroll.go +++ b/crunchyroll.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "regexp" @@ -68,7 +68,7 @@ func LoginWithCredentials(user string, password string, locale LOCALE, client *h defer sessResp.Body.Close() var data map[string]interface{} - body, _ := ioutil.ReadAll(sessResp.Body) + body, _ := io.ReadAll(sessResp.Body) json.Unmarshal(body, &data) sessionID := data["data"].(map[string]interface{})["session_id"].(string) @@ -211,7 +211,7 @@ func (c *Crunchyroll) request(endpoint string) (*http.Response, error) { resp, err := c.Client.Do(req) if err == nil { - bodyAsBytes, _ := ioutil.ReadAll(resp.Body) + bodyAsBytes, _ := io.ReadAll(resp.Body) defer resp.Body.Close() if resp.StatusCode == http.StatusUnauthorized { return nil, &AccessError{ @@ -231,7 +231,7 @@ func (c *Crunchyroll) request(endpoint string) (*http.Response, error) { } } } - resp.Body = ioutil.NopCloser(bytes.NewBuffer(bodyAsBytes)) + resp.Body = io.NopCloser(bytes.NewBuffer(bodyAsBytes)) } return resp, err } diff --git a/downloader.go b/downloader.go index 48460c3..8c0278b 100644 --- a/downloader.go +++ b/downloader.go @@ -8,7 +8,6 @@ import ( "fmt" "github.com/grafov/m3u8" "io" - "io/ioutil" "math" "net/http" "os" @@ -324,7 +323,7 @@ func getCrypt(format *Format, segment *m3u8.MediaSegment) (block cipher.Block, i return nil, nil, err } defer resp.Body.Close() - key, err := ioutil.ReadAll(resp.Body) + key, err := io.ReadAll(resp.Body) block, err = aes.NewCipher(key) if err != nil { @@ -372,7 +371,7 @@ func (d Downloader) decryptSegment(client *http.Client, segment *m3u8.MediaSegme } defer resp.Body.Close() - raw, err := ioutil.ReadAll(resp.Body) + raw, err := io.ReadAll(resp.Body) if err != nil { return nil, err }