41 lines
851 B
Go
Raw Normal View History

2018-11-01 06:17:03 +00:00
package main
import (
"strings"
2019-04-23 05:45:17 +00:00
"github.com/akyoto/color"
2019-06-03 09:32:43 +00:00
"github.com/animenotifier/notify.moe/arn"
2018-11-01 06:17:03 +00:00
)
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()
}
}
}