spotify / web-api

This issue tracker is no longer used. Join us in the Spotify for Developers forum for support with the Spotify Web API ➡️ https://community.spotify.com/t5/Spotify-for-Developers/bd-p/Spotify_Developer
982 stars 79 forks source link

recommendations function of web-api seems to ignore "track attributes" #335

Closed ToniKos closed 8 years ago

ToniKos commented 8 years ago

Hello guys!

I’m using the recommendations-function of the web-api in a little project for my thesis and have now encountered the problem, that the “Tuneable Track attributes” of the recommendations-function like “target_popularity”, “target_energy” and even the general request parameter “market” seems to have no influence on the recommendation results. Every time I make a call with or without this values, I always get the same result list (100 items) in different order but with identical content. https://developer.spotify.com/web-api/get-recommendations/

I am using the jwilsson/spotify-web-api-php code as base project to communicate with the web-api https://github.com/jwilsson/spotify-web-api-php

and have already successfully created an spotify account and web-project with the client-id and client-secret. https://developer.spotify.com/web-api/tutorial/

The call for the authorisation-token (OAuth Token?) seems to work as well and the values are also all passed properly to the api-interface, as I already get results from the call.

But only manipulating the values “seed_genres” and “seed_tracks” have an effect on the results. Manipulating the other values always leads to the same result list if I use the maximum allowed amount of recommended tracks (100 items).

For example, the following three calls are giving the same result list in different order, but if you sort them (artist name -> song name) they are 100% identically.

Does someone have the same issue or any idea, what the reason could be, that the other values are totally ignored by my api-calls?

Many thanks and best regards Toni

Code Calls:

require_once('Session.php');
require_once('Request.php');
require_once('SpotifyWebAPI.php');

$accessToken = 'access_token';

$clientID = 'e63***9b';
$clientSecret = '531***cee';
$redirectURI = "";
$refreshToken = '';

$api = new SpotifyWebAPIClass();

$session = new Session($clientID, $clientSecret, $redirectURI);

$scopes = array(
    'playlist-read-private',
    'user-library-read',
    'user-read-private',
    'playlist-read-collaborative',
    'user-follow-read',
    'user-top-read'
);

$session->requestCredentialsToken($scopes);
$accessToken = $session->getAccessToken();

$api->setAccessToken($accessToken);

echo "--- 1st Call: without target_energy | with US market ---";

$options = array(
    'target_popularity' => 25,
    'market' => array('US'),
    'seed_genres' => array('rock'),
    'limit' => 100
);

$response = $api->getRecommendations($options);

echo "Artist;Song<br />\n";
foreach ($response->tracks as $value) {
    echo $value->artists[0]->name.";".$value->name."<br />\n";
}

echo "--- 2st Call: with low target_energy = 0 | with DE market ---";

$options_low = array(
    'target_popularity' => 25,
    'market' => array('DE'),
    'seed_genres' => array('rock'),
    'limit' => 100,
    'target_energy' => 0
);

$response = $api->getRecommendations($options_low);

echo "Artist;Song<br />\n";
foreach ($response->tracks as $value) {
    echo $value->artists[0]->name.";".$value->name."<br />\n";
}

echo "--- 3rd Call: with high target_energy = 1.0 | with EN market ---";

$options_high = array(
    'target_popularity' => 25,
    'market' => array('EN'),
    'seed_genres' => array('rock'),
    'limit' => 100,
    'target_energy' => 1.0
);

$response = $api->getRecommendations($options_high);

echo "Artist;Song<br />\n";
foreach ($response->tracks as $value) {
    echo $value->artists[0]->name.";".$value->name."<br />\n";
}

Result:

Method: [POST] Url: [https://accounts.spotify.com/api/token] Parameters: ["grant_type=client_credentials&scope=playlist-read-private+user-library-read+user-read-private+playlist-read-collaborative+user-follow-read+user-top-read"] Headers: [{"Authorization":"Basic ZTY***WU="}]

--- 1st Call: without target_energy | with US market ---

Method: [GET] Url: [https://api.spotify.com/v1/recommendations] Parameters: ["target_popularity=25&market%5B0%5D=US&seed_genres=rock&limit=100"] Headers: [{"Authorization":"Bearer BQC***WRhg"}]

Artist;Song Five Finger Death Punch;Wrong Side Of Heaven Keane;Somewhere Only We Know The Offspring;You're Gonna Go Far, Kid Enter Shikari;The Last Garrison Kasabian;eez-eh Weezer;Back To The Shack Death From Above 1979;Trainwreck 1979 TV On The Radio;Happy Idiot Arctic Monkeys;R U Mine? Slipknot;Killpop The Verve;Bitter Sweet Symphony Blur;Song 2 blink-182;I Miss You alt-J;Every Other Freckle Survivor;Eye of the Tiger Joy Division;Love Will Tear Us Apart - 2011 Total Version Fall Out Boy;Centuries Imagine Dragons;Warriors R.E.M.;Losing My Religion Radiohead;Creep Queen;Don't Stop Me Now Slipknot;The Devil In I Kings of Leon;Sex on Fire Jack White;Would You Fight For My Love? alt-J;Left Hand Free Bon Jovi;It's My Life Jamie T;Zombie Pixies;Where Is My Mind? No Doubt;Don't Speak Cobra Starship;Never Been In Love (feat. Icona Pop) American Authors;Believer Linkin Park;In The End Guns N' Roses;November Rain Seether;Words As Weapons Interpol;All The Rage Back Home Lenny Kravitz;The Chamber Slipknot;The Negative One Linkin Park;Until It's Gone Jack White;Lazaretto Red Hot Chili Peppers;Dani California Bon Jovi;Livin' On A Prayer The Black Keys;Gotta Get Away Guns N' Roses;Welcome To The Jungle WALK THE MOON;Shut Up and Dance Green Day;Wake Me Up When September Ends Scorpions;Wind Of Change Arctic Monkeys;Do I Wanna Know? Imagine Dragons;Radioactive Guns N' Roses;Sweet Child O' Mine Sheppard;Geronimo Red Hot Chili Peppers;Californication Queens of the Stone Age;No One Knows Hoobastank;The Reason Gorillaz;Clint Eastwood The Black Keys;Fever 3 Doors Down;Here Without You Two Door Cinema Club;What You Know American Authors;Best Day Of My Life Arctic Monkeys;Snap Out Of It Europe;The Final Countdown The Killers;Somebody Told Me Paramore;Ain't It Fun System of a Down;Chop Suey! Nirvana;Come As You Are Audioslave;Like a Stone Evanescence;Bring Me To Life Journey;Don't Stop Believin' Paramore;Still Into You Edward Sharpe & The Magnetic Zeros;Home 3 Doors Down;Kryptonite Fall Out Boy;My Songs Know What You Did In The Dark (Light Em Up) alt-J;Breezeblocks Franz Ferdinand;Take Me Out blink-182;All The Small Things The Strokes;Reptilia Aerosmith;I Don't Want to Miss a Thing Modest Mouse;Float On Imagine Dragons;Demons Queen;Bohemian Rhapsody Band of Horses;The Funeral The Black Keys;Lonely Boy Avenged Sevenfold;Hail to the King MGMT;Electric Feel Nirvana;Smells Like Teen Spirit Foo Fighters;The Pretender Boston;More Than a Feeling Green Day;21 Guns Kings of Leon;Use Somebody My Chemical Romance;Welcome to the Black Parade MGMT;Kids Foo Fighters;Everlong The Killers;Mr. Brightside Rage Against The Machine;Killing In The Name - Remastered The Goo Goo Dolls;Iris Green Day;Basket Case Metallica;Nothing Else Matters Linkin Park;Numb Red Hot Chili Peppers;Under The Bridge Foster The People;Pumped Up Kicks Metallica;Enter Sandman

--- 2st Call: with low target_energy = 0 | with DE market ---

Method: [GET] Url: [https://api.spotify.com/v1/recommendations] Parameters: ["target_popularity=25&market%5B0%5D=DE&seed_genres=rock&limit=100&target_energy=0"] Headers: [{"Authorization":"Bearer BQC***WRhg"}]

Artist;Song Radiohead;Creep Keane;Somewhere Only We Know Pixies;Where Is My Mind? Survivor;Eye of the Tiger Jack White;Would You Fight For My Love? Weezer;Back To The Shack Red Hot Chili Peppers;Under The Bridge Metallica;Nothing Else Matters Scorpions;Wind Of Change Queen;Bohemian Rhapsody Blur;Song 2 Arctic Monkeys;Do I Wanna Know? blink-182;I Miss You alt-J;Every Other Freckle Queens of the Stone Age;No One Knows No Doubt;Don't Speak Queen;Don't Stop Me Now Arctic Monkeys;R U Mine? Enter Shikari;The Last Garrison Guns N' Roses;November Rain The Offspring;You're Gonna Go Far, Kid 3 Doors Down;Here Without You Kasabian;eez-eh Five Finger Death Punch;Wrong Side Of Heaven Audioslave;Like a Stone Imagine Dragons;Warriors Fall Out Boy;Centuries Hoobastank;The Reason R.E.M.;Losing My Religion Edward Sharpe & The Magnetic Zeros;Home The Verve;Bitter Sweet Symphony Arctic Monkeys;Snap Out Of It Slipknot;Killpop Death From Above 1979;Trainwreck 1979 The Black Keys;Fever TV On The Radio;Happy Idiot Gorillaz;Clint Eastwood alt-J;Breezeblocks Joy Division;Love Will Tear Us Apart - 2011 Total Version The Strokes;Reptilia Aerosmith;I Don't Want to Miss a Thing Kings of Leon;Sex on Fire Franz Ferdinand;Take Me Out alt-J;Left Hand Free Green Day;Wake Me Up When September Ends Red Hot Chili Peppers;Californication Jack White;Lazaretto Sheppard;Geronimo The Black Keys;Gotta Get Away Slipknot;The Devil In I Jamie T;Zombie Boston;More Than a Feeling Bon Jovi;It's My Life Seether;Words As Weapons Linkin Park;In The End Two Door Cinema Club;What You Know Cobra Starship;Never Been In Love (feat. Icona Pop) Imagine Dragons;Demons Kings of Leon;Use Somebody Journey;Don't Stop Believin' Linkin Park;Until It's Gone Interpol;All The Rage Back Home Bon Jovi;Livin' On A Prayer Green Day;21 Guns WALK THE MOON;Shut Up and Dance American Authors;Believer Red Hot Chili Peppers;Dani California Lenny Kravitz;The Chamber Band of Horses;The Funeral Imagine Dragons;Radioactive Foster The People;Pumped Up Kicks Nirvana;Come As You Are Europe;The Final Countdown Slipknot;The Negative One Guns N' Roses;Sweet Child O' Mine MGMT;Electric Feel The Goo Goo Dolls;Iris Rage Against The Machine;Killing In The Name - Remastered 3 Doors Down;Kryptonite American Authors;Best Day Of My Life Guns N' Roses;Welcome To The Jungle Paramore;Ain't It Fun The Black Keys;Lonely Boy Modest Mouse;Float On Metallica;Enter Sandman blink-182;All The Small Things Avenged Sevenfold;Hail to the King Foo Fighters;Everlong Paramore;Still Into You Linkin Park;Numb System of a Down;Chop Suey! Fall Out Boy;My Songs Know What You Did In The Dark (Light Em Up) Nirvana;Smells Like Teen Spirit Evanescence;Bring Me To Life The Killers;Somebody Told Me My Chemical Romance;Welcome to the Black Parade MGMT;Kids Foo Fighters;The Pretender Green Day;Basket Case The Killers;Mr. Brightside

--- 3rd Call: with high target_energy = 1.0 | with EN market ---

Method: [GET] Url: [https://api.spotify.com/v1/recommendations] Parameters: ["target_popularity=25&market%5B0%5D=EN&seed_genres=rock&limit=100&target_energy=1"] Headers: [{"Authorization":"Bearer BQC***WRhg"}]

Artist;Song Five Finger Death Punch;Wrong Side Of Heaven TV On The Radio;Happy Idiot Death From Above 1979;Trainwreck 1979 Kasabian;eez-eh Slipknot;Killpop The Offspring;You're Gonna Go Far, Kid The Verve;Bitter Sweet Symphony Enter Shikari;The Last Garrison Joy Division;Love Will Tear Us Apart - 2011 Total Version American Authors;Believer Slipknot;The Devil In I Bon Jovi;It's My Life Kings of Leon;Sex on Fire Cobra Starship;Never Been In Love (feat. Icona Pop) Guns N' Roses;Welcome To The Jungle Jamie T;Zombie Slipknot;The Negative One Fall Out Boy;Centuries R.E.M.;Losing My Religion alt-J;Left Hand Free Imagine Dragons;Warriors Seether;Words As Weapons Arctic Monkeys;R U Mine? blink-182;I Miss You Lenny Kravitz;The Chamber Linkin Park;In The End Interpol;All The Rage Back Home Guns N' Roses;Sweet Child O' Mine Weezer;Back To The Shack Red Hot Chili Peppers;Dani California Bon Jovi;Livin' On A Prayer Linkin Park;Until It's Gone The Killers;Somebody Told Me WALK THE MOON;Shut Up and Dance Queen;Don't Stop Me Now Blur;Song 2 Imagine Dragons;Radioactive Jack White;Lazaretto alt-J;Every Other Freckle The Black Keys;Gotta Get Away Keane;Somewhere Only We Know System of a Down;Chop Suey! Evanescence;Bring Me To Life Green Day;Wake Me Up When September Ends Paramore;Still Into You Foo Fighters;The Pretender Fall Out Boy;My Songs Know What You Did In The Dark (Light Em Up) American Authors;Best Day Of My Life No Doubt;Don't Speak MGMT;Kids Paramore;Ain't It Fun The Killers;Mr. Brightside Green Day;Basket Case blink-182;All The Small Things Modest Mouse;Float On Avenged Sevenfold;Hail to the King Nirvana;Smells Like Teen Spirit My Chemical Romance;Welcome to the Black Parade Europe;The Final Countdown Survivor;Eye of the Tiger 3 Doors Down;Kryptonite Sheppard;Geronimo Foo Fighters;Everlong The Black Keys;Lonely Boy Red Hot Chili Peppers;Californication Guns N' Roses;November Rain Two Door Cinema Club;What You Know Nirvana;Come As You Are Rage Against The Machine;Killing In The Name - Remastered Linkin Park;Numb Jack White;Would You Fight For My Love? MGMT;Electric Feel Metallica;Enter Sandman Journey;Don't Stop Believin' Band of Horses;The Funeral Gorillaz;Clint Eastwood The Goo Goo Dolls;Iris The Black Keys;Fever Imagine Dragons;Demons Green Day;21 Guns Hoobastank;The Reason Queens of the Stone Age;No One Knows Kings of Leon;Use Somebody Radiohead;Creep Franz Ferdinand;Take Me Out Arctic Monkeys;Snap Out Of It The Strokes;Reptilia alt-J;Breezeblocks Aerosmith;I Don't Want to Miss a Thing Scorpions;Wind Of Change Foster The People;Pumped Up Kicks Arctic Monkeys;Do I Wanna Know? Boston;More Than a Feeling Pixies;Where Is My Mind? Edward Sharpe & The Magnetic Zeros;Home 3 Doors Down;Here Without You Queen;Bohemian Rhapsody Audioslave;Like a Stone Metallica;Nothing Else Matters Red Hot Chili Peppers;Under The Bridge

hughrawlinson commented 8 years ago

Thanks for the report @ToniKos! I'll pass this on to the relevant team.

joegester commented 8 years ago

Hi Toni,

I think this is mostly functioning as expected. The target_* parameters will never exclude content. They instead put the items with the scores closest to your target scores nearer to the front of the list. So for the rock genre seed, which is a pool of only 100 items, the expected result is to have exactly the same set of results in a different order. If you add some more seeds to increase the pool of tracks you're drawing from, not all tracks will fit in the result set and you'll see a different set of stuff at the top of the list.

If you want to use attributes to actually exclude content, use the min* and max* parameters. Based on a quick test in the developer console, these seem to be working correctly.

Similarly, the market parameter seems OK too. See the track relinking guide for why you may find all the tracks are available even after you specify a market.

I think you have uncovered two smaller bugs here though.

The "seeds" object in the response should describe the total size of the available pool, the number of tracks after filtering out min* and max* parameters and the number of those tracks available in the selected market. It seems that the initial pool size being returned is the same as the size of the pool after filtering. I'll fix this so that you can see the total tracks in the pool, the number excluded by filters and the number by market availability.

If you look in the developer console though, you can see the pool sizes change when you apply a min* or max* parameter or a market parameter.

Additionally, you're using country code EN but the ISO standard code is GB. We should be giving a 400 error to let you know that instead of silently dropping it. I'll make sure that happens as well.

Sorry for the long response. Thanks so much for your feedback. I'll leave this issue open while we make those two fixes.

ToniKos commented 8 years ago

Hi Joegester,

thank you for your detail response. I'll try out to use the parameters like you described the next days and am happy if I really could help uncovering the two smaller bugs, even if not intentional ^^'

Many thanks and best regards Toni