Created
February 17, 2016 15:44
-
-
Save Neoklosch/a5da9729283dfc37d0ba to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
import subprocess, time, json | |
import urllib2 | |
def main(): | |
print "Starting notifier..." | |
message = ["notify-send", "Deine Nummer Digga, geh los!"] | |
while True: | |
current_number = your_number() | |
if current_number in (689, 690, 691): | |
subprocess.call(message) | |
else: | |
print current_number | |
time.sleep(2) | |
print "Closing notifier..." | |
def your_number(): | |
api_url = 'http://pa.freitagsrunde.org/api/' | |
content = urllib2.urlopen(api_url).read() | |
json_content = json.loads(content) | |
for item in json_content['entries']: | |
if item['src'] == 23: | |
numbers = item['numbers'] | |
for number in numbers: | |
if number['src'] == "23": | |
current_number = number['num'] | |
return current_number | |
return -1 | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment