update to latest sentriz/taggolib

This commit is contained in:
sentriz
2019-06-07 17:13:40 +01:00
parent c96fdf458f
commit 188b52bc61
5 changed files with 28 additions and 62 deletions

View File

@@ -15,6 +15,7 @@ import (
"github.com/sentriz/gonic/mime"
"github.com/sentriz/gonic/model"
"github.com/sentriz/taggolib"
)
var (
@@ -36,6 +37,19 @@ var coverFilenames = map[string]struct{}{
"front.jpeg": {},
}
func readTags(path string) (taggolib.Parser, error) {
track, err := os.Open(path)
if err != nil {
return nil, errors.Wrap(err, "reading disk")
}
defer track.Close()
parser, err := taggolib.New(track)
if err != nil {
return nil, errors.Wrap(err, "parsing")
}
return parser, nil
}
type Scanner struct {
db, tx *gorm.DB
musicPath string
@@ -262,8 +276,8 @@ func (s *Scanner) handleTrack(it *item) error {
track.TagTrackArtist = tags.Artist()
track.TagTrackNumber = tags.TrackNumber()
track.TagDiscNumber = tags.DiscNumber()
track.Duration = tags.DurationSecs() // these two should be calculated
track.Bitrate = tags.Bitrate() // from the file instead of tags
track.Duration = tags.Duration() // these two should be calculated
track.Bitrate = tags.Bitrate() // from the file instead of tags
//
// set album artist basics
artist := &model.Artist{}