function request($song, $artist)
{
    $request = findSong($song, $artist);
    //check our database first
    if (!isset($request)) {
        $request = echoNest($song, $artist);
        //song must not be in our database, so we check echonest
    }
    if (!isset($request)) {
        $request = spotify($song, $artist);
        //then spotify
    }
    if (!isset($request)) {
        return null;
        //then fail
    }
    return $request;
}
示例#2
0
 if (count($result) > 0) {
     $featuredSongArr = $result[0]->featured_song;
     $featuredSong = "";
     if (count($featuredSongArr) > 0) {
         $featuredSong = $featuredSongArr[0];
     }
     $themeSong = "";
     if (strlen($featuredSong) > 0) {
         $themeThong = $featuredSong;
         $themeSong = str_replace("'", "", $themeThong);
         $spotifyURL = 'https://api.spotify.com/v1/search?q=' . urlencode($movies . ' ' . $themeSong) . '&type=track';
         $items = spotify($spotifyURL);
         //var_dump($items);
         if (empty($items)) {
             $spotifyURL = 'https://api.spotify.com/v1/search?q=' . urlencode($themeSong) . '&type=track';
             $items = spotify($spotifyURL);
         }
         $previewURL = $items[0]->preview_url;
     }
     echo $movies . "<br />";
     echo $votes . "<br />";
     echo $imdbID . "<br />";
     echo $year . "<br />";
     echo $rating . "<br />";
     //        echo $poster . "<br />";
     //        echo $rgb . "<br />";
     //        echo $themeSong . "<br />";
     //        echo $genre . "<br />";
     //        echo $plot . "<br />";
     //        echo $previewURL . "<br />";
     //        echo $actors . "<br />";