-
-
Save Ivoah/076d65a87d5424bccbd6 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
# -*- coding: utf-8 -*- | |
from requests import get | |
from bs4 import BeautifulSoup | |
import time | |
import Foundation | |
import objc | |
NSUserNotification = objc.lookUpClass('NSUserNotification') | |
NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter') | |
def notify(title, subtitle, info_text, delay=0, sound=False, userInfo={}): | |
notification = NSUserNotification.alloc().init() | |
notification.setTitle_(title) | |
notification.setSubtitle_(subtitle) | |
notification.setInformativeText_(info_text) | |
notification.setUserInfo_(userInfo) | |
if sound: | |
notification.setSoundName_("NSUserNotificationDefaultSoundName") | |
notification.setDeliveryDate_(Foundation.NSDate.dateWithTimeInterval_sinceDate_(delay, Foundation.NSDate.date())) | |
NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification) | |
oval = 0 | |
while True: | |
val = int(BeautifulSoup(get('https://www.kickstarter.com/projects/214379695/micropython-on-the-esp8266-beautifully-easy-iot').text, 'html.parser').find_all('data')[2]['data-value']) | |
if val != oval: | |
notify('MicroPython donation!', 'Now at: {} pounds'.format(val), 'Somebody donated {} pounds'.format(val - oval), sound = True) | |
oval = val | |
time.sleep(60) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment