mirror of
https://github.com/cgzirim/seek-tune.git
synced 2025-12-16 16:34:21 +00:00
refactor(downloader): remove WAV conversion step and update audio download function
- Remove unused wav package import and WAV conversion logic - Pass original downloaded audio file directly to fingerprinting - Update calls from downloadYTaudio2 → downloadYTaudio after function rename
This commit is contained in:
parent
95218512a6
commit
6f1111eb35
1 changed files with 3 additions and 10 deletions
|
|
@ -11,7 +11,6 @@ import (
|
|||
"song-recognition/db"
|
||||
"song-recognition/shazam"
|
||||
"song-recognition/utils"
|
||||
"song-recognition/wav"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
|
@ -134,7 +133,7 @@ func dlTrack(tracks []Track, path string) (int, error) {
|
|||
fileName := fmt.Sprintf("%s - %s", trackCopy.Title, trackCopy.Artist)
|
||||
filePath := filepath.Join(path, fileName)
|
||||
|
||||
filePath, err = downloadYTaudio2(ytID, filePath)
|
||||
filePath, err = downloadYTaudio(ytID, filePath)
|
||||
if err != nil {
|
||||
logMessage := fmt.Sprintf("'%s' by '%s' could not be downloaded", trackCopy.Title, trackCopy.Artist)
|
||||
logger.ErrorContext(ctx, logMessage, slog.Any("error", xerrors.New(err)))
|
||||
|
|
@ -227,22 +226,16 @@ func ProcessAndSaveSong(songFilePath, songTitle, songArtist, ytID string) error
|
|||
}
|
||||
defer dbclient.Close()
|
||||
|
||||
wavFilePath, err := wav.ConvertToWAV(songFilePath)
|
||||
if err != nil {
|
||||
logger.Error("Failed to convert to WAV", slog.Any("error", err))
|
||||
return err
|
||||
}
|
||||
|
||||
songID, err := dbclient.RegisterSong(songTitle, songArtist, ytID)
|
||||
if err != nil {
|
||||
logger.Error("Failed to register song", slog.Any("error", err))
|
||||
return fmt.Errorf("error registering song '%s' by '%s': %v", songTitle, songArtist, err)
|
||||
}
|
||||
|
||||
fingerprint, err := shazam.FingerprintAudio(wavFilePath, songID)
|
||||
fingerprint, err := shazam.FingerprintAudio(songFilePath, songID)
|
||||
if err != nil {
|
||||
dbclient.DeleteSongByID(songID)
|
||||
logger.Error("Failed to create fingerprint", slog.String("wavFilePath", wavFilePath))
|
||||
logger.Error("Failed to create fingerprint", slog.String("wavFilePath", songFilePath))
|
||||
return fmt.Errorf("error generating fingerprint for %s by %s", songTitle, songArtist)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue