/** * Gets song matches by querying the Grooveshark API for matches. * * @param search The phrase that is being searched for. Typically contains * the song, artist, and/or album. * * @return An array containing all of the song objects that matched the search * phrase. */ function getGroovesharkResults($search) { $songs = findSongs($search); foreach ($songs as $song) { if (!songIsInDb($song->id)) { if (!albumIsInDb($song->albumId)) { if (!artistIsInDb($song->artistId)) { addArtist($song->artistId, $song->artist); } $location = $song->arturl; addAlbum($song->albumId, $song->album, $song->artistId, $location, $song->arturl); } addSong($song->id, $song->title, $song->albumId, $song->track, $song->popularity, $song->duration); } } return $songs; }
$confirmAddSong = 1; } } } } if ($confirmAddSong > 0) { confirmAddSong($confirmAddSong); } if ($noMatches) { addSong($file, $xml, $backupXML); } } elseif (isset($_GET['artist']) && isset($_GET['album']) && isset($_GET['song']) && isset($_GET['confirm'])) { $file = 'info.xml'; $xml = @simplexml_load_file($file); $backupXML = @simplexml_load_file($file); if (!$xml) { $xml = new SimpleXMLElement('<songs/>'); $backupXML = new SimpleXMLElement('<songs/>'); } addSong($file, $xml, $backupXML); } else { ?> <title>Error</title> <h1>Redirecting to /show/. If you are not redirected please click <a href="show">here</a></h1> <script> (function() {location.replace('show')})(); </script> <?php }