plietar / librespot

Open Source Spotify client library
MIT License
1.14k stars 185 forks source link

a track cannot be played with librespot (but with offical app) #173

Closed balbuze closed 7 years ago

balbuze commented 7 years ago

a track can be played on my smartphone or computer with offical app but if sent to librespot it can't. the message is

Apr 15 17:16:03 volumio-hifiberry volumio[2892]: INFO:librespot::session: Connecting to AP "lon3-accesspoint-a6.ap.spotify.com:4070"
Apr 15 17:16:04 volumio-hifiberry volumio[2892]: INFO:librespot::session: Authenticated as "xxxxxx" !
Apr 15 17:16:04 volumio-hifiberry volumio[2892]: INFO:librespot::audio_backend::alsa: Using alsa sink
Apr 15 17:16:06 volumio-hifiberry volumio[2892]: INFO:librespot::player: Loading track "Dylan"
Apr 15 17:16:07 volumio-hifiberry volumio[2892]: INFO:librespot::player: Track "Dylan" loaded
Apr 15 17:16:26 volumio-hifiberry volumio[2892]: INFO:librespot::player: Loading track "Qui de nous deux"
Apr 15 17:16:26 volumio-hifiberry volumio[2892]: WARN:librespot::player: Track "Qui de nous deux" is not available

the track is spotify:track:0PZiPbrDCdORrSW6IIICRG

plietar commented 7 years ago

According to the metadata for that track, it is restricted in the following countries : BQ, CN, CU, CW, IR, KP, SX, SY, with no alternative track available. It is odd you are able to load the track in official apps if your account is of one of those countries.

You can add the following after line 209 of session.rs to check the country code for your account.

println!("Country: {:?}", country);

(Btw I've edited your message to quote the log with ```, please do so in the future it makes it a lot easier to read)

seanrand commented 7 years ago

I've just run into this with the new Gorillaz album. Plays fine on Spotify Android/Linux, but the tracks that weren't released as singles fail to play on librespot HEAD with "not available". Librespot's country code is DE (which is correct).

Edit: Log output with a println!("{:?}", track) strewn in:

INFO:librespot::player: Loading track "Carnival (feat. Anthony Hamilton)"
Track {
    id: SpotifyId(u128 { high: 13613275396732833587, low: 11745946959238700783 }),
    name: "Carnival (feat. Anthony Hamilton)",
    album: SpotifyId(u128 { high: 1890433301851688242, low: 9818994387987334294 }),
    artists: [SpotifyId(u128 { high: 8499679525537402513, low: 12369894434121956278 }),
              SpotifyId(u128 { high: 6246551273308307512, low: 9583232305209340264 })],
    files: {
        OGG_VORBIS_320: FileId("d398a783eb80e0e69c7ce71a2e01599e67983d95"),
        OGG_VORBIS_160: FileId("2e87baeab76884e3016d4bff17c8748e285a2be8"),
        OGG_VORBIS_96: FileId("efd708389324c1476ef967db44c071e0699ebfcf"),
        AAC_320: FileId("2bb870ec3667a9e0e9b7f4638b199056c07d0633"),
        AAC_160: FileId("80a61afa69ee15b56b094ed378cf3e617edc4a59"),
        MP3_160_ENC: FileId("7249060aff32c52055b342f6d9904c7d7656b606"),
        OTHER2: FileId("aad2a02c9b49cd17fb7386624820813b1bb9f734")
    },
    alternatives: [],
    available: false
}
WARN:librespot::player: Track "Carnival (feat. Anthony Hamilton)" is not available
plietar commented 7 years ago

Thanks @seanrand, I can reproduce this with the Gorillaz album. Looking into it

thegass commented 7 years ago

track is playing fine for me (INFO:librespot::session: Country: "AT")

INFO:librespot::player: Loading track "Carnival (feat. Anthony Hamilton)"
Track { id: SpotifyId(u128 { high: 13613275396732833587, low: 11745946959238700783 }), name: "Carnival (feat. Anthony Hamilton)", album: SpotifyId(u128 { high: 1890433301851688242, low: 9818994387987334294 }), artists: [SpotifyId(u128 { high: 8499679525537402513, low: 12369894434121956278 }), SpotifyId(u128 { high: 6246551273308307512, low: 9583232305209340264 })], files: {OGG_VORBIS_320: FileId("d398a783eb80e0e69c7ce71a2e01599e67983d95"), OGG_VORBIS_160: FileId("2e87baeab76884e3016d4bff17c8748e285a2be8"), OGG_VORBIS_96: FileId("efd708389324c1476ef967db44c071e0699ebfcf"), AAC_320: FileId("2bb870ec3667a9e0e9b7f4638b199056c07d0633"), AAC_160: FileId("80a61afa69ee15b56b094ed378cf3e617edc4a59"), MP3_160_ENC: FileId("7249060aff32c52055b342f6d9904c7d7656b606"), OTHER2: FileId("aad2a02c9b49cd17fb7386624820813b1bb9f734")}, alternatives: [], available: true, track: 13, disc: 1 }
INFO:librespot::player: Track "Carnival (feat. Anthony Hamilton)" loaded
jsopenrb commented 7 years ago

I had a similar issue when playing an album on its release date - some tracks failed to play. After a couple of days it was fine though. Maybe it's some kind of a caching issue from Spotify side, not librespot?

jsopenrb commented 7 years ago

Ok, this is a bug in librespot. parse_restrictions function goes over all restrictions and check them one by one. But, for example, there are tracks which have two allowed fields and no forbidden ones. This kind of track cannot be played because only one allowed field matches the given country.

I suppose parse_restrictions should concatenate all allowed and forbidden fields, and only then do a check if track is available for the given country.