From 9c68ecb4bb386a771d312c1679300f6357125dc3 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Wed, 25 Apr 2018 16:13:03 +0200 Subject: [PATCH] Added unaligned lyrics filter for soundtracks --- pages/editor/editor.pixy | 7 ++++++- pages/editor/filtersoundtracks/lyrics.go | 18 ++++++++++++++++-- pages/index.go | 3 ++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/pages/editor/editor.pixy b/pages/editor/editor.pixy index b9e3f164..923630d3 100644 --- a/pages/editor/editor.pixy +++ b/pages/editor/editor.pixy @@ -86,10 +86,15 @@ component EditorTabs(url string, user *arn.User) if strings.Contains(url, "/editor/soundtracks/") .tabs Tab("Links", "external-link", "/editor/soundtracks/links") - Tab("Lyrics", "font", "/editor/soundtracks/lyrics") + Tab("Lyrics", "font", "/editor/soundtracks/lyrics/missing") Tab("Tags", "tag", "/editor/soundtracks/tags") Tab("File", "volume-off", "/editor/soundtracks/file") + if strings.Contains(url, "/editor/soundtracks/lyrics/") + .tabs + Tab("Missing", "times", "/editor/soundtracks/lyrics/missing") + Tab("Unaligned", "align-left", "/editor/soundtracks/lyrics/unaligned") + if strings.Contains(url, "/editor/anime/") || strings.Contains(url, "/editor/mal/diff/anime") .editor-filters #filter-root(data-url=url) diff --git a/pages/editor/filtersoundtracks/lyrics.go b/pages/editor/filtersoundtracks/lyrics.go index 89a8e0c9..8ba341b6 100644 --- a/pages/editor/filtersoundtracks/lyrics.go +++ b/pages/editor/filtersoundtracks/lyrics.go @@ -1,12 +1,14 @@ package filtersoundtracks import ( + "strings" + "github.com/aerogo/aero" "github.com/animenotifier/arn" ) -// Lyrics shows soundtracks without lyrics. -func Lyrics(ctx *aero.Context) string { +// MissingLyrics shows soundtracks without lyrics. +func MissingLyrics(ctx *aero.Context) string { return editorList( ctx, "Soundtracks without lyrics", @@ -18,3 +20,15 @@ func Lyrics(ctx *aero.Context) string { }, ) } + +// UnalignedLyrics shows soundtracks with unaligned lyrics. +func UnalignedLyrics(ctx *aero.Context) string { + return editorList( + ctx, + "Soundtracks with unaligned lyrics", + func(track *arn.SoundTrack) bool { + return track.Lyrics.Native != "" && track.Lyrics.Romaji != "" && strings.Count(track.Lyrics.Native, "\n") != strings.Count(track.Lyrics.Romaji, "\n") + }, + nil, + ) +} diff --git a/pages/index.go b/pages/index.go index fdda298c..c390567f 100644 --- a/pages/index.go +++ b/pages/index.go @@ -338,7 +338,8 @@ func Configure(app *aero.Application) { // Editor - Soundtracks l.Page("/editor/soundtracks/links", filtersoundtracks.Links) - l.Page("/editor/soundtracks/lyrics", filtersoundtracks.Lyrics) + l.Page("/editor/soundtracks/lyrics/missing", filtersoundtracks.MissingLyrics) + l.Page("/editor/soundtracks/lyrics/unaligned", filtersoundtracks.UnalignedLyrics) l.Page("/editor/soundtracks/tags", filtersoundtracks.Tags) l.Page("/editor/soundtracks/file", filtersoundtracks.File)