@@ -12,6 +12,7 @@ import (
1212 "github.com/devgianlu/go-librespot/output"
1313 downloadpb "github.com/devgianlu/go-librespot/proto/spotify/download"
1414 extmetadatapb "github.com/devgianlu/go-librespot/proto/spotify/extendedmetadata"
15+ audiofilespb "github.com/devgianlu/go-librespot/proto/spotify/extendedmetadata/audiofiles"
1516 metadatapb "github.com/devgianlu/go-librespot/proto/spotify/metadata"
1617 "github.com/devgianlu/go-librespot/spclient"
1718 "github.com/devgianlu/go-librespot/vorbis"
@@ -495,19 +496,18 @@ func (p *Player) NewStream(ctx context.Context, client *http.Client, spotId libr
495496 return nil , librespot .ErrMediaRestricted
496497 }
497498
498- if len (trackMeta .File ) == 0 {
499- for _ , alt := range trackMeta .Alternative {
500- if len (alt .File ) == 0 {
501- continue
502- }
503-
504- trackMeta .File = append (trackMeta .File , alt .File ... )
505- }
499+ var audioFilesResp audiofilespb.AudioFilesExtensionResponse
500+ err = p .sp .ExtendedMetadataSimple (ctx , spotId , extmetadatapb .ExtensionKind_AUDIO_FILES , & audioFilesResp )
501+ if err != nil {
502+ return nil , fmt .Errorf ("failed getting audio files metadata: %w" , err )
503+ }
506504
507- log .Warnf ("original track has no formats, alternatives have a total of %d" , len (trackMeta .File ))
505+ var audioFiles []* metadatapb.AudioFile
506+ for _ , f := range audioFilesResp .Files {
507+ audioFiles = append (audioFiles , f .File )
508508 }
509509
510- file = selectBestMediaFormat (trackMeta . File , bitrate )
510+ file = selectBestMediaFormat (audioFiles , bitrate )
511511 if file == nil {
512512 return nil , librespot .ErrNoSupportedFormats
513513 }
0 commit comments