Created animediff package
This commit is contained in:
@ -1,22 +0,0 @@
|
||||
package utils
|
||||
|
||||
// AnimeTitleDiff describes differing titles.
|
||||
type AnimeTitleDiff struct {
|
||||
TitleA string
|
||||
TitleB string
|
||||
}
|
||||
|
||||
// String returns the description.
|
||||
func (diff *AnimeTitleDiff) String() string {
|
||||
return "Titles are different"
|
||||
}
|
||||
|
||||
// DetailsA shows the details for the first anime.
|
||||
func (diff *AnimeTitleDiff) DetailsA() string {
|
||||
return diff.TitleA
|
||||
}
|
||||
|
||||
// DetailsB shows the details for the second anime.
|
||||
func (diff *AnimeTitleDiff) DetailsB() string {
|
||||
return diff.TitleB
|
||||
}
|
17
utils/HashStrings.go
Normal file
17
utils/HashStrings.go
Normal file
@ -0,0 +1,17 @@
|
||||
package utils
|
||||
|
||||
import "github.com/OneOfOne/xxhash"
|
||||
|
||||
// HashStringsNoOrder returns a hash of the string slice contents, ignoring order.
|
||||
func HashStringsNoOrder(items []string) uint64 {
|
||||
sum := uint64(0)
|
||||
|
||||
for _, item := range items {
|
||||
h := xxhash.NewS64(0)
|
||||
h.Write([]byte(item))
|
||||
numHash := h.Sum64()
|
||||
sum += numHash
|
||||
}
|
||||
|
||||
return sum
|
||||
}
|
@ -3,18 +3,12 @@ package utils
|
||||
import (
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/mal"
|
||||
"github.com/animenotifier/notify.moe/utils/animediff"
|
||||
)
|
||||
|
||||
// AnimeDiff describes a difference between two anime.
|
||||
type AnimeDiff interface {
|
||||
String() string
|
||||
DetailsA() string
|
||||
DetailsB() string
|
||||
}
|
||||
|
||||
// MALComparison encapsulates the difference between an ARN anime and a MAL anime.
|
||||
type MALComparison struct {
|
||||
Anime *arn.Anime
|
||||
MALAnime *mal.Anime
|
||||
Differences []AnimeDiff
|
||||
Differences []animediff.Difference
|
||||
}
|
||||
|
22
utils/animediff/CanonicalTitle.go
Normal file
22
utils/animediff/CanonicalTitle.go
Normal file
@ -0,0 +1,22 @@
|
||||
package animediff
|
||||
|
||||
// CanonicalTitle describes differing titles.
|
||||
type CanonicalTitle struct {
|
||||
TitleA string
|
||||
TitleB string
|
||||
}
|
||||
|
||||
// String returns the description.
|
||||
func (diff *CanonicalTitle) String() string {
|
||||
return "Canonical titles are different"
|
||||
}
|
||||
|
||||
// DetailsA shows the details for the first anime.
|
||||
func (diff *CanonicalTitle) DetailsA() string {
|
||||
return diff.TitleA
|
||||
}
|
||||
|
||||
// DetailsB shows the details for the second anime.
|
||||
func (diff *CanonicalTitle) DetailsB() string {
|
||||
return diff.TitleB
|
||||
}
|
@ -1,24 +1,24 @@
|
||||
package utils
|
||||
package animediff
|
||||
|
||||
import "strings"
|
||||
|
||||
// AnimeGenresDiff describes differing genres.
|
||||
type AnimeGenresDiff struct {
|
||||
// Genres describes differing genres.
|
||||
type Genres struct {
|
||||
GenresA []string
|
||||
GenresB []string
|
||||
}
|
||||
|
||||
// String returns the description.
|
||||
func (diff *AnimeGenresDiff) String() string {
|
||||
func (diff *Genres) String() string {
|
||||
return "Genres are different"
|
||||
}
|
||||
|
||||
// DetailsA shows the details for the first anime.
|
||||
func (diff *AnimeGenresDiff) DetailsA() string {
|
||||
func (diff *Genres) DetailsA() string {
|
||||
return strings.Join(diff.GenresA, ", ")
|
||||
}
|
||||
|
||||
// DetailsB shows the details for the second anime.
|
||||
func (diff *AnimeGenresDiff) DetailsB() string {
|
||||
func (diff *Genres) DetailsB() string {
|
||||
return strings.Join(diff.GenresB, ", ")
|
||||
}
|
8
utils/animediff/Interface.go
Normal file
8
utils/animediff/Interface.go
Normal file
@ -0,0 +1,8 @@
|
||||
package animediff
|
||||
|
||||
// Difference describes a difference between two anime.
|
||||
type Difference interface {
|
||||
String() string
|
||||
DetailsA() string
|
||||
DetailsB() string
|
||||
}
|
22
utils/animediff/JapaneseTitle.go
Normal file
22
utils/animediff/JapaneseTitle.go
Normal file
@ -0,0 +1,22 @@
|
||||
package animediff
|
||||
|
||||
// JapaneseTitle describes differing Japanese titles.
|
||||
type JapaneseTitle struct {
|
||||
TitleA string
|
||||
TitleB string
|
||||
}
|
||||
|
||||
// String returns the description.
|
||||
func (diff *JapaneseTitle) String() string {
|
||||
return "Japanese titles are different"
|
||||
}
|
||||
|
||||
// DetailsA shows the details for the first anime.
|
||||
func (diff *JapaneseTitle) DetailsA() string {
|
||||
return diff.TitleA
|
||||
}
|
||||
|
||||
// DetailsB shows the details for the second anime.
|
||||
func (diff *JapaneseTitle) DetailsB() string {
|
||||
return diff.TitleB
|
||||
}
|
Reference in New Issue
Block a user