Files
icecast-ripper/internal/hash/hash.go
Dmitry Andreev b5f23a50b7
Some checks failed
CodeQL / Analyze (go) (push) Has been cancelled
Docker / build (push) Has been cancelled
golangci-lint / lint (push) Has been cancelled
Integrate MP3 duration extraction and silence handling (#6)
* feat: integrate MP3 duration extraction and silence handling

- Added a new dependency on github.com/tcolgate/mp3 for MP3 frame decoding.
- Implemented actual MP3 duration retrieval in the scanRecordings function, falling back to an estimation if retrieval fails.
- Introduced a silent frame asset for generating silence in audio streams.
- Created a silence reader to provide a continuous stream of silent frames.
- Added necessary documentation and licensing for the new MP3 package.
- Updated .gitignore to exclude MP3 files except for the internal data directory.

* feat: update README and improve application configuration and logging

* refactor: remove unused GenerateFileHash function and improve resource cleanup in MP3 and recorder modules
2025-04-13 15:56:22 +03:00

29 lines
647 B
Go

package hash
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"path/filepath"
"time"
)
// GenerateGUID creates a unique identifier based on metadata
// Uses stream name, recording time and filename to create a deterministic GUID
func GenerateGUID(streamName string, recordedAt time.Time, filePath string) string {
filename := filepath.Base(filePath)
// Create a unique string combining metadata
input := fmt.Sprintf("%s:%s:%s",
streamName,
recordedAt.UTC().Format(time.RFC3339),
filename)
// Hash the combined string
hasher := sha256.New()
hasher.Write([]byte(input))
guid := hex.EncodeToString(hasher.Sum(nil))
return guid
}