Cleanup
This commit is contained in:
parent
fd45f4820e
commit
16c76670e8
@ -1,91 +1,93 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
func main() {}
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/animenotifier/arn"
|
// import (
|
||||||
"github.com/animenotifier/jikan"
|
// "fmt"
|
||||||
"github.com/fatih/color"
|
// "strings"
|
||||||
)
|
|
||||||
|
|
||||||
var jikanDB = arn.Node.Namespace("jikan")
|
// "github.com/animenotifier/arn"
|
||||||
|
// "github.com/animenotifier/jikan"
|
||||||
|
// "github.com/fatih/color"
|
||||||
|
// )
|
||||||
|
|
||||||
func main() {
|
// var jikanDB = arn.Node.Namespace("jikan")
|
||||||
color.Yellow("Importing jikan characters...")
|
|
||||||
defer arn.Node.Close()
|
|
||||||
|
|
||||||
for characterObj := range jikanDB.All("Character") {
|
// func main() {
|
||||||
jikanCharacter := characterObj.(*jikan.Character)
|
// color.Yellow("Importing jikan characters...")
|
||||||
|
// defer arn.Node.Close()
|
||||||
|
|
||||||
if jikanCharacter.Name != "Slaine Troyard" {
|
// for characterObj := range jikanDB.All("Character") {
|
||||||
continue
|
// jikanCharacter := characterObj.(*jikan.Character)
|
||||||
}
|
|
||||||
|
|
||||||
character := &arn.Character{
|
// if jikanCharacter.Name != "Slaine Troyard" {
|
||||||
ID: arn.GenerateID("Character"),
|
// continue
|
||||||
Description: jikanCharacter.About,
|
// }
|
||||||
Name: &arn.CharacterName{
|
|
||||||
Romaji: jikanCharacter.Name,
|
|
||||||
Japanese: jikanCharacter.NameJapanese,
|
|
||||||
},
|
|
||||||
Image: jikanCharacter.Image,
|
|
||||||
// Mappings: []*arn.Mapping{
|
|
||||||
// &arn.Mapping{
|
|
||||||
// Service: "myanimelist/character",
|
|
||||||
// ServiceID: jikanCharacter.
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.HasPrefix(character.Name.Japanese, "(") {
|
// character := &arn.Character{
|
||||||
character.Name.Japanese = strings.TrimPrefix(character.Name.Japanese, "(")
|
// ID: arn.GenerateID("Character"),
|
||||||
character.Name.Japanese = strings.TrimSuffix(character.Name.Japanese, ")")
|
// Description: jikanCharacter.About,
|
||||||
}
|
// Name: &arn.CharacterName{
|
||||||
|
// Romaji: jikanCharacter.Name,
|
||||||
|
// Japanese: jikanCharacter.NameJapanese,
|
||||||
|
// },
|
||||||
|
// Image: jikanCharacter.Image,
|
||||||
|
// // Mappings: []*arn.Mapping{
|
||||||
|
// // &arn.Mapping{
|
||||||
|
// // Service: "myanimelist/character",
|
||||||
|
// // ServiceID: jikanCharacter.
|
||||||
|
// // }
|
||||||
|
// // },
|
||||||
|
// }
|
||||||
|
|
||||||
lines := strings.Split(character.Description, "\n")
|
// if strings.HasPrefix(character.Name.Japanese, "(") {
|
||||||
finalLines := make([]string, 0, len(lines))
|
// character.Name.Japanese = strings.TrimPrefix(character.Name.Japanese, "(")
|
||||||
|
// character.Name.Japanese = strings.TrimSuffix(character.Name.Japanese, ")")
|
||||||
|
// }
|
||||||
|
|
||||||
for _, line := range lines {
|
// lines := strings.Split(character.Description, "\n")
|
||||||
line = strings.TrimSpace(line)
|
// finalLines := make([]string, 0, len(lines))
|
||||||
originalLine := line
|
|
||||||
|
|
||||||
if strings.HasPrefix(line, "(") {
|
// for _, line := range lines {
|
||||||
line = strings.TrimPrefix(line, "(")
|
// line = strings.TrimSpace(line)
|
||||||
line = strings.TrimSuffix(line, ")")
|
// originalLine := line
|
||||||
}
|
|
||||||
|
|
||||||
line = strings.TrimSpace(line)
|
// if strings.HasPrefix(line, "(") {
|
||||||
|
// line = strings.TrimPrefix(line, "(")
|
||||||
|
// line = strings.TrimSuffix(line, ")")
|
||||||
|
// }
|
||||||
|
|
||||||
colonPos := strings.Index(line, ":")
|
// line = strings.TrimSpace(line)
|
||||||
|
|
||||||
if colonPos == -1 || colonPos < 2 || colonPos > 25 {
|
// colonPos := strings.Index(line, ":")
|
||||||
finalLines = append(finalLines, originalLine)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
key := line[:colonPos]
|
// if colonPos == -1 || colonPos < 2 || colonPos > 25 {
|
||||||
value := line[colonPos+1:]
|
// finalLines = append(finalLines, originalLine)
|
||||||
|
// continue
|
||||||
|
// }
|
||||||
|
|
||||||
value = strings.TrimSpace(value)
|
// key := line[:colonPos]
|
||||||
|
// value := line[colonPos+1:]
|
||||||
|
|
||||||
if key == "source" {
|
// value = strings.TrimSpace(value)
|
||||||
key = "Source"
|
|
||||||
}
|
|
||||||
|
|
||||||
character.Attributes = append(character.Attributes, &arn.CharacterAttribute{
|
// if key == "source" {
|
||||||
Name: key,
|
// key = "Source"
|
||||||
Value: value,
|
// }
|
||||||
})
|
|
||||||
|
|
||||||
fmt.Println(color.CyanString(key), color.YellowString(value))
|
// character.Attributes = append(character.Attributes, &arn.CharacterAttribute{
|
||||||
}
|
// Name: key,
|
||||||
|
// Value: value,
|
||||||
|
// })
|
||||||
|
|
||||||
character.Description = strings.Join(finalLines, "\n")
|
// fmt.Println(color.CyanString(key), color.YellowString(value))
|
||||||
character.Description = strings.TrimSpace(character.Description)
|
// }
|
||||||
|
|
||||||
arn.PrettyPrint(character)
|
// character.Description = strings.Join(finalLines, "\n")
|
||||||
}
|
// character.Description = strings.TrimSpace(character.Description)
|
||||||
|
|
||||||
color.Green("Finished.")
|
// arn.PrettyPrint(character)
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// color.Green("Finished.")
|
||||||
|
// }
|
||||||
|
@ -31,7 +31,7 @@ func main() {
|
|||||||
user.Accounts.Facebook.ID = ""
|
user.Accounts.Facebook.ID = ""
|
||||||
user.Accounts.Google.ID = ""
|
user.Accounts.Google.ID = ""
|
||||||
user.AgeRange = arn.UserAgeRange{}
|
user.AgeRange = arn.UserAgeRange{}
|
||||||
user.Location = arn.UserLocation{}
|
user.Location = arn.Location{}
|
||||||
|
|
||||||
user.PushSubscriptions().Items = []*arn.PushSubscription{}
|
user.PushSubscriptions().Items = []*arn.PushSubscription{}
|
||||||
user.PushSubscriptions().Save()
|
user.PushSubscriptions().Save()
|
||||||
|
Loading…
Reference in New Issue
Block a user