class PushbulletNotificationservice(NotificationService):

    @staticmethod
    def get_service_name():
        return 'Pushbullet'

    def __init__(self, api_key, device_identifier):
        super().__init__(device_identifier)
        self._api_key = api_key
        self._notification_service = Pushbullet(self._api_key)
        self._device = self.get_device()

    def get_device(self):
        all_possible_devices = self._notification_service.devices
        for device in all_possible_devices:
            if device.nickname == self.device_identifier:
                logging.info('Found Pushbullet device: "%s"', device.nickname)
                return device
        logging.error('Did not found Pushbullet device! '
                      'These are all possible devices: "%s" '
                      'This is the device name specified in config: "%s"',
                      all_possible_devices,
                      self.device_identifier)
        return None

    def send_test_notification(self):
        self._notification_service.push_note('Test', 'Test', device=self._device)

    def send_notification(self, title, message):
        self._notification_service.push_note(title, message, device=self._device)
Beispiel #2
0
def setup_pushbullet(pb_api_key, debug):
  if debug:
    print('> DEBUG MODE: setup_pushbullet: acquired device api!')
    return 'TEST_DEVICE_ID'
  else:
    pb = Pushbullet(api_key=pb_api_key)
    device_iden = pb.list_devices()['devices'][0]['iden']
    return device_iden
 def __init__(self, api_key, device_identifier):
     super().__init__(device_identifier)
     self._api_key = api_key
     self._notification_service = Pushbullet(self._api_key)
     self._device = self.get_device()
from pushbullet.pushbullet import Pushbullet
#import wolframalpha
import json
import tungsten

pb = Pushbullet(api_key="PUSHBULLET_API_KEY")

wolf_api = "WOLFRAMALPHA_API_KEY"
#client = wolframalpha.Client(wolf_api)
client = tungsten.Tungsten(wolf_api)
pushes = pb.get_pushes()

f = open("sent.json")
sent = json.loads(f.read())
f.close()

for push in pushes:
    if 'body' in push.keys() and push['body'].startswith(
            'Hey Jarvis') and push['iden'] not in sent:
        try:
            sent.append(push['iden'])
            res = client.query(push['body'][11:])
            if res.success:
                print "Success"
                print[pod.format['plaintext'][0] for pod in res.pods]
                results = [
                    pod.format['plaintext'][0] for pod in res.pods
                    if type(pod.format['plaintext'][0]) is not None
                ]
                if len(results) != 0:
                    pb.push_note(title=push['body'][11:],
import requests
from BeautifulSoup import BeautifulSoup
from pushbullet.pushbullet import Pushbullet
import json

pb = Pushbullet(api_key="API KEY HERE")
device_iden = pb.list_devices()['devices'][0]['iden']

# Read list of shows interested in.
f = open("shows.txt")
shows = f.read().split("\n")
shows.pop()
print shows
f.close()

# Get HTML of kat.cr and extract all anchor tags
r=requests.get("https://kat.cr",verify=False)
soup = BeautifulSoup(r.text)
links = soup.findAll("a")
text_list = []
# Get text of all anchor tags
for i in links: 
  text_list.append(i.text)
  pass
# From layout of kat.cr, the list of tv shows lie between these two strings
# Horrible hack
text_list = text_list[text_list.index("TV Shows Torrents"):text_list.index("Music Torrents")]


# Fetch the list of shows that match with yours
match = [ text for text in text_list for show in shows if show in text]