2018-04-22 15:43:20 +00:00
package main
import (
"fmt"
"sort"
2019-04-23 05:45:17 +00:00
"github.com/akyoto/color"
2019-04-23 05:52:55 +00:00
"github.com/animenotifier/arn"
2018-04-22 15:43:20 +00:00
)
func main ( ) {
color . Yellow ( "Merging duplicate characters" )
defer color . Green ( "Finished" )
defer arn . Node . Close ( )
malIDToCharacters := map [ string ] [ ] * arn . Character { }
for character := range arn . StreamCharacters ( ) {
malID := character . GetMapping ( "myanimelist/character" )
if malID != "" {
malIDToCharacters [ malID ] = append ( malIDToCharacters [ malID ] , character )
}
}
for _ , characters := range malIDToCharacters {
if len ( characters ) > 1 {
sort . Slice ( characters , func ( i , j int ) bool {
return len ( characters [ i ] . Likes ) > len ( characters [ j ] . Likes )
} )
for index , character := range characters {
if index == 0 {
continue
}
fmt . Printf ( "Merging '%s' with '%s' (%s to %s)\n" , color . YellowString ( character . String ( ) ) , color . YellowString ( characters [ 0 ] . String ( ) ) , character . ID , characters [ 0 ] . ID )
character . Merge ( characters [ 0 ] )
}
}
}
}