Added missing Kitsu mappings list for editors

This commit is contained in:
Eduard Urbach 2019-11-04 15:29:50 +09:00
parent 9d97be7c15
commit 604dc3c755
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
4 changed files with 22 additions and 191 deletions

View File

@ -869,194 +869,3 @@ func FilterAnime(filter func(*Anime) bool) []*Anime {
return filtered return filtered
} }
// // SetID performs a database-wide ID change.
// // Calling this will automatically save the anime.
// func (anime *Anime) SetID(newID string) {
// oldID := anime.ID
// // Update anime ID in character list
// characters, _ := GetAnimeCharacters(oldID)
// characters.Delete()
// characters.AnimeID = newID
// characters.Save()
// // Update anime ID in relation list
// relations, _ := GetAnimeRelations(oldID)
// relations.Delete()
// relations.AnimeID = newID
// relations.Save()
// // Update anime ID in episode list
// episodes, _ := GetAnimeEpisodes(oldID)
// episodes.Delete()
// episodes.AnimeID = newID
// episodes.Save()
// // Update anime list items
// for animeList := range StreamAnimeLists() {
// item := animeList.Find(oldID)
// if item != nil {
// item.AnimeID = newID
// animeList.Save()
// }
// }
// // Update relations pointing to this anime
// for relations := range StreamAnimeRelations() {
// relation := relations.Find(oldID)
// if relation != nil {
// relation.AnimeID = newID
// relations.Save()
// }
// }
// // Update quotes
// for quote := range StreamQuotes() {
// if quote.AnimeID == oldID {
// quote.AnimeID = newID
// quote.Save()
// }
// }
// // Update log entries
// for entry := range StreamEditLogEntries() {
// switch entry.ObjectType {
// case "Anime", "AnimeRelations", "AnimeCharacters", "AnimeEpisodes":
// if entry.ObjectID == oldID {
// entry.ObjectID = newID
// entry.Save()
// }
// }
// }
// // Update ignored anime differences
// for ignore := range StreamIgnoreAnimeDifferences() {
// // ID example: arn:10052|mal:28701|RomajiTitle
// arnPart := strings.Split(ignore.ID, "|")[0]
// actualID := strings.Split(arnPart, ":")[1]
// if actualID == oldID {
// DB.Delete("IgnoreAnimeDifference", ignore.ID)
// ignore.ID = strings.Replace(ignore.ID, arnPart, "arn:"+newID, 1)
// ignore.Save()
// }
// }
// // Update soundtrack tags
// for track := range StreamSoundTracks() {
// newTags := []string{}
// modified := false
// for _, tag := range track.Tags {
// if strings.HasPrefix(tag, "anime:") {
// parts := strings.Split(tag, ":")
// id := parts[1]
// if id == oldID {
// newTags = append(newTags, "anime:"+newID)
// modified = true
// continue
// }
// }
// newTags = append(newTags, tag)
// }
// if modified {
// track.Tags = newTags
// track.Save()
// }
// }
// // Update images on file system
// anime.MoveImageFiles(oldID, newID)
// // Delete old anime ID
// DB.Delete("Anime", oldID)
// // Change anime ID and save it
// anime.ID = newID
// anime.Save()
// }
// // MoveImageFiles ...
// func (anime *Anime) MoveImageFiles(oldID string, newID string) {
// if anime.Image.Extension == "" {
// return
// }
// err := os.Rename(
// path.Join(Root, "images/anime/original/", oldID+anime.Image.Extension),
// path.Join(Root, "images/anime/original/", newID+anime.Image.Extension),
// )
// if err != nil {
// // Don't return the error.
// // It's too late to stop the process at this point.
// // Instead, log the error.
// color.Red(err.Error())
// }
// os.Rename(
// path.Join(Root, "images/anime/large/", oldID+".jpg"),
// path.Join(Root, "images/anime/large/", newID+".jpg"),
// )
// os.Rename(
// path.Join(Root, "images/anime/large/", oldID+"@2.jpg"),
// path.Join(Root, "images/anime/large/", newID+"@2.jpg"),
// )
// os.Rename(
// path.Join(Root, "images/anime/large/", oldID+".webp"),
// path.Join(Root, "images/anime/large/", newID+".webp"),
// )
// os.Rename(
// path.Join(Root, "images/anime/large/", oldID+"@2.webp"),
// path.Join(Root, "images/anime/large/", newID+"@2.webp"),
// )
// os.Rename(
// path.Join(Root, "images/anime/medium/", oldID+".jpg"),
// path.Join(Root, "images/anime/medium/", newID+".jpg"),
// )
// os.Rename(
// path.Join(Root, "images/anime/medium/", oldID+"@2.jpg"),
// path.Join(Root, "images/anime/medium/", newID+"@2.jpg"),
// )
// os.Rename(
// path.Join(Root, "images/anime/medium/", oldID+".webp"),
// path.Join(Root, "images/anime/medium/", newID+".webp"),
// )
// os.Rename(
// path.Join(Root, "images/anime/medium/", oldID+"@2.webp"),
// path.Join(Root, "images/anime/medium/", newID+"@2.webp"),
// )
// os.Rename(
// path.Join(Root, "images/anime/small/", oldID+".jpg"),
// path.Join(Root, "images/anime/small/", newID+".jpg"),
// )
// os.Rename(
// path.Join(Root, "images/anime/small/", oldID+"@2.jpg"),
// path.Join(Root, "images/anime/small/", newID+"@2.jpg"),
// )
// os.Rename(
// path.Join(Root, "images/anime/small/", oldID+".webp"),
// path.Join(Root, "images/anime/small/", newID+".webp"),
// )
// os.Rename(
// path.Join(Root, "images/anime/small/", oldID+"@2.webp"),
// path.Join(Root, "images/anime/small/", newID+"@2.webp"),
// )
// }

View File

@ -77,6 +77,7 @@ component EditorTabs(url string, user *arn.User)
Tab("MAL", "arrows-h", "/editor/anime/mapping/mal" + user.Settings().Editor.Filter.Suffix()) Tab("MAL", "arrows-h", "/editor/anime/mapping/mal" + user.Settings().Editor.Filter.Suffix())
Tab("Shoboi", "arrows-h", "/editor/anime/mapping/shoboi" + user.Settings().Editor.Filter.Suffix()) Tab("Shoboi", "arrows-h", "/editor/anime/mapping/shoboi" + user.Settings().Editor.Filter.Suffix())
Tab("AniList", "arrows-h", "/editor/anime/mapping/anilist" + user.Settings().Editor.Filter.Suffix()) Tab("AniList", "arrows-h", "/editor/anime/mapping/anilist" + user.Settings().Editor.Filter.Suffix())
Tab("Kitsu", "arrows-h", "/editor/anime/mapping/kitsu" + user.Settings().Editor.Filter.Suffix())
Tab("Duplicate", "exclamation-circle", "/editor/anime/mapping/duplicate" + user.Settings().Editor.Filter.Suffix()) Tab("Duplicate", "exclamation-circle", "/editor/anime/mapping/duplicate" + user.Settings().Editor.Filter.Suffix())
if strings.Contains(url, "/editor/anime/image/") if strings.Contains(url, "/editor/anime/image/")

View File

@ -0,0 +1,20 @@
package filteranime
import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
)
// Kitsu ...
func Kitsu(ctx aero.Context) error {
return editorList(
ctx,
"Anime without Kitsu mappings",
func(anime *arn.Anime) bool {
return anime.GetMapping("kitsu/anime") == ""
},
func(anime *arn.Anime) string {
return "https://kitsu.io/anime?text=" + anime.Title.Canonical
},
)
}

View File

@ -26,6 +26,7 @@ func Register(app *aero.Application) {
editorFilterable("/editor/anime/mapping/shoboi", filteranime.Shoboi) editorFilterable("/editor/anime/mapping/shoboi", filteranime.Shoboi)
editorFilterable("/editor/anime/mapping/anilist", filteranime.AniList) editorFilterable("/editor/anime/mapping/anilist", filteranime.AniList)
editorFilterable("/editor/anime/mapping/mal", filteranime.MAL) editorFilterable("/editor/anime/mapping/mal", filteranime.MAL)
editorFilterable("/editor/anime/mapping/kitsu", filteranime.Kitsu)
editorFilterable("/editor/anime/mapping/duplicate", filteranime.DuplicateMappings) editorFilterable("/editor/anime/mapping/duplicate", filteranime.DuplicateMappings)
editorFilterable("/editor/anime/image/lowres", filteranime.LowResolutionAnimeImages) editorFilterable("/editor/anime/image/lowres", filteranime.LowResolutionAnimeImages)