-
-
Save breyten/487b06a2fd2b54530555 to your computer and use it in GitHub Desktop.
Get songs from Radiobox2 and add links to Spoptify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Radioboxify</title> | |
</head> | |
<body> | |
<h1>Radioboxify</h2> | |
<form> | |
<input type="text" name="q" value="<?php echo $_GET['q']; ?>" /> | |
<input type="submit" value="Verstuur" /> | |
</form> | |
<?php | |
if (trim($_GET['q']) != '') { | |
$q = $_GET['q']; | |
$results = json_decode(file_get_contents("http://radiobox2.omroep.nl/song/search.json?q=title~'%$q%'")); | |
} else { | |
$results = new stdClass(); | |
$results->results = array(); | |
} | |
//print_r($results); | |
foreach($results->results as $result) { | |
$artist = $result->songversion[0]->presentable_name; | |
$title = $result->songversion[0]->title; | |
$spotify_query = urlencode("$artist $title"); | |
$spotify_info = json_decode(file_get_contents("http://ws.spotify.com/search/1/track.json?q=$spotify_query")); | |
print "<div class=\"result\">"; | |
print "<h3>$artist - $title</h3>"; | |
print $result->songversion[0]->description; | |
if ($spotify_info->info->num_results > 0) { | |
print "<ul>"; | |
foreach ($spotify_info->tracks as $track) { | |
$track_info = split(':', $track->href); | |
//print_r($track_info); | |
$track_id = $track_info[2];; | |
$play_url = "https://play.spotify.com/track/$track_id"; | |
print "<li><a href=\"$play_url\">Speel dit nummer op spotify</a></li>"; | |
} | |
print "</ul>"; | |
} | |
print "</div>"; | |
//print_r($spotify_info); | |
} | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment