Added tool to split spoiler paragraphs
This commit is contained in:
parent
942f45f04d
commit
257ba1bf59
40
patches/character-split-spoilers/character-split-spoilers.go
Normal file
40
patches/character-split-spoilers/character-split-spoilers.go
Normal 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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user