Skip to content

Instantly share code, notes, and snippets.

@sumpygump
Created January 2, 2015 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sumpygump/8b1bc45bdf3bf1740e84 to your computer and use it in GitHub Desktop.
Save sumpygump/8b1bc45bdf3bf1740e84 to your computer and use it in GitHub Desktop.
Method Radio Terminal Status
#!/usr/bin/env php
<?php
/**
* Method Radio Terminal status
*
* This will show the currently playing song and a brief song history from the
* terminal
*
* Save this file in your path as 'method'
*
* Suggested usage:
* watch -n 60 method
*/
$infoUrl = 'http://groove.methodradio.com/api/stream/info';
$rawJson = file_get_contents($infoUrl);
$playInfo = json_decode($rawJson);
print("Method Radio\n");
print("------------\n");
printf("Now Playing: %s\n", $playInfo->title);
printf("Listeners: %s\n", $playInfo->listeners);
print "\nHistory:\n";
foreach ($playInfo->songHistory as $song) {
printf("%s %s\n", date('Y-m-d H:i:s', $song->time), $song->title);
}
exit(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment