(filePaths []string, index int)
| 10 | ) |
| 11 | |
| 12 | func (a *App) processBatchLyrics(filePaths []string, index int) tea.Cmd { |
| 13 | if index >= len(filePaths) { |
| 14 | return nil |
| 15 | } |
| 16 | |
| 17 | filePath := filePaths[index] |
| 18 | |
| 19 | return func() tea.Msg { |
| 20 | te := mp3.NewTagEditor() |
| 21 | lf := fetcher.NewLyricsFetcher() |
| 22 | |
| 23 | tags, err := te.ReadTags(filePath) |
| 24 | if err != nil { |
| 25 | return BatchProcessMsg{ |
| 26 | FilePath: filePath, |
| 27 | Success: false, |
| 28 | Error: err, |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | lyrics, err := lf.Fetch(tags.Title, tags.Artist) |
| 33 | if err != nil { |
| 34 | return BatchProcessMsg{ |
| 35 | FilePath: filePath, |
| 36 | Success: false, |
| 37 | Error: err, |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | updates := mp3.TagUpdates{ |
| 42 | Lyrics: lyrics, |
| 43 | } |
| 44 | err = te.EditTags(filePath, updates) |
| 45 | if err != nil { |
| 46 | return BatchProcessMsg{ |
| 47 | FilePath: filePath, |
| 48 | Success: false, |
| 49 | Error: err, |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | return BatchProcessMsg{ |
| 54 | FilePath: filePath, |
| 55 | Success: true, |
| 56 | Error: nil, |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | func (a *App) processBatchArtwork(filePaths []string, index int) tea.Cmd { |
| 62 | if index >= len(filePaths) { |
no test coverage detected