Skip to content

Instantly share code, notes, and snippets.

@pierrebeaucamp
Last active December 14, 2015 22:27

Revisions

  1. pierrebeaucamp revised this gist Dec 14, 2015. 1 changed file with 22 additions and 0 deletions.
    22 changes: 22 additions & 0 deletions soundcloud-alarm.py
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,25 @@
    # The MIT License (MIT)
    #
    # Copyright (c) 2015 Pierre Beaucamp <[email protected]>
    #
    # Permission is hereby granted, free of charge, to any person obtaining a copy
    # of this software and associated documentation files (the "Software"), to deal
    # in the Software without restriction, including without limitation the rights
    # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    # copies of the Software, and to permit persons to whom the Software is
    # furnished to do so, subject to the following conditions:
    #
    # The above copyright notice and this permission notice shall be included in all
    # copies or substantial portions of the Software.
    #
    # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    # SOFTWARE.

    import os
    import requests
    import time
  2. pierrebeaucamp revised this gist Feb 22, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions soundcloud-alarm.py
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    import os
    import requests
    import time
    from random import choice, randint
    import random

    if __name__ == "__main__":
    # Let's track the time
    @@ -25,12 +25,12 @@

    def playSoundcloud():
    # Gets the JSON from Soundcloud
    url = 'https://api.soundcloud.com/users/' + choice(users) + '/favorites.json?client_id=f8dc78d527a14157cce82626661b9607'
    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[randint(0, len(j))]['stream_url'] + '?client_id=f8dc78d527a14157cce82626661b9607 -O - | mplayer -cache 8192 -')
    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()
  3. pierrebeaucamp revised this gist Feb 6, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion soundcloud-alarm.py
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@
    # Let's track the time
    start_time = time.time()

    # Turns on the Receiver (ooh, he likes it)
    # 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")
  4. pierrebeaucamp revised this gist Feb 6, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion soundcloud-alarm.py
    Original file line number Diff line number Diff line change
    @@ -30,7 +30,7 @@ def playSoundcloud():
    j = r.json()

    # Plays a Sound
    os.system('wget ' + j[randint(0, len(j))]['stream_url'] + '?client_id=f8dc78d527a14157cce82626661b9607' + ' -O - | mplayer -cache 8192 -')
    os.system('wget ' + j[randint(0, len(j))]['stream_url'] + '?client_id=f8dc78d527a14157cce82626661b9607 -O - | mplayer -cache 8192 -')

    while ((time.time() - start_time) < 1800):
    playSoundcloud()
  5. pierrebeaucamp revised this gist Feb 6, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion soundcloud-alarm.py
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@
    for i in range(200):
    os.system("printf '%s\r\b' VD | nc 10.0.0.2 8102")

    # Turns is on a nice Volume to wake up
    # 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")

  6. pierrebeaucamp created this gist Feb 6, 2014.
    36 changes: 36 additions & 0 deletions soundcloud-alarm.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    import os
    import requests
    import time
    from random import choice, randint

    if __name__ == "__main__":
    # Let's track the time
    start_time = time.time()

    # Turns on the Receiver (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 is 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/' + choice(users) + '/favorites.json?client_id=f8dc78d527a14157cce82626661b9607'
    r = requests.get(url)
    j = r.json()

    # Plays a Sound
    os.system('wget ' + j[randint(0, len(j))]['stream_url'] + '?client_id=f8dc78d527a14157cce82626661b9607' + ' -O - | mplayer -cache 8192 -')

    while ((time.time() - start_time) < 1800):
    playSoundcloud()