diff --git a/jobs/mal-import/mal-import.go b/jobs/mal-import/mal-import.go index a2d89c2f..508da394 100644 --- a/jobs/mal-import/mal-import.go +++ b/jobs/mal-import/mal-import.go @@ -55,7 +55,7 @@ func readFile(name string) error { return errors.New("Empty ID") } - fmt.Println(anime.ID, anime.Title) + // fmt.Println(anime.ID, anime.Title) arn.MAL.Set("Anime", anime.ID, anime) return nil } diff --git a/pages/editor/mal.go b/pages/editor/mal.go index 1cb5db9a..f7c66eeb 100644 --- a/pages/editor/mal.go +++ b/pages/editor/mal.go @@ -12,7 +12,7 @@ import ( "github.com/animenotifier/notify.moe/utils" ) -const maxCompareMALEntries = 10 +const maxCompareMALEntries = 15 // CompareMAL ... func CompareMAL(ctx *aero.Context) string { @@ -86,6 +86,71 @@ func CompareMAL(ctx *aero.Context) string { } } + // Romaji title + if anime.Title.Romaji != malAnime.Title { + hash := utils.HashString(malAnime.Title) + + if !arn.IsAnimeDifferenceIgnored(anime.ID, "mal", malAnime.ID, "RomajiTitle", hash) { + differences = append(differences, &animediff.RomajiTitle{ + TitleA: anime.Title.Romaji, + TitleB: malAnime.Title, + NumericHash: hash, + }) + } + } + + // Airing start date + if anime.StartDate != malAnime.StartDate { + hash := utils.HashString(malAnime.StartDate) + + if !arn.IsAnimeDifferenceIgnored(anime.ID, "mal", malAnime.ID, "StartDate", hash) { + differences = append(differences, &animediff.StartDate{ + DateA: anime.StartDate, + DateB: malAnime.StartDate, + NumericHash: hash, + }) + } + } + + // Airing end date + if anime.EndDate != malAnime.EndDate && malAnime.EndDate != "" { + hash := utils.HashString(malAnime.EndDate) + + if !arn.IsAnimeDifferenceIgnored(anime.ID, "mal", malAnime.ID, "EndDate", hash) { + differences = append(differences, &animediff.EndDate{ + DateA: anime.EndDate, + DateB: malAnime.EndDate, + NumericHash: hash, + }) + } + } + + // Status + if anime.Status != malAnime.Status { + hash := utils.HashString(malAnime.Status) + + if !arn.IsAnimeDifferenceIgnored(anime.ID, "mal", malAnime.ID, "Status", hash) { + differences = append(differences, &animediff.Status{ + StatusA: anime.Status, + StatusB: malAnime.Status, + NumericHash: hash, + }) + } + } + + // EpisodeCount + if anime.EpisodeCount != malAnime.EpisodeCount { + hash := uint64(malAnime.EpisodeCount) + + if !arn.IsAnimeDifferenceIgnored(anime.ID, "mal", malAnime.ID, "EpisodeCount", hash) { + differences = append(differences, &animediff.EpisodeCount{ + EpisodesA: anime.EpisodeCount, + EpisodesB: malAnime.EpisodeCount, + NumericHash: hash, + }) + } + } + // Synopsis if len(anime.Summary) < len(malAnime.Synopsis) { hash := utils.HashString(malAnime.Synopsis) diff --git a/utils/animediff/EndDate.go b/utils/animediff/EndDate.go new file mode 100644 index 00000000..2c657888 --- /dev/null +++ b/utils/animediff/EndDate.go @@ -0,0 +1,33 @@ +package animediff + +// EndDate describes differing Romaji titles. +type EndDate struct { + DateA string + DateB string + NumericHash uint64 +} + +// Type returns the diff type. +func (diff *EndDate) Type() string { + return "EndDate" +} + +// Explanation returns the description. +func (diff *EndDate) Explanation() string { + return "End dates are different" +} + +// DetailsA shows the details for the first anime. +func (diff *EndDate) DetailsA() string { + return diff.DateA +} + +// DetailsB shows the details for the second anime. +func (diff *EndDate) DetailsB() string { + return diff.DateB +} + +// Hash returns the hash for the suggested value (from anime B). +func (diff *EndDate) Hash() uint64 { + return diff.NumericHash +} diff --git a/utils/animediff/EpisodeCount.go b/utils/animediff/EpisodeCount.go new file mode 100644 index 00000000..96d130ec --- /dev/null +++ b/utils/animediff/EpisodeCount.go @@ -0,0 +1,35 @@ +package animediff + +import "strconv" + +// EpisodeCount ... +type EpisodeCount struct { + EpisodesA int + EpisodesB int + NumericHash uint64 +} + +// Type returns the diff type. +func (diff *EpisodeCount) Type() string { + return "EpisodeCount" +} + +// Explanation returns the description. +func (diff *EpisodeCount) Explanation() string { + return "Episode counts are different" +} + +// DetailsA shows the details for the first anime. +func (diff *EpisodeCount) DetailsA() string { + return strconv.Itoa(diff.EpisodesA) +} + +// DetailsB shows the details for the second anime. +func (diff *EpisodeCount) DetailsB() string { + return strconv.Itoa(diff.EpisodesB) +} + +// Hash returns the hash for the suggested value (from anime B). +func (diff *EpisodeCount) Hash() uint64 { + return diff.NumericHash +} diff --git a/utils/animediff/RomajiTitle.go b/utils/animediff/RomajiTitle.go new file mode 100644 index 00000000..05b9031a --- /dev/null +++ b/utils/animediff/RomajiTitle.go @@ -0,0 +1,33 @@ +package animediff + +// RomajiTitle describes differing Romaji titles. +type RomajiTitle struct { + TitleA string + TitleB string + NumericHash uint64 +} + +// Type returns the diff type. +func (diff *RomajiTitle) Type() string { + return "RomajiTitle" +} + +// Explanation returns the description. +func (diff *RomajiTitle) Explanation() string { + return "Romaji titles are different" +} + +// DetailsA shows the details for the first anime. +func (diff *RomajiTitle) DetailsA() string { + return diff.TitleA +} + +// DetailsB shows the details for the second anime. +func (diff *RomajiTitle) DetailsB() string { + return diff.TitleB +} + +// Hash returns the hash for the suggested value (from anime B). +func (diff *RomajiTitle) Hash() uint64 { + return diff.NumericHash +} diff --git a/utils/animediff/StartDate.go b/utils/animediff/StartDate.go new file mode 100644 index 00000000..f3033dc5 --- /dev/null +++ b/utils/animediff/StartDate.go @@ -0,0 +1,33 @@ +package animediff + +// StartDate describes differing Romaji titles. +type StartDate struct { + DateA string + DateB string + NumericHash uint64 +} + +// Type returns the diff type. +func (diff *StartDate) Type() string { + return "StartDate" +} + +// Explanation returns the description. +func (diff *StartDate) Explanation() string { + return "Start dates are different" +} + +// DetailsA shows the details for the first anime. +func (diff *StartDate) DetailsA() string { + return diff.DateA +} + +// DetailsB shows the details for the second anime. +func (diff *StartDate) DetailsB() string { + return diff.DateB +} + +// Hash returns the hash for the suggested value (from anime B). +func (diff *StartDate) Hash() uint64 { + return diff.NumericHash +} diff --git a/utils/animediff/Status.go b/utils/animediff/Status.go new file mode 100644 index 00000000..f8f18386 --- /dev/null +++ b/utils/animediff/Status.go @@ -0,0 +1,33 @@ +package animediff + +// Status describes differing Romaji titles. +type Status struct { + StatusA string + StatusB string + NumericHash uint64 +} + +// Type returns the diff type. +func (diff *Status) Type() string { + return "Status" +} + +// Explanation returns the description. +func (diff *Status) Explanation() string { + return "Status is different" +} + +// DetailsA shows the details for the first anime. +func (diff *Status) DetailsA() string { + return diff.StatusA +} + +// DetailsB shows the details for the second anime. +func (diff *Status) DetailsB() string { + return diff.StatusB +} + +// Hash returns the hash for the suggested value (from anime B). +func (diff *Status) Hash() uint64 { + return diff.NumericHash +}