mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-17 11:16:35 -07:00
feat: time-gated imports via cfg
This commit is contained in:
parent
6d000d87e4
commit
c14df8c2fb
6 changed files with 59 additions and 4 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue