diff --git a/auth/facebook.go b/auth/facebook.go index 75fa4b5a..d7f8c890 100644 --- a/auth/facebook.go +++ b/auth/facebook.go @@ -1,6 +1,7 @@ package auth import ( + "context" "encoding/json" "errors" "io/ioutil" @@ -57,14 +58,14 @@ func InstallFacebookAuth(app *aero.Application) { } // Handle the exchange code to initiate a transport - token, err := config.Exchange(oauth2.NoContext, ctx.Query("code")) + token, err := config.Exchange(context.Background(), ctx.Query("code")) if err != nil { return ctx.Error(http.StatusBadRequest, "Could not obtain OAuth token", err) } // Construct the OAuth client - client := config.Client(oauth2.NoContext, token) + client := config.Client(context.Background(), token) // Fetch user data from Facebook resp, err := client.Get("https://graph.facebook.com/me?fields=email,first_name,last_name,gender") diff --git a/auth/google.go b/auth/google.go index 77321831..86317342 100644 --- a/auth/google.go +++ b/auth/google.go @@ -1,6 +1,7 @@ package auth import ( + "context" "encoding/json" "errors" "io/ioutil" @@ -63,14 +64,14 @@ func InstallGoogleAuth(app *aero.Application) { } // Handle the exchange code to initiate a transport - token, err := config.Exchange(oauth2.NoContext, ctx.Query("code")) + token, err := config.Exchange(context.Background(), ctx.Query("code")) if err != nil { return ctx.Error(http.StatusBadRequest, "Could not obtain OAuth token", err) } // Construct the OAuth client - client := config.Client(oauth2.NoContext, token) + client := config.Client(context.Background(), token) // Fetch user data from Google resp, err := client.Get("https://www.googleapis.com/oauth2/v3/userinfo") diff --git a/bots/discord/discord.go b/bots/discord/discord.go index ec81ebe9..39eee5b3 100644 --- a/bots/discord/discord.go +++ b/bots/discord/discord.go @@ -49,6 +49,6 @@ func main() { // Wait for a CTRL-C log.Printf("Tsundere is ready. Press CTRL-C to exit.") sc := make(chan os.Signal, 1) - signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill) + signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) <-sc } diff --git a/jobs/kitsu-characters-parse/kitsu-characters-parse.go b/jobs/kitsu-characters-parse/kitsu-characters-parse.go index 46fea188..9e777af4 100644 --- a/jobs/kitsu-characters-parse/kitsu-characters-parse.go +++ b/jobs/kitsu-characters-parse/kitsu-characters-parse.go @@ -101,7 +101,7 @@ func main() { } character.Description = strings.Join(finalLines, "\n\n") - character.Description = strings.Trim(character.Description, "\n\n") + character.Description = strings.Trim(character.Description, "\n") character.Save() // Save Kitsu character in Kitsu DB diff --git a/jobs/mal-parse/mal-parse.go b/jobs/mal-parse/mal-parse.go index 869caadf..d0a170de 100644 --- a/jobs/mal-parse/mal-parse.go +++ b/jobs/mal-parse/mal-parse.go @@ -1,7 +1,6 @@ package main import ( - "encoding/json" "errors" "fmt" "os" @@ -47,13 +46,13 @@ func main() { func readFile(name string) error { file, err := os.Open(name) - defer file.Close() if err != nil { fmt.Println(err) return err } + defer file.Close() anime, characters, err := malparser.ParseAnime(file) if err != nil { @@ -95,9 +94,3 @@ func readFile(name string) error { arn.MAL.Set("Anime", anime.ID, anime) return nil } - -// prettyPrint prints the object as indented JSON data on the console. -func prettyPrint(obj interface{}) { - pretty, _ := json.MarshalIndent(obj, "", "\t") - fmt.Println(string(pretty)) -} diff --git a/pages/admin/admin.go b/pages/admin/admin.go index 122bbd44..7ee305de 100644 --- a/pages/admin/admin.go +++ b/pages/admin/admin.go @@ -45,17 +45,3 @@ func Get(ctx *aero.Context) string { return ctx.HTML(components.Admin(user, platform, family, platformVersion, kernelVersion)) } - -func average(floatSlice []float64) float64 { - if len(floatSlice) == 0 { - return 0 - } - - var sum float64 - - for _, value := range floatSlice { - sum += value - } - - return sum / float64(len(floatSlice)) -} diff --git a/pages/editor/filtersoundtracks/links.go b/pages/editor/filtersoundtracks/links.go index 2ef307fb..3b873703 100644 --- a/pages/editor/filtersoundtracks/links.go +++ b/pages/editor/filtersoundtracks/links.go @@ -5,8 +5,6 @@ import ( "github.com/animenotifier/arn" ) -const maxEntries = 70 - // Links shows soundtracks without links. func Links(ctx *aero.Context) string { return editorList( diff --git a/pages/profile/profile.go b/pages/profile/profile.go index 58146cdd..4bf6cc54 100644 --- a/pages/profile/profile.go +++ b/pages/profile/profile.go @@ -7,8 +7,6 @@ import ( "github.com/animenotifier/notify.moe/utils" ) -const maxPosts = 5 - // Get user profile page. func Get(ctx *aero.Context) string { nick := ctx.Get("nick") diff --git a/pages/users/users.go b/pages/users/users.go index fa8c5239..6e32e0bc 100644 --- a/pages/users/users.go +++ b/pages/users/users.go @@ -19,11 +19,7 @@ func Active(ctx *aero.Context) string { sort.Slice(users, func(i, j int) bool { if users[i].HasAvatar() != users[j].HasAvatar() { - if users[i].HasAvatar() { - return true - } - - return false + return users[i].HasAvatar() } followersA := followCount[users[i].ID] @@ -101,11 +97,7 @@ func ActiveNoAvatar(ctx *aero.Context) string { sort.Slice(users, func(i, j int) bool { if users[i].HasAvatar() != users[j].HasAvatar() { - if users[i].HasAvatar() { - return true - } - - return false + return users[i].HasAvatar() } followersA := followCount[users[i].ID] diff --git a/patches/fix-airing-dates/fix-airing-dates.go b/patches/fix-airing-dates/fix-airing-dates.go index 87b12547..7588024a 100644 --- a/patches/fix-airing-dates/fix-airing-dates.go +++ b/patches/fix-airing-dates/fix-airing-dates.go @@ -39,7 +39,7 @@ func main() { modified = true } - if modified == true { + if modified { anime.Episodes().Save() } } diff --git a/patches/improve-image-quality/improve-image-quality.go b/patches/improve-image-quality/improve-image-quality.go index 90befb4e..a5d68c24 100644 --- a/patches/improve-image-quality/improve-image-quality.go +++ b/patches/improve-image-quality/improve-image-quality.go @@ -35,8 +35,6 @@ func main() { png.Encode(f, improved) } -const max = float64(65535) - // Pixel ... type Pixel struct { X int @@ -228,42 +226,42 @@ func ImproveQuality(img image.Image) *image.NRGBA { offset++ } - // Determine surrounding area - surroundingAreaIndex := -1 - bestScore := 0 + // // Determine surrounding area + // surroundingAreaIndex := -1 + // bestScore := 0 - for checkIndex, score := range areaSurroundedBy { - if score > bestScore && checkIndex != areaIndex { - bestScore = score - surroundingAreaIndex = checkIndex - } - } + // for checkIndex, score := range areaSurroundedBy { + // if score > bestScore && checkIndex != areaIndex { + // bestScore = score + // surroundingAreaIndex = checkIndex + // } + // } - surroundingArea := areas[surroundingAreaIndex] + // surroundingArea := areas[surroundingAreaIndex] - if areaIndex != surroundingAreaIndex && len(surroundingArea.Pixels) > len(area.Pixels)*2 { - // const surroundTolerance = 5000 + // if areaIndex != surroundingAreaIndex && len(surroundingArea.Pixels) > len(area.Pixels)*2 { + // // const surroundTolerance = 5000 - // r1, g1, b1, a1 := area.AverageColor().RGBA() - // r2, g2, b2, a2 := surroundingArea.AverageColor().RGBA() + // // r1, g1, b1, a1 := area.AverageColor().RGBA() + // // r2, g2, b2, a2 := surroundingArea.AverageColor().RGBA() - // if diffAbs(r1, r2) < surroundTolerance && diffAbs(g1, g2) < surroundTolerance && diffAbs(b1, b2) < surroundTolerance && diffAbs(a1, a2) < surroundTolerance { - // // fmt.Println(areaIndex, "surrounded by", surroundingAreaIndex, "|", len(area.Pixels), len(surroundingArea.Pixels)) + // // if diffAbs(r1, r2) < surroundTolerance && diffAbs(g1, g2) < surroundTolerance && diffAbs(b1, b2) < surroundTolerance && diffAbs(a1, a2) < surroundTolerance { + // // // fmt.Println(areaIndex, "surrounded by", surroundingAreaIndex, "|", len(area.Pixels), len(surroundingArea.Pixels)) - // // Add pixels to surrounding area - // for _, pixel := range area.Pixels { - // r, g, b, a := img.At(pixel.X, pixel.Y).RGBA() - // surroundingArea.Add(pixel.X, pixel.Y, r, g, b, a) - // } + // // // Add pixels to surrounding area + // // for _, pixel := range area.Pixels { + // // r, g, b, a := img.At(pixel.X, pixel.Y).RGBA() + // // surroundingArea.Add(pixel.X, pixel.Y, r, g, b, a) + // // } - // // Remove this area - // area.Pixels = nil - // area.totalR = 0 - // area.totalG = 0 - // area.totalB = 0 - // area.totalA = 0 - // } - } + // // // Remove this area + // // area.Pixels = nil + // // area.totalR = 0 + // // area.totalG = 0 + // // area.totalB = 0 + // // area.totalA = 0 + // // } + // } } fmt.Println(noiseCount, "noise pixels") diff --git a/patches/kitsu-anilist/kitsu-anilist.go b/patches/kitsu-anilist/kitsu-anilist.go index 550b99e9..6593298c 100644 --- a/patches/kitsu-anilist/kitsu-anilist.go +++ b/patches/kitsu-anilist/kitsu-anilist.go @@ -28,10 +28,7 @@ func main() { } externalID := mapping.Attributes.ExternalID - - if strings.HasPrefix(externalID, "anime/") { - externalID = externalID[len("anime/"):] - } + externalID = strings.TrimPrefix(externalID, "anime/") anime := finder.GetAnime(mapping.Relationships.Item.Data.ID) diff --git a/patches/kitsu-download-anime-images/kitsu-download-anime-images.go b/patches/kitsu-download-anime-images/kitsu-download-anime-images.go index eece2d57..5f6f2a30 100644 --- a/patches/kitsu-download-anime-images/kitsu-download-anime-images.go +++ b/patches/kitsu-download-anime-images/kitsu-download-anime-images.go @@ -22,7 +22,6 @@ var ticker = time.NewTicker(50 * time.Millisecond) // Shell parameters var from int var to int -var useCache bool // Shell flags func init() {