Added tool to split spoiler paragraphs

This commit is contained in:
Eduard Urbach 2018-11-01 15:17:03 +09:00
parent 942f45f04d
commit 257ba1bf59

View File

@ -0,0 +1,40 @@
package main
import (
"strings"
"github.com/animenotifier/arn"
"github.com/fatih/color"
)
func main() {
color.Yellow("Splitting character spoiler paragraphs into separate spoilers")
defer color.Green("Finished.")
defer arn.Node.Close()
for character := range arn.StreamCharacters() {
spoilers := character.Spoilers
finalSpoilers := []arn.Spoiler{}
for _, spoiler := range spoilers {
if !strings.Contains(strings.TrimSpace(spoiler.Text), "\n\n") {
finalSpoilers = append(finalSpoilers, spoiler)
continue
}
paragraphs := strings.Split(spoiler.Text, "\n\n")
for _, paragraph := range paragraphs {
finalSpoilers = append(finalSpoilers, arn.Spoiler{
Text: paragraph,
})
}
}
if len(finalSpoilers) != len(spoilers) {
character.Spoilers = finalSpoilers
character.Save()
}
}
}