mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Replaced ioutil package with io
This commit is contained in:
parent
52a8f81356
commit
16fcf08f34
3 changed files with 8 additions and 10 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue