mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-16 02:45:54 -07:00
Pre-release version v0.0.13 (#52)
* feat: search/merge items by id * feat: update track duration using musicbrainz * chore: changelog * fix: make username updates case insensitive * feat: add minutes listened to ui and fix image drop * chore: changelog * fix: embed db migrations (#37) * feat: Add support for ARM in publish workflow (#51) * chore: changelog * docs: search by id and custom theme support --------- Co-authored-by: potatoattack <lvl70nub@gmail.com> Co-authored-by: Benjamin Jonard <benjaminjonard@users.noreply.github.com>
This commit is contained in:
parent
5537b6fb89
commit
5419178012
32 changed files with 1252 additions and 100 deletions
|
|
@ -134,15 +134,35 @@ func SubmitListen(ctx context.Context, store db.DB, opts SubmitListenOpts) error
|
|||
}
|
||||
l.Debug().Any("track", track).Msg("Matched listen to track")
|
||||
|
||||
if track.Duration == 0 && opts.Duration != 0 {
|
||||
err := store.UpdateTrack(ctx, db.UpdateTrackOpts{
|
||||
ID: track.ID,
|
||||
Duration: opts.Duration,
|
||||
})
|
||||
if err != nil {
|
||||
l.Err(err).Msgf("Failed to update duration for track %s", track.Title)
|
||||
if track.Duration == 0 {
|
||||
if opts.Duration != 0 {
|
||||
l.Debug().Msg("Updating duration using request information")
|
||||
err := store.UpdateTrack(ctx, db.UpdateTrackOpts{
|
||||
ID: track.ID,
|
||||
Duration: opts.Duration,
|
||||
})
|
||||
if err != nil {
|
||||
l.Err(err).Msgf("Failed to update duration for track %s", track.Title)
|
||||
} else {
|
||||
l.Info().Msgf("Duration updated to %d for track '%s'", opts.Duration, track.Title)
|
||||
}
|
||||
} else if track.MbzID != nil && *track.MbzID != uuid.Nil {
|
||||
l.Debug().Msg("Attempting to update duration using MusicBrainz ID")
|
||||
mbztrack, err := opts.MbzCaller.GetTrack(ctx, *track.MbzID)
|
||||
if err != nil {
|
||||
l.Err(err).Msg("Failed to make request to MusicBrainz")
|
||||
} else {
|
||||
err = store.UpdateTrack(ctx, db.UpdateTrackOpts{
|
||||
ID: track.ID,
|
||||
Duration: int32(mbztrack.LengthMs / 1000),
|
||||
})
|
||||
if err != nil {
|
||||
l.Err(err).Msgf("Failed to update duration for track %s", track.Title)
|
||||
} else {
|
||||
l.Info().Msgf("Duration updated to %d for track '%s'", mbztrack.LengthMs/1000, track.Title)
|
||||
}
|
||||
}
|
||||
}
|
||||
l.Info().Msgf("Duration updated to %d for track '%s'", opts.Duration, track.Title)
|
||||
}
|
||||
|
||||
if opts.SkipSaveListen {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue