remove commented out codes

This commit is contained in:
tramhao 2021-03-10 10:55:38 +08:00
parent 67def0a86d
commit f17c2cdcf6
5 changed files with 19 additions and 41 deletions

View File

@ -115,7 +115,7 @@ func NewFromLRC(s string) (res Lyric, err error) {
return
}
// parseSrtTime parses a lrc subtitle time (duration since start of film)
// parseLrcTime parses a lrc subtitle time (duration since start of film)
func parseLrcTime(in string) (time.Time, error) {
in = strings.TrimPrefix(in, "[")
in = strings.TrimSuffix(in, "]")
@ -181,7 +181,7 @@ func (lyric Lyric) AsLRC() (res string) {
return
}
// AsLRC renders the caption as lrc
// AsLRC renders the caption as one line in lrc
func (cap Caption) AsLRC() string {
// res := fmt.Sprintf("%d", cap.Caption.Seq) + eol +
// TimeLRC(cap.Caption.Start) + " --> " + TimeLRC(cap.Caption.End) + eol

View File

@ -14,12 +14,11 @@ type SongTag struct {
TitleForPopup string
LangExt string
ServiceProvider string
SongID string // SongID and LyricID is returned by cn server. It's not guaranteed to be identical
SongID string // SongID and LyricID is returned from cn server. It's not guaranteed to be identical
LyricID string
}
// GetLyric should receive url that was returned from GetLyricOptions. GetLyric
// returns lyric of the queried song.
// GetLyric return the actual function based on lang
func GetLyric(lang string, songTag *SongTag) (string, error) {
switch lang {
@ -33,8 +32,7 @@ func GetLyric(lang string, songTag *SongTag) (string, error) {
}
// GetLyricOptions queries available song lyrics. It returns map of title and
// url of the lyric.
// GetLyricOptions return the actual function based on lang
func GetLyricOptions(lang string, search string) ([]*SongTag, error) {
switch lang {

View File

@ -10,8 +10,7 @@ import (
"github.com/ztrue/tracerr"
)
// GetLyricOptionsChinese queries available song lyrics. It returns map of title and
// id of the lyric.
// getLyricOptionsCn queries available song lyrics. It returns slice of SongTag
func getLyricOptionsCn(search string) ([]*SongTag, error) {
serviceProvider := "netease"
@ -26,24 +25,12 @@ func getLyricOptionsCn(search string) ([]*SongTag, error) {
}
results = append(results, results2...)
// var results3 []*SongTag
// for _, v := range results {
// flag := 0
// for _, k := range results {
// if v.TitleForPopup == k.TitleForPopup {
// flag++
// }
// }
// if flag < 2 {
// results3 = append(results3, v)
// }
// }
return results, err
}
// GetLyricCn should receive songTag that was returned from GetLyricOptionsCn. GetLyricCn
// returns lyric of the queried song.
// getLyricCn should receive songTag that was returned from getLyricOptionsCn
// and returns lyric of the queried song.
func getLyricCn(songTag *SongTag) (string, error) {
var lyric string
@ -73,6 +60,7 @@ func getLyricCn(songTag *SongTag) (string, error) {
return "", errors.New("lyric not compatible")
}
// getLyricOptionsCnByProvider do the query by provider
func getLyricOptionsCnByProvider(search string, serviceProvider string) ([]*SongTag, error) {
var resultTags []*SongTag

View File

@ -8,7 +8,7 @@ import (
"github.com/gocolly/colly"
)
// GetLyric should receive url that was returned from GetLyricOptions. GetLyric
// getLyricEn should receive SongTag that was returned from GetLyricOptions, and
// returns lyric of the queried song.
func getLyricEn(songTag *SongTag) (string, error) {
@ -37,8 +37,7 @@ func getLyricEn(songTag *SongTag) (string, error) {
return "", fmt.Errorf("lyric not compatible")
}
// GetLyricOptions queries available song lyrics. It returns map of title and
// url of the lyric.
// getLyricOptionsEn queries available song lyrics. It returns slice of SongTag
func getLyricOptionsEn(search string) ([]*SongTag, error) {
var songTags []*SongTag

View File

@ -14,11 +14,13 @@ import (
"github.com/ztrue/tracerr"
)
// myFlex extend the flex control to modify the Focus item
type myFlex struct {
*tview.Flex
FocusedItem tview.Primitive
}
// tagPopup is used to edit tag, delete and fetch lyrics
func tagPopup(node *AudioFile) (err error) {
popupID := "tag-editor-input-popup"
@ -321,10 +323,6 @@ func tagPopup(node *AudioFile) (err error) {
rightFlex.SetDirection(tview.FlexColumn).
AddItem(lyricTextView, 0, 1, true)
// lyricFlex := tview.NewFlex().SetDirection(tview.FlexColumn).
// AddItem(leftGrid, 0, 2, true).
// AddItem(rightFlex, 0, 3, true)
lyricFlex := &myFlex{
tview.NewFlex().SetDirection(tview.FlexColumn).
AddItem(leftGrid, 0, 2, true).
@ -382,6 +380,7 @@ func tagPopup(node *AudioFile) (err error) {
return err
}
// This is a hack to cycle Focus in a flex
func (f *myFlex) cycleFocus(app *tview.Application, elements []tview.Primitive, reverse bool) {
for i, el := range elements {
if !el.HasFocus() {
@ -404,24 +403,18 @@ func (f *myFlex) cycleFocus(app *tview.Application, elements []tview.Primitive,
}
}
// Focus is an override of Focus function in tview.flex.
// This is to ensure that the focus of flex remain unchanged
// when returning from popups or search lists
func (f *myFlex) Focus(delegate func(p tview.Primitive)) {
// if f.FocusedItem != nil {
// delegate(f.FocusedItem)
// } else {
// f.Focus(f.FocusedItem)
// }
// for _, item := range f.Focus.items {
// if item.Item != nil && item.Focus {
// delegate(item.Item)
// return
// }
// }
if f.FocusedItem != nil {
gomu.app.SetFocus(f.FocusedItem)
} else {
f.Flex.Focus(delegate)
}
}
// loadTagMap will load from tag and return a map of langExt to lyrics
func loadTagMap(node *AudioFile) (tag *id3v2.Tag, popupLyricMap map[string]string, options []string, err error) {
popupLyricMap = make(map[string]string)