<commit_before><?php

class SpotifyController extends BaseController {

    protected $client_id;
    protected $client_secret;
    protected $callback_url;

    public function __construct()
    {
        $this->client_id = Config::get('services.spotify.client_id');
        $this->client_secret = Config::get('services.spotify.client_secret');
        $this->callback_url = config::get('services.spotify.callback_url');
    }

    public function getSearch()
    {
        $search = Input::get('search', 'lifestyle');
        $client = new GuzzleHttp\Client();
        $response = $client->get('https://api.spotify.com/v1/search?q='.$search.'&type=track');
        return $response->getBody();
    }

    public function getTrack()
    {
        $songID = Input::get('songID');
        $client = new GuzzleHttp\Client();
        $response = $client->get('https://api.spotify.com/v1/tracks/'.$songID);

        $trackData = \GuzzleHttp\json_decode($response->getBody());

        $song = [
            'trackName' => $trackData->name,
            'artistName' => $trackData->artists[0]->name,
            'albumArt' => $trackData->album->images[0]->url
        ];

        dd($song);<commit_msg>Song don't play because they aren't available in the US market.  Altering the search to only pull back items that are available in the US.  An alternative might be to alter the UI to visually show that a song is not available.<commit_after><?php

class SpotifyController extends BaseController {

    protected $client_id;
    protected $client_secret;
    protected $callback_url;

    public function __construct()
    {
        $this->client_id = Config::get('services.spotify.client_id');
        $this->client_secret = Config::get('services.spotify.client_secret');
        $this->callback_url = config::get('services.spotify.callback_url');
    }

    public function getSearch()
    {
        $search = Input::get('search', 'lifestyle');
        $client = new GuzzleHttp\Client();
        $response = $client->get('https://api.spotify.com/v1/search?q='.$search.'&type=track&market=US');
        return $response->getBody();
    }

    public function getTrack()
    {
        $songID = Input::get('songID');
        $client = new GuzzleHttp\Client();
        $response = $client->get('https://api.spotify.com/v1/tracks/'.$songID);

        $trackData = \GuzzleHttp\json_decode($response->getBody());

        $song = [
            'trackName' => $trackData->name,
            'artistName' => $trackData->artists[0]->name,
            'albumArt' => $trackData->album->images[0]->url
        ];

        dd($song);
{'fraction_non_alphanumeric': 0.1564053537284895, 'fraction_numerical': 0.0030592734225621415, 'mean_word_length': 2.887072808320951, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '931914', 'n_tokens_mistral': 800, 'n_tokens_neox': 762, 'n_words': 146}