jwilsson / spotify-web-api-php

A PHP wrapper for Spotify's Web API.
MIT License
862 stars 156 forks source link

Question about Country Code and Episode Search #218

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hi Jonathan,

I notice that when I run a search for an episode, that records are returned where the language of that record is de for example.

This is my sample code:

// @@@@@@@@@@@@@@@ CALL THE API @@@@@@@@@@@@@@@

$options = ['return_assoc' => true];
$api = new SpotifyWebAPI\SpotifyWebAPI($options);   
$api->setAccessToken($accessToken);

// @@@@@@@@@@@@@@@ search @@@@@@@@@@@@@@@

try {
    $search_options = ['offset' => 0,'limit' => $limit,'market' => 'from_token', 'include_external' => 'audio'];
    $search = $api->search("saturday live","episode",$search_options);
} catch (SpotifyWebAPI\SpotifyWebAPIException $e) {
    header('Location:index.php');
    exit;
}

I have reviewed the Spotify Docs which says:

market

An ISO 3166-1 alpha-2 country code or the string from_token.

If a country code is specified, only content that is playable in that market is returned.

Note:

- Playlist results are not affected by the market parameter.
- If market is set to from_token, and a valid access token is specified in the request header, only content playable in the country associated with the user account, is returned.
- Users can view the country that is associated with their account in the account settings. A user must grant access to the user-read-private scope prior to when the access token is issued.

My country is set to GB, so I have tested having search options as:

$search_options = ['offset' => 0,'limit' => $limit,'market' => 'from_token', 'include_external' => 'audio'];

And also:

$search_options = ['offset' => 0,'limit' => $limit,'market' => 'GB', 'include_external' => 'audio'];

However, when e.g. searching for saturday live the top results are episodes with language values of de

e.g. first result has audio_preview_url of https://p.scdn.co/mp3-preview/fe5cf4286b8e67065b41546424c6dcb463cf0c09 and description of "Wir sind zurück! Und besprechen die dinge die uns wirklich am herzen liegen wie zu Beispiel reich sein und Dampfduschen!", and language of "de".

The Docs says Playlist results are not affected by the market parameter. but doesn't mention episodes not being affected by the market parameter.

Do you think this an issue with this library, or the wider API?

Thanks

Jim

jwilsson commented 3 years ago

Hi Jim! I don't think the market parameter will actually control the language of the results returned (I'm in Sweden and I'm getting a mix of English and German results too) but only limit the results to items actually playable in that country.

What we'd really want is a locale parameter like the featured playlists endpoint. I'd post a suggestion for it on their developer forum and hope they implement something like it.

Cheers, Jonathan

ghost commented 3 years ago

As ever, thank you Jonathan, you are a big help.

Jim