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