(filePaths []string, index int)
| 59 | } |
| 60 | |
| 61 | func (a *App) processBatchArtwork(filePaths []string, index int) tea.Cmd { |
| 62 | if index >= len(filePaths) { |
| 63 | return nil |
| 64 | } |
| 65 | |
| 66 | filePath := filePaths[index] |
| 67 | |
| 68 | return func() tea.Msg { |
| 69 | te := mp3.NewTagEditor() |
| 70 | af := fetcher.NewArtworkFetcher() |
| 71 | |
| 72 | tags, err := te.ReadTags(filePath) |
| 73 | if err != nil { |
| 74 | return BatchProcessMsg{ |
| 75 | FilePath: filePath, |
| 76 | Success: false, |
| 77 | Error: err, |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | artwork, err := af.Fetch(tags.Title, tags.Artist, tags.Album) |
| 82 | if err != nil { |
| 83 | return BatchProcessMsg{ |
| 84 | FilePath: filePath, |
| 85 | Success: false, |
| 86 | Error: err, |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | updates := mp3.TagUpdates{ |
| 91 | Artwork: artwork, |
| 92 | } |
| 93 | err = te.EditTags(filePath, updates) |
| 94 | if err != nil { |
| 95 | return BatchProcessMsg{ |
| 96 | FilePath: filePath, |
| 97 | Success: false, |
| 98 | Error: err, |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | return BatchProcessMsg{ |
| 103 | FilePath: filePath, |
| 104 | Success: true, |
| 105 | Error: nil, |
| 106 | } |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | func (a *App) processBatchBoth(filePaths []string, index int) tea.Cmd { |
| 111 | if index >= len(filePaths) { |
no test coverage detected