Applied suggested linter changes
This commit is contained in:
parent
a45c39a916
commit
e90873b64f
@ -1,6 +1,7 @@
|
|||||||
package auth
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -57,14 +58,14 @@ func InstallFacebookAuth(app *aero.Application) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle the exchange code to initiate a transport
|
// 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 {
|
if err != nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Could not obtain OAuth token", err)
|
return ctx.Error(http.StatusBadRequest, "Could not obtain OAuth token", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct the OAuth client
|
// Construct the OAuth client
|
||||||
client := config.Client(oauth2.NoContext, token)
|
client := config.Client(context.Background(), token)
|
||||||
|
|
||||||
// Fetch user data from Facebook
|
// Fetch user data from Facebook
|
||||||
resp, err := client.Get("https://graph.facebook.com/me?fields=email,first_name,last_name,gender")
|
resp, err := client.Get("https://graph.facebook.com/me?fields=email,first_name,last_name,gender")
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package auth
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -63,14 +64,14 @@ func InstallGoogleAuth(app *aero.Application) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle the exchange code to initiate a transport
|
// 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 {
|
if err != nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Could not obtain OAuth token", err)
|
return ctx.Error(http.StatusBadRequest, "Could not obtain OAuth token", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct the OAuth client
|
// Construct the OAuth client
|
||||||
client := config.Client(oauth2.NoContext, token)
|
client := config.Client(context.Background(), token)
|
||||||
|
|
||||||
// Fetch user data from Google
|
// Fetch user data from Google
|
||||||
resp, err := client.Get("https://www.googleapis.com/oauth2/v3/userinfo")
|
resp, err := client.Get("https://www.googleapis.com/oauth2/v3/userinfo")
|
||||||
|
@ -49,6 +49,6 @@ func main() {
|
|||||||
// Wait for a CTRL-C
|
// Wait for a CTRL-C
|
||||||
log.Printf("Tsundere is ready. Press CTRL-C to exit.")
|
log.Printf("Tsundere is ready. Press CTRL-C to exit.")
|
||||||
sc := make(chan os.Signal, 1)
|
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
|
<-sc
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
character.Description = strings.Join(finalLines, "\n\n")
|
character.Description = strings.Join(finalLines, "\n\n")
|
||||||
character.Description = strings.Trim(character.Description, "\n\n")
|
character.Description = strings.Trim(character.Description, "\n")
|
||||||
character.Save()
|
character.Save()
|
||||||
|
|
||||||
// Save Kitsu character in Kitsu DB
|
// Save Kitsu character in Kitsu DB
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
@ -47,13 +46,13 @@ func main() {
|
|||||||
|
|
||||||
func readFile(name string) error {
|
func readFile(name string) error {
|
||||||
file, err := os.Open(name)
|
file, err := os.Open(name)
|
||||||
defer file.Close()
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer file.Close()
|
||||||
anime, characters, err := malparser.ParseAnime(file)
|
anime, characters, err := malparser.ParseAnime(file)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -95,9 +94,3 @@ func readFile(name string) error {
|
|||||||
arn.MAL.Set("Anime", anime.ID, anime)
|
arn.MAL.Set("Anime", anime.ID, anime)
|
||||||
return nil
|
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))
|
|
||||||
}
|
|
||||||
|
@ -45,17 +45,3 @@ func Get(ctx *aero.Context) string {
|
|||||||
|
|
||||||
return ctx.HTML(components.Admin(user, platform, family, platformVersion, kernelVersion))
|
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))
|
|
||||||
}
|
|
||||||
|
@ -5,8 +5,6 @@ import (
|
|||||||
"github.com/animenotifier/arn"
|
"github.com/animenotifier/arn"
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxEntries = 70
|
|
||||||
|
|
||||||
// Links shows soundtracks without links.
|
// Links shows soundtracks without links.
|
||||||
func Links(ctx *aero.Context) string {
|
func Links(ctx *aero.Context) string {
|
||||||
return editorList(
|
return editorList(
|
||||||
|
@ -7,8 +7,6 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/utils"
|
"github.com/animenotifier/notify.moe/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxPosts = 5
|
|
||||||
|
|
||||||
// Get user profile page.
|
// Get user profile page.
|
||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
nick := ctx.Get("nick")
|
nick := ctx.Get("nick")
|
||||||
|
@ -19,11 +19,7 @@ func Active(ctx *aero.Context) string {
|
|||||||
|
|
||||||
sort.Slice(users, func(i, j int) bool {
|
sort.Slice(users, func(i, j int) bool {
|
||||||
if users[i].HasAvatar() != users[j].HasAvatar() {
|
if users[i].HasAvatar() != users[j].HasAvatar() {
|
||||||
if users[i].HasAvatar() {
|
return users[i].HasAvatar()
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
followersA := followCount[users[i].ID]
|
followersA := followCount[users[i].ID]
|
||||||
@ -101,11 +97,7 @@ func ActiveNoAvatar(ctx *aero.Context) string {
|
|||||||
|
|
||||||
sort.Slice(users, func(i, j int) bool {
|
sort.Slice(users, func(i, j int) bool {
|
||||||
if users[i].HasAvatar() != users[j].HasAvatar() {
|
if users[i].HasAvatar() != users[j].HasAvatar() {
|
||||||
if users[i].HasAvatar() {
|
return users[i].HasAvatar()
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
followersA := followCount[users[i].ID]
|
followersA := followCount[users[i].ID]
|
||||||
|
@ -39,7 +39,7 @@ func main() {
|
|||||||
modified = true
|
modified = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if modified == true {
|
if modified {
|
||||||
anime.Episodes().Save()
|
anime.Episodes().Save()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,6 @@ func main() {
|
|||||||
png.Encode(f, improved)
|
png.Encode(f, improved)
|
||||||
}
|
}
|
||||||
|
|
||||||
const max = float64(65535)
|
|
||||||
|
|
||||||
// Pixel ...
|
// Pixel ...
|
||||||
type Pixel struct {
|
type Pixel struct {
|
||||||
X int
|
X int
|
||||||
@ -228,42 +226,42 @@ func ImproveQuality(img image.Image) *image.NRGBA {
|
|||||||
offset++
|
offset++
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine surrounding area
|
// // Determine surrounding area
|
||||||
surroundingAreaIndex := -1
|
// surroundingAreaIndex := -1
|
||||||
bestScore := 0
|
// bestScore := 0
|
||||||
|
|
||||||
for checkIndex, score := range areaSurroundedBy {
|
// for checkIndex, score := range areaSurroundedBy {
|
||||||
if score > bestScore && checkIndex != areaIndex {
|
// if score > bestScore && checkIndex != areaIndex {
|
||||||
bestScore = score
|
// bestScore = score
|
||||||
surroundingAreaIndex = checkIndex
|
// surroundingAreaIndex = checkIndex
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
surroundingArea := areas[surroundingAreaIndex]
|
// surroundingArea := areas[surroundingAreaIndex]
|
||||||
|
|
||||||
if areaIndex != surroundingAreaIndex && len(surroundingArea.Pixels) > len(area.Pixels)*2 {
|
// if areaIndex != surroundingAreaIndex && len(surroundingArea.Pixels) > len(area.Pixels)*2 {
|
||||||
// const surroundTolerance = 5000
|
// // const surroundTolerance = 5000
|
||||||
|
|
||||||
// r1, g1, b1, a1 := area.AverageColor().RGBA()
|
// // r1, g1, b1, a1 := area.AverageColor().RGBA()
|
||||||
// r2, g2, b2, a2 := surroundingArea.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 {
|
// // 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))
|
// // // fmt.Println(areaIndex, "surrounded by", surroundingAreaIndex, "|", len(area.Pixels), len(surroundingArea.Pixels))
|
||||||
|
|
||||||
// // Add pixels to surrounding area
|
// // // Add pixels to surrounding area
|
||||||
// for _, pixel := range area.Pixels {
|
// // for _, pixel := range area.Pixels {
|
||||||
// r, g, b, a := img.At(pixel.X, pixel.Y).RGBA()
|
// // r, g, b, a := img.At(pixel.X, pixel.Y).RGBA()
|
||||||
// surroundingArea.Add(pixel.X, pixel.Y, r, g, b, a)
|
// // surroundingArea.Add(pixel.X, pixel.Y, r, g, b, a)
|
||||||
// }
|
// // }
|
||||||
|
|
||||||
// // Remove this area
|
// // // Remove this area
|
||||||
// area.Pixels = nil
|
// // area.Pixels = nil
|
||||||
// area.totalR = 0
|
// // area.totalR = 0
|
||||||
// area.totalG = 0
|
// // area.totalG = 0
|
||||||
// area.totalB = 0
|
// // area.totalB = 0
|
||||||
// area.totalA = 0
|
// // area.totalA = 0
|
||||||
// }
|
// // }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(noiseCount, "noise pixels")
|
fmt.Println(noiseCount, "noise pixels")
|
||||||
|
@ -28,10 +28,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
externalID := mapping.Attributes.ExternalID
|
externalID := mapping.Attributes.ExternalID
|
||||||
|
externalID = strings.TrimPrefix(externalID, "anime/")
|
||||||
if strings.HasPrefix(externalID, "anime/") {
|
|
||||||
externalID = externalID[len("anime/"):]
|
|
||||||
}
|
|
||||||
|
|
||||||
anime := finder.GetAnime(mapping.Relationships.Item.Data.ID)
|
anime := finder.GetAnime(mapping.Relationships.Item.Data.ID)
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ var ticker = time.NewTicker(50 * time.Millisecond)
|
|||||||
// Shell parameters
|
// Shell parameters
|
||||||
var from int
|
var from int
|
||||||
var to int
|
var to int
|
||||||
var useCache bool
|
|
||||||
|
|
||||||
// Shell flags
|
// Shell flags
|
||||||
func init() {
|
func init() {
|
||||||
|
Loading…
Reference in New Issue
Block a user