MCPcopy Create free account
hub / github.com/capable-average/tagTonic / processBatchArtwork

Method processBatchArtwork

tui/batch.go:61–108  ·  view source on GitHub ↗
(filePaths []string, index int)

Source from the content-addressed store, hash-verified

59}
60
61func (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
110func (a *App) processBatchBoth(filePaths []string, index int) tea.Cmd {
111 if index >= len(filePaths) {

Callers 2

batchFetchArtworkMethod · 0.95
UpdateMethod · 0.95

Calls 5

ReadTagsMethod · 0.95
FetchMethod · 0.95
EditTagsMethod · 0.95
NewTagEditorFunction · 0.92
NewArtworkFetcherFunction · 0.92

Tested by

no test coverage detected