Last active
December 14, 2015 22:27
-
-
Save pierrebeaucamp/8839152 to your computer and use it in GitHub Desktop.
Soundcloud Alarm
This file contains hidden or 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
import os | |
import requests | |
import time | |
import random | |
if __name__ == "__main__": | |
# Let's track the time | |
start_time = time.time() | |
# Turns the Receiver on (ooh, he likes it) | |
os.system("printf '%s\r\n' PO | nc 10.0.0.2 8102") | |
time.sleep(2) | |
os.system("printf '%s\r\n' 06FN | nc 10.0.0.2 8102") | |
# Nulls the Volume | |
for i in range(200): | |
os.system("printf '%s\r\b' VD | nc 10.0.0.2 8102") | |
# Turns it on a nice Volume to wake up | |
for i in range(50): | |
os.system("printf '%s\r\b' VU | nc 10.0.0.2 8102") | |
# Whos favorites are we listening to? | |
users = ['5727592', '8058060'] | |
def playSoundcloud(): | |
# Gets the JSON from Soundcloud | |
url = 'https://api.soundcloud.com/users/' + random.Random(time.time()).choice(users) + '/favorites.json?client_id=f8dc78d527a14157cce82626661b9607' | |
r = requests.get(url) | |
j = r.json() | |
# Plays a Sound | |
os.system('wget ' + j[random.Random(time.time()).randint(0, len(j))]['stream_url'] + '?client_id=f8dc78d527a14157cce82626661b9607 -O - | mplayer -cache 8192 -') | |
while ((time.time() - start_time) < 1800): | |
playSoundcloud() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment