OCRrainwaveNP.php
· 1.1 KiB · PHP
Raw
<?php
# Because sometimes it's easier to load up a web browser.
# http://blha303.com.au/util/ocr.rainwave.cc.php
$pagecontent = file_get_contents("http://ocr.rainwave.cc/");
preg_match_all("/PRELOADED_APIKEY = '(.*?)'/", $pagecontent, $matches);
$url = "http://ocr.rainwave.cc/sync/2/init";
$data = array('refresh' => 'full',
'user_id' => '1',
'key' => $matches[1][0],
'in_order' => 'true');
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
$result = json_decode(file_get_contents($url, false, $context), true);
$songinfo = $result[3]["sched_current"]["song_data"][0];
$artists = array();
foreach($songinfo["artists"] as $item) {
$artists[] = $item["artist_name"];
}
print sprintf("%s - %s (from %s) %s",
implode(", ", $artists),
$songinfo["song_title"],
$songinfo["album_name"],
$songinfo["song_url"]);
| 1 | <?php |
| 2 | # Because sometimes it's easier to load up a web browser. |
| 3 | # http://blha303.com.au/util/ocr.rainwave.cc.php |
| 4 | |
| 5 | $pagecontent = file_get_contents("http://ocr.rainwave.cc/"); |
| 6 | preg_match_all("/PRELOADED_APIKEY = '(.*?)'/", $pagecontent, $matches); |
| 7 | $url = "http://ocr.rainwave.cc/sync/2/init"; |
| 8 | $data = array('refresh' => 'full', |
| 9 | 'user_id' => '1', |
| 10 | 'key' => $matches[1][0], |
| 11 | 'in_order' => 'true'); |
| 12 | |
| 13 | $options = array( |
| 14 | 'http' => array( |
| 15 | 'header' => "Content-type: application/x-www-form-urlencoded\r\n", |
| 16 | 'method' => 'POST', |
| 17 | 'content' => http_build_query($data), |
| 18 | ), |
| 19 | ); |
| 20 | |
| 21 | $context = stream_context_create($options); |
| 22 | $result = json_decode(file_get_contents($url, false, $context), true); |
| 23 | $songinfo = $result[3]["sched_current"]["song_data"][0]; |
| 24 | $artists = array(); |
| 25 | foreach($songinfo["artists"] as $item) { |
| 26 | $artists[] = $item["artist_name"]; |
| 27 | } |
| 28 | print sprintf("%s - %s (from %s) %s", |
| 29 | implode(", ", $artists), |
| 30 | $songinfo["song_title"], |
| 31 | $songinfo["album_name"], |
| 32 | $songinfo["song_url"]); |
| 33 |
OCRrainwaveNP.py
· 871 B · Python
Raw
from urllib2 import urlopen
from urllib import urlencode
from json import loads
def main():
data = loads(urlopen("http://ocr.rainwave.cc/sync/2/init",
data=urlencode({'refresh': 'full',
'user_id': '1',
'key': 'd472aaf56b',
'in_order': 'true'}
)).read())
songinfo = data[3]["sched_current"]["song_data"][0]
artists = []
for i in songinfo["artists"]:
artists.append(i["artist_name"])
print "%s by %s (from %s) %s" % (songinfo["song_title"],
", ".join(artists),
songinfo["album_name"],
songinfo["song_url"])
if __name__ == "__main__":
main()
| 1 | from urllib2 import urlopen |
| 2 | from urllib import urlencode |
| 3 | from json import loads |
| 4 | |
| 5 | |
| 6 | def main(): |
| 7 | data = loads(urlopen("http://ocr.rainwave.cc/sync/2/init", |
| 8 | data=urlencode({'refresh': 'full', |
| 9 | 'user_id': '1', |
| 10 | 'key': 'd472aaf56b', |
| 11 | 'in_order': 'true'} |
| 12 | )).read()) |
| 13 | songinfo = data[3]["sched_current"]["song_data"][0] |
| 14 | artists = [] |
| 15 | for i in songinfo["artists"]: |
| 16 | artists.append(i["artist_name"]) |
| 17 | print "%s by %s (from %s) %s" % (songinfo["song_title"], |
| 18 | ", ".join(artists), |
| 19 | songinfo["album_name"], |
| 20 | songinfo["song_url"]) |
| 21 | |
| 22 | |
| 23 | if __name__ == "__main__": |
| 24 | main() |
| 25 |