Commit 0b709e218f
0b709e218fc63499811ed9b0b6db3ae45ab3a1ef
parent: 02471056a4
Unsigned
Wraient <wraient.911@gmail.com> · 2024-10-19 21:13 UTC
Fix: io/ioutils is deprecated
Layout: unified · split
internal/anilist.go
+6 −6
| @@ -4,13 +4,13 @@ import ( |
| 4 | 4 | "bytes" |
| 5 | 5 | "encoding/json" |
| 6 | 6 | "fmt" |
| 7 | | "io/ioutil" |
| 7 | "io" |
| 8 | 8 | "net/http" |
| 9 | "os" |
| 9 | 10 | "strconv" |
| 10 | 11 | "strings" |
| 11 | 12 | ) |
| 12 | 13 | |
| 13 | | |
| 14 | 14 | // AniListAnime is the struct for the API response |
| 15 | 15 | type AniListAnime struct { |
| 16 | 16 | ID int `json:"id"` |
| @@ -134,11 +134,11 @@ func SearchAnimeAnilist(query, token string) (map[string]string, error) { |
| 134 | 134 | defer resp.Body.Close() |
| 135 | 135 | |
| 136 | 136 | if resp.StatusCode != http.StatusOK { |
| 137 | | body, _ := ioutil.ReadAll(resp.Body) |
| 137 | body, _ := io.ReadAll(resp.Body) |
| 138 | 138 | return nil, fmt.Errorf("failed to search for anime. Status Code: %d, Response: %s", resp.StatusCode, string(body)) |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | | body, err := ioutil.ReadAll(resp.Body) |
| 141 | body, err := io.ReadAll(resp.Body) |
| 142 | 142 | if err != nil { |
| 143 | 143 | return nil, fmt.Errorf("failed to read response body: %w", err) |
| 144 | 144 | } |
| @@ -315,7 +315,7 @@ func GetUserData(token string, userID int) (map[string]interface{}, error) { |
| 315 | 315 | |
| 316 | 316 | // Function to load a JSON file |
| 317 | 317 | func LoadJSONFile(filePath string) (map[string]interface{}, error) { |
| 318 | | data, err := ioutil.ReadFile(filePath) |
| 318 | data, err := os.ReadFile(filePath) |
| 319 | 319 | if err != nil { |
| 320 | 320 | return nil, fmt.Errorf("failed to read file: %w", err) |
| 321 | 321 | } |
| @@ -451,7 +451,7 @@ func makePostRequest(url, query string, variables map[string]interface{}, header |
| 451 | 451 | } |
| 452 | 452 | defer resp.Body.Close() |
| 453 | 453 | |
| 454 | | body, err := ioutil.ReadAll(resp.Body) |
| 454 | body, err := io.ReadAll(resp.Body) |
| 455 | 455 | if err != nil { |
| 456 | 456 | return nil, fmt.Errorf("failed to read response body: %w", err) |
| 457 | 457 | } |
internal/anime_list.go
+2 −2
| @@ -3,7 +3,7 @@ package internal |
| 3 | 3 | import ( |
| 4 | 4 | "encoding/json" |
| 5 | 5 | "fmt" |
| 6 | | "io/ioutil" |
| 6 | "io" |
| 7 | 7 | "net/http" |
| 8 | 8 | // "strings" |
| 9 | 9 | ) |
| @@ -71,7 +71,7 @@ func SearchAnime(query, mode string) (map[string]string, error) { |
| 71 | 71 | } |
| 72 | 72 | defer resp.Body.Close() |
| 73 | 73 | |
| 74 | | body, err := ioutil.ReadAll(resp.Body) |
| 74 | body, err := io.ReadAll(resp.Body) |
| 75 | 75 | if err != nil { |
| 76 | 76 | fmt.Println("Error reading response body:", err) |
| 77 | 77 | return animeList, err |
internal/curd.go
+1 −2
| @@ -3,7 +3,6 @@ package internal |
| 3 | 3 | import ( |
| 4 | 4 | "encoding/json" |
| 5 | 5 | "fmt" |
| 6 | | "io/ioutil" |
| 7 | 6 | "os" |
| 8 | 7 | "runtime" |
| 9 | 8 | "strings" |
| @@ -12,7 +11,7 @@ import ( |
| 12 | 11 | |
| 13 | 12 | func GetTokenFromFile(filePath string) (string, error) { |
| 14 | 13 | // Read the token from the file |
| 15 | | data, err := ioutil.ReadFile(filePath) |
| 14 | data, err := os.ReadFile(filePath) |
| 16 | 15 | if err != nil { |
| 17 | 16 | return "", fmt.Errorf("failed to read token from file: %w", err) |
| 18 | 17 | } |
internal/episode_list.go
+2 −2
| @@ -3,7 +3,7 @@ package internal |
| 3 | 3 | import ( |
| 4 | 4 | "encoding/json" |
| 5 | 5 | "fmt" |
| 6 | | "io/ioutil" |
| 6 | "io" |
| 7 | 7 | "net/http" |
| 8 | 8 | "sort" |
| 9 | 9 | "strconv" |
| @@ -62,7 +62,7 @@ func EpisodesList(showID, mode string) ([]string, error) { |
| 62 | 62 | } |
| 63 | 63 | defer resp.Body.Close() |
| 64 | 64 | |
| 65 | | body, err := ioutil.ReadAll(resp.Body) |
| 65 | body, err := io.ReadAll(resp.Body) |
| 66 | 66 | if err != nil { |
| 67 | 67 | fmt.Println("Error reading response body:", err) |
| 68 | 68 | return episodes, err |
internal/episode_url.go
+5 −5
| @@ -3,7 +3,7 @@ package internal |
| 3 | 3 | import ( |
| 4 | 4 | "encoding/json" |
| 5 | 5 | "fmt" |
| 6 | | "io/ioutil" |
| 6 | "io" |
| 7 | 7 | "net/http" |
| 8 | 8 | "net/url" |
| 9 | 9 | "regexp" |
| @@ -71,13 +71,13 @@ func extractLinks(provider_id string) map[string]interface{} { |
| 71 | 71 | // Send the request |
| 72 | 72 | resp, err := client.Do(req) |
| 73 | 73 | if err != nil { |
| 74 | | fmt.Println("Error sending request:", err) |
| 74 | Log(fmt.Sprint("Error sending request:", err), logFile) |
| 75 | 75 | return videoData |
| 76 | 76 | } |
| 77 | 77 | defer resp.Body.Close() |
| 78 | 78 | |
| 79 | 79 | // Read the response body |
| 80 | | body, err := ioutil.ReadAll(resp.Body) |
| 80 | body, err := io.ReadAll(resp.Body) |
| 81 | 81 | if err != nil { |
| 82 | 82 | fmt.Println("Error reading response:", err) |
| 83 | 83 | return videoData |
| @@ -140,7 +140,7 @@ func GetEpisodeURL(config CurdConfig, id string, epNo int) ([]string, error) { |
| 140 | 140 | } |
| 141 | 141 | defer resp.Body.Close() |
| 142 | 142 | |
| 143 | | body, err := ioutil.ReadAll(resp.Body) |
| 143 | body, err := io.ReadAll(resp.Body) |
| 144 | 144 | if err != nil { |
| 145 | 145 | return nil, err |
| 146 | 146 | } |
| @@ -170,7 +170,7 @@ func GetEpisodeURL(config CurdConfig, id string, epNo int) ([]string, error) { |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | } else { |
| 173 | | fmt.Println("Links field is not of the expected type []interface{}") |
| 173 | Log("Links field is not of the expected type []interface{}", logFile) |
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | } |