feat: time-gated imports via cfg

This commit is contained in:
Gabe Farrell 2025-06-13 05:36:41 -04:00
parent 6d000d87e4
commit c14df8c2fb
6 changed files with 59 additions and 4 deletions

View file

@ -43,10 +43,15 @@ func ImportSpotifyFile(ctx context.Context, store db.DB, filename string) error
if err != nil {
return err
}
for _, item := range export {
if item.ReasonEnd != "trackdone" {
continue
}
if !inImportTimeWindow(item.Timestamp) {
l.Debug().Msgf("Skipping import due to import time rules")
continue
}
dur := item.MsPlayed
if item.TrackName == "" || item.ArtistName == "" {
l.Debug().Msg("Skipping non-track item")
@ -58,7 +63,7 @@ func ImportSpotifyFile(ctx context.Context, store db.DB, filename string) error
TrackTitle: item.TrackName,
ReleaseTitle: item.AlbumName,
Duration: dur / 1000,
Time: item.Timestamp.UTC(),
Time: item.Timestamp,
UserID: 1,
}
err = catalog.SubmitListen(ctx, store, opts)