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

Function worker

cmd/batch.go:254–277  ·  view source on GitHub ↗
(ctx context.Context, jobs <-chan FileJob, results chan<- FileResult, wg *sync.WaitGroup, cfg *config.Config)

Source from the content-addressed store, hash-verified

252}
253
254func worker(ctx context.Context, jobs <-chan FileJob, results chan<- FileResult, wg *sync.WaitGroup, cfg *config.Config) {
255 defer wg.Done()
256
257 editor := mp3.NewTagEditor()
258
259 var lyricsFetcher fetcher.LyricsFetcher
260 if cfg.GeniusAPIKey != "" {
261 lyricsFetcher = fetcher.NewLyricsFetcherWithConfig(cfg.GeniusAPIKey)
262 } else {
263 lyricsFetcher = fetcher.NewLyricsFetcher()
264 }
265
266 artworkFetcher := fetcher.NewArtworkFetcher()
267
268 for job := range jobs {
269 select {
270 case <-ctx.Done():
271 return
272 default:
273 result := processFile(job.filepath, editor, lyricsFetcher, artworkFetcher)
274 results <- result
275 }
276 }
277}
278
279func processFile(filePath string, editor mp3.TagEditor, lyricsFetcher fetcher.LyricsFetcher, artworkFetcher fetcher.ArtworkFetcher) FileResult {
280 result := FileResult{filepath: filePath}

Callers 1

processBatchConcurrentlyFunction · 0.85

Calls 5

NewTagEditorFunction · 0.92
NewLyricsFetcherFunction · 0.92
NewArtworkFetcherFunction · 0.92
processFileFunction · 0.85

Tested by

no test coverage detected