spelling correct
This commit is contained in:
parent
d4ad4bc430
commit
72dfbf4a03
@ -17,14 +17,14 @@ func AniListQuery(body interface{}, login bool) (json.RawMessage, string) {
|
|||||||
if login && (AniListJWT{}) != aniListJwt {
|
if login && (AniListJWT{}) != aniListJwt {
|
||||||
response.Header.Add("Authorization", "Bearer "+aniListJwt.AccessToken)
|
response.Header.Add("Authorization", "Bearer "+aniListJwt.AccessToken)
|
||||||
} else if login {
|
} else if login {
|
||||||
return nil, "Please login to anilist to make this request"
|
return nil, "Please login to AniList to make this request"
|
||||||
}
|
}
|
||||||
response.Header.Add("Content-Type", "application/json")
|
response.Header.Add("Content-Type", "application/json")
|
||||||
response.Header.Add("Accept", "application/json")
|
response.Header.Add("Accept", "application/json")
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
res, reserr := client.Do(response)
|
res, resErr := client.Do(response)
|
||||||
if reserr != nil {
|
if resErr != nil {
|
||||||
log.Printf("Failed at res, %s\n", err)
|
log.Printf("Failed at res, %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ func (a *App) GetAniListItem(aniId int, login bool) AniListGetSingleAnime {
|
|||||||
return post
|
return post
|
||||||
}
|
}
|
||||||
|
|
||||||
if status == "404 Not Found" && login {
|
if status == "404 Not Found" {
|
||||||
post = a.GetAniListItem(aniId, false)
|
post = a.GetAniListItem(aniId, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
@ -123,7 +124,7 @@ func (a *App) handleAniListCallback(wg *sync.WaitGroup) {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||||
log.Fatalf("listen: %s\n", err)
|
log.Fatalf("listen: %s\n", err)
|
||||||
}
|
}
|
||||||
fmt.Println("Shutting down...")
|
fmt.Println("Shutting down...")
|
||||||
@ -152,8 +153,8 @@ func getAniListAuthorizationToken(content string) AniListJWT {
|
|||||||
response.Header.Add("Accept", "application/json")
|
response.Header.Add("Accept", "application/json")
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
res, reserr := client.Do(response)
|
res, resErr := client.Do(response)
|
||||||
if reserr != nil {
|
if resErr != nil {
|
||||||
log.Printf("Failed at res, %s\n", err)
|
log.Printf("Failed at res, %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
@ -79,10 +80,10 @@ func (a *App) CheckIfMyAnimeListLoggedIn() bool {
|
|||||||
if (tokenErr != nil || expiresInErr != nil || refreshTokenErr != nil || accessTokenErr != nil) || len(accessToken.Data) == 0 {
|
if (tokenErr != nil || expiresInErr != nil || refreshTokenErr != nil || accessTokenErr != nil) || len(accessToken.Data) == 0 {
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
var expresInConvertErr error
|
var expiresInConvertErr error
|
||||||
myAnimeListJwt.TokenType = string(tokenType.Data)
|
myAnimeListJwt.TokenType = string(tokenType.Data)
|
||||||
myAnimeListJwt.ExpiresIn, expresInConvertErr = strconv.Atoi(string(expiresIn.Data))
|
myAnimeListJwt.ExpiresIn, expiresInConvertErr = strconv.Atoi(string(expiresIn.Data))
|
||||||
if expresInConvertErr != nil {
|
if expiresInConvertErr != nil {
|
||||||
fmt.Println("unable to convert string to int")
|
fmt.Println("unable to convert string to int")
|
||||||
}
|
}
|
||||||
myAnimeListJwt.AccessToken = string(accessToken.Data)
|
myAnimeListJwt.AccessToken = string(accessToken.Data)
|
||||||
@ -111,10 +112,10 @@ func (a *App) MyAnimeListLogin() {
|
|||||||
a.handleMyAnimeListCallback(serverDone, verifier)
|
a.handleMyAnimeListCallback(serverDone, verifier)
|
||||||
serverDone.Wait()
|
serverDone.Wait()
|
||||||
} else {
|
} else {
|
||||||
var expresInConvertErr error
|
var expiresInConvertErr error
|
||||||
myAnimeListJwt.TokenType = string(tokenType.Data)
|
myAnimeListJwt.TokenType = string(tokenType.Data)
|
||||||
myAnimeListJwt.ExpiresIn, expresInConvertErr = strconv.Atoi(string(expiresIn.Data))
|
myAnimeListJwt.ExpiresIn, expiresInConvertErr = strconv.Atoi(string(expiresIn.Data))
|
||||||
if expresInConvertErr != nil {
|
if expiresInConvertErr != nil {
|
||||||
fmt.Println("unable to convert string to int in Login function")
|
fmt.Println("unable to convert string to int in Login function")
|
||||||
}
|
}
|
||||||
myAnimeListJwt.AccessToken = string(accessToken.Data)
|
myAnimeListJwt.AccessToken = string(accessToken.Data)
|
||||||
@ -176,7 +177,7 @@ func (a *App) handleMyAnimeListCallback(wg *sync.WaitGroup, verifier *CodeVerifi
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||||
log.Fatalf("listen: %s\n", err)
|
log.Fatalf("listen: %s\n", err)
|
||||||
}
|
}
|
||||||
fmt.Println("Shutting down...")
|
fmt.Println("Shutting down...")
|
||||||
@ -215,8 +216,8 @@ func getMyAnimeListAuthorizationToken(content string, verifier *CodeVerifier) My
|
|||||||
response.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
response.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
res, reserr := client.Do(response)
|
res, resErr := client.Do(response)
|
||||||
if reserr != nil {
|
if resErr != nil {
|
||||||
log.Printf("Failed at res, %s\n", err)
|
log.Printf("Failed at res, %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,8 +266,8 @@ func refreshMyAnimeListAuthorizationToken() {
|
|||||||
response.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
response.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
res, reserr := client.Do(response)
|
res, resErr := client.Do(response)
|
||||||
if reserr != nil {
|
if resErr != nil {
|
||||||
log.Printf("Failed at res, %s\n", err)
|
log.Printf("Failed at res, %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
@ -114,7 +115,7 @@ func (a *App) handleSimklCallback(wg *sync.WaitGroup) {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||||
log.Fatalf("listen: %s\n", err)
|
log.Fatalf("listen: %s\n", err)
|
||||||
}
|
}
|
||||||
fmt.Println("Shutting down...")
|
fmt.Println("Shutting down...")
|
||||||
@ -147,8 +148,8 @@ func getSimklAuthorizationToken(content string) SimklJWT {
|
|||||||
response.Header.Add("Content-Type", "application/json")
|
response.Header.Add("Content-Type", "application/json")
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
res, reserr := client.Do(response)
|
res, resErr := client.Do(response)
|
||||||
if reserr != nil {
|
if resErr != nil {
|
||||||
log.Printf("Failed at res, %s\n", err)
|
log.Printf("Failed at res, %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user