This commit is contained in:
Mikkel Rask 2026-04-02 12:58:56 +00:00 committed by GitHub
commit 4da5c4baf6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View file

@ -274,7 +274,7 @@ func RunImporter(l *zerolog.Logger, store db.DB, mbzc mbz.MusicBrainzCaller) {
} }
if strings.Contains(file.Name(), "Streaming_History_Audio") { if strings.Contains(file.Name(), "Streaming_History_Audio") {
l.Info().Msgf("Importer: Import file %s detecting as being Spotify export", file.Name()) l.Info().Msgf("Importer: Import file %s detecting as being Spotify export", file.Name())
err := importer.ImportSpotifyFile(logger.NewContext(l), store, file.Name()) err := importer.ImportSpotifyFile(logger.NewContext(l), store, mbzc, file.Name())
if err != nil { if err != nil {
l.Err(err).Msgf("Importer: Failed to import file: %s", file.Name()) l.Err(err).Msgf("Importer: Failed to import file: %s", file.Name())
} }

View file

@ -12,7 +12,7 @@ import (
"github.com/gabehf/koito/internal/cfg" "github.com/gabehf/koito/internal/cfg"
"github.com/gabehf/koito/internal/db" "github.com/gabehf/koito/internal/db"
"github.com/gabehf/koito/internal/logger" "github.com/gabehf/koito/internal/logger"
"github.com/gabehf/koito/internal/mbz" mbz "github.com/gabehf/koito/internal/mbz"
) )
type SpotifyExportItem struct { type SpotifyExportItem struct {
@ -24,7 +24,7 @@ type SpotifyExportItem struct {
MsPlayed int32 `json:"ms_played"` MsPlayed int32 `json:"ms_played"`
} }
func ImportSpotifyFile(ctx context.Context, store db.DB, filename string) error { func ImportSpotifyFile(ctx context.Context, store db.DB, mbzc mbz.MusicBrainzCaller, filename string) error {
l := logger.FromContext(ctx) l := logger.FromContext(ctx)
l.Info().Msgf("Beginning spotify import on file: %s", filename) l.Info().Msgf("Beginning spotify import on file: %s", filename)
file, err := os.Open(path.Join(cfg.ConfigDir(), "import", filename)) file, err := os.Open(path.Join(cfg.ConfigDir(), "import", filename))
@ -59,7 +59,7 @@ func ImportSpotifyFile(ctx context.Context, store db.DB, filename string) error
continue continue
} }
opts := catalog.SubmitListenOpts{ opts := catalog.SubmitListenOpts{
MbzCaller: &mbz.MusicBrainzClient{}, MbzCaller: mbzc,
Artist: item.ArtistName, Artist: item.ArtistName,
TrackTitle: item.TrackName, TrackTitle: item.TrackName,
ReleaseTitle: item.AlbumName, ReleaseTitle: item.AlbumName,