本文整理汇总了Python中pushbullet.Pushbullet.push_link方法的典型用法代码示例。如果您正苦于以下问题:Python Pushbullet.push_link方法的具体用法?Python Pushbullet.push_link怎么用?Python Pushbullet.push_link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pushbullet.Pushbullet
的用法示例。
在下文中一共展示了Pushbullet.push_link方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_change
# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_link [as 别名]
def on_change(title, link):
title = HTMLParser().unescape(title)
api_key = read_file('api_key')
if api_key:
pb = Pushbullet(api_key.strip())
pb.push_link(title, link)
else:
print('No api_key file available. Push not sent')
示例2: push_item
# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_link [as 别名]
def push_item(items):
pb = Pushbullet(API_KEY)
for item in items:
if item["price"] == -1:
price_info = "No price: "
else:
price_info = str(item["price"]) + ":- | "
push = pb.push_link(price_info + item["title"], item["url"])
示例3: send_push
# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_link [as 别名]
def send_push(new_bikes, new_finds):
"""
Uses pushbullet to send a notification that new bikes were scraped.
Args:
new_bikes (list): List of new_bikes objects
"""
print "Pushing"
pb = Pushbullet(PUSHBULLET_KEY)
push_sent = False
# Don't do individual pushes if there's a large number of new posts
if len(new_bikes) <= 10:
for bike in new_bikes:
# Only push high priority bikes
if bike['priority'] == bikeutils.Priority.HighPriority:
pb.push_link(bike["title"], bike["url"])
push_sent = True
if not push_sent:
pb.push_link("%d bike(s) added to sheet" % len(new_bikes), SHEET_URL)
# Push any new posts in the ebay finds thread
if new_finds:
pb.push_link("%d new posts in the ebay/craigslist finds thread"
% new_finds,
"https://www.lfgss.com/conversations/127097/newest/")
示例4: action
# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_link [as 别名]
def action(self):
# fill in the shared kvp in your instance
pb_api = Pushbullet(shared.pb_api_key)
notif_dict = self.notif_dict
if notif_dict['type'] == 'note':
note = pb_api.push_note(notif_dict['title'], notif_dict['note'])
elif notif_dict['type'] == 'link':
link = pb_api.push_link(notif_dict['title'], notif_dict['link'])
elif notif_dict['type'] == 'list':
pb_list = pb_api.push_list(notif_dict['title'], notif_dict['list'])
elif notif_dict['type'] == 'address':
address = pb_api.push_address(notif_dict['title'], notif_dict['address'])
示例5: rgc_runner_run
# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_link [as 别名]
def rgc_runner_run(forum_url, search_strings, pb_key):
fr = ForumRunner(url=forum_url)
results = fr.run()
search_results = fr.search(search_strings)
for res in search_results:
if res.is_new:
print "%s (%s) new?%s" % (res.title, res.price, res.is_new)
#if the pushbullet key is set, send a link to pushbullet containing the information and URL that we found
if pb_key:
pb = Pushbullet(pb_key)
found_text = 'RCGBot -- Match Found: %s %s' % (res.title, res.price)
push = pb.push_link(found_text, res.url)
示例6: pushbullet_listening
# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_link [as 别名]
def pushbullet_listening():
week = ['mon','tue','wed','thu','fri','sat','sun']
day_of_week = week[datetime.today().weekday()]
hour_of_day = datetime.now().hour
minute_of_day = datetime.now().minute
title = 'Khaleesi notifications'
now_time = '{hour}:{minute}:00'.format(hour=hour_of_day, minute=minute_of_day)
list_notifications = {
'start_time': {
'text': 'Buen día. Es hora de comenzar a trabajar. No olvides activar tus tareas.',
'filter': {'start_time': now_time},
'type': 'note'
},
'lunch_time': {
'text': 'Hora de comer ! Recuerda pausar tus tareas activas.',
'filter': {'lunch_time': now_time},
'type': 'image'
},
'end_time': {
'text': 'Tu día parece haber terminado. Buen trabajo. Recuerda que a las 6pm todas las tareas activas se pausarán automáticamente.',
'filter': {'end_time': now_time},
'type': 'link',
'url': 'http://khaleesi.unisem.mx/admin/track/tarea/'
}
}
for profile in UserProfile.objects.filter(Q(**{day_of_week: True}) & Q(token__isnull=False)):
try:
pb = Pushbullet(profile.token)
#print profile.user
for notification in list_notifications.keys():
if UserProfile.objects.filter(id=profile.id).filter(Q(**list_notifications[notification]['filter'])).count() > 0:
if list_notifications[notification]['type'] == 'note':
push = pb.push_note(title, list_notifications[notification]['text'])
elif list_notifications[notification]['type'] == 'link':
push = pb.push_link(title, url=list_notifications[notification]['url'], body=list_notifications[notification]['text'])
elif list_notifications[notification]['type'] == 'image':
push = pb.push_file(file_url=get_url_image(), file_name=title, file_type='image/jpeg', body=list_notifications[notification]['text'])
print push
except Exception as e:
#print 'Error: ', e
pass
示例7: price_change
# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_link [as 别名]
def price_change(item, old_price):
print "Price change! " + item["title"] + " Old price: " + old_price + " New price: " + item["price"] + " URL: " + item["url"]
if PB_ACTIVE:
pb = Pushbullet(API_KEY)
pb.push_link("Price changed from " + str(old_price) + ":- to " + str(item["price"]) + ":- | " + item["title"], item["url"])
示例8: Album
# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_link [as 别名]
else:
album_formats = "FLAC, MP3"
# Album Tracks
album_tracks = curr_album.find("span", "circle").text
# Album Size
album_size = curr_album.find("span","col-small text-right").text
# Album Date
album_date = curr_album.find("span","col-medium").text
# Creating the album and adding it to the list
album = Album(artist_name, album_name, album_link, album_year, album_genres, album_formats, album_tracks, album_size, album_date)
albums.append(album)
i += 1
return albums
old_albums = []
new_albums = []
config = configparser.ConfigParser()
config.read('settings.ini')
# Using Pushbullet
pb = Pushbullet(config['settings']['PUSHBULLET_API_KEY'])
while 1:
albums = getAlbums()
if old_albums:
i = 0
while old_albums[0].album_name != albums[i].album_name:
push = pb.push_link(albums[i].artist_name + " - " + albums[i].album_name + " - " + albums[i].album_genres + " (" + albums[i].album_year + ") " + albums[i].album_formats, "http://mp3boo.cc" + albums[i].album_link)
i += 1
old_albums = albums
time.sleep(float(config['settings']['TIMEOUT_DURATION']))
示例9: tmp
# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_link [as 别名]
c_tmp = con_tmp.cursor()
c_tmp.execute("create table tmp (url text, episode text, manga_name text);")
for row in c.execute('select url,name from WatchList;'):
try:
print row
request = urllib2.Request(row[0],None,headers)
response = urllib2.urlopen(request)
page = response.read()
episode = search_episode(page)
for e in episode:
#save to tmp table
c_tmp.execute("insert into tmp values(?,?,?)",(e[0].decode('utf8'),e[1].decode('utf8'), row[1]))
except URLError as e:
print e.reason
#check if pushed
c_tmp.execute("select * from tmp")
while True:
episode_tmp = c_tmp.fetchone()
if episode_tmp != None:
c.execute("select url from Episode where url=? limit 1;",(episode_tmp[0],))
if c.fetchone() == None:
#new episode spotted
full_url = "m.seemh.com"+episode_tmp[0]
if not args.update:
push = pb.push_link("New episode from m.seemh.com!",full_url)
c.execute("insert into episode values (?,?)",(episode_tmp[0],episode_tmp[1]))
else:
break
con.commit()
con.close()
示例10: ServicePushbullet
# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_link [as 别名]
class ServicePushbullet(ServicesMgr):
def __init__(self, token=None, **kwargs):
super(ServicePushbullet, self).__init__(token, **kwargs)
self.AUTH_URL = "https://pushbullet.com/authorize"
self.ACC_TOKEN = "https://pushbullet.com/access_token"
self.REQ_TOKEN = "https://api.pushbullet.com/oauth2/token"
self.consumer_key = settings.TH_PUSHBULLET["client_id"]
self.consumer_secret = settings.TH_PUSHBULLET["client_secret"]
self.scope = "everything"
self.service = "ServicePushbullet"
self.oauth = "oauth2"
if token:
self.token = token
self.pushb = Pushb(token)
def read_data(self, **kwargs):
"""
get the data from the service
as the pushbullet service does not have any date
in its API linked to the note,
add the triggered date to the dict data
thus the service will be triggered when data will be found
:param kwargs: contain keyword args : trigger_id at least
:type kwargs: dict
:rtype: list
"""
trigger_id = kwargs["trigger_id"]
data = list()
cache.set("th_pushbullet_" + str(trigger_id), data)
def save_data(self, trigger_id, **data):
"""
let's save the data
:param trigger_id: trigger ID from which to save data
:param data: the data to check to be used and save
:type trigger_id: int
:type data: dict
:return: the status of the save statement
:rtype: boolean
"""
kwargs = {}
title, content = super(ServicePushbullet, self).save_data(trigger_id, data, **kwargs)
if self.token:
trigger = Pushbullet.objects.get(trigger_id=trigger_id)
if trigger.type == "note":
status = self.pushb.push_note(title=title, body=content)
elif trigger.type == "link":
status = self.pushb.push_link(title=title, body=content, url=data.get("link"))
sentence = str("pushbullet {} created").format(title)
logger.debug(sentence)
else:
# no valid type of pushbullet specified
logger.critical("no valid type of pushbullet specified")
status = False
else:
logger.critical("no token or link provided for " "trigger ID {} ".format(trigger_id))
status = False
return status
示例11: notify
# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_link [as 别名]
def notify(self, title, text, url=None):
pb = Pushbullet(self.pushbullet_apikey)
push = pb.push_link(text, url)
示例12: repr
# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_link [as 别名]
return
elif wanted_pokemon != None and not pokename in wanted_pokemon:
return
elif wanted_pokemon == None and unwanted_pokemon != None and pokename in unwanted_pokemon:
return
# notify
print "[+] Notifier found pokemon:", pokename
#http://maps.google.com/maps/place/<place_lat>,<place_long>/@<map_center_lat>,<map_center_long>,<zoom_level>z
latLon = '{},{}'.format(repr(pokemon["lat"]), repr(pokemon["lng"]))
google_maps_link = 'http://maps.google.com/maps/place/{}/@{},{}z'.format(latLon, latLon, 20)
<<<<<<< HEAD
notification_text = "Pokemon Found " + _str(pokemon["name"]) + "!"
disappear_time = str(datetime.fromtimestamp(pokemon["disappear_time"]).strftime("%I:%M%p").lstrip('0'))+")"
location_text = "Location : " + google_maps_link + ". " + _str(pokemon["name"]) + " Available till " + disappear_time + "."
push = my_channel.push_link( _str(pokemon["name"] + " found, Available until " +disappear_time ) , google_maps_link )
#push = pushbullet_client.push_link(notification_text, google_maps_link, body=location_text)
=======
notification_text = "Pokemon Finder found " + _str(pokemon["name"]) + "!"
disappear_time = str(datetime.fromtimestamp(pokemon["disappear_time"]).strftime("%I:%M%p").lstrip('0'))+")"
location_text = "Locate on Google Maps : " + google_maps_link + ". " + _str(pokemon["name"]) + " will be available until " + disappear_time + "."
push = pushbullet_client.push_link(notification_text, google_maps_link, body=location_text)
push = my_channel.push_link( _str(pokemon["name"] + " found, Available until " +disappear_time ) , google_maps_link )
>>>>>>> origin/master
init()
示例13: check_old
# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_link [as 别名]
def check_old(self):
if self.url in old_posts.read().split(","):
return False
else:
return True
def get_catalog():
articles = []
# Gets the all the articles as a link and puts them in a list
for tbody in catalog.find_all("tbody"):
if tbody.get("class")[0] == "body":
for tr in tbody.find_all("tr"):
# The index thing is for that the url has some uneccesery stuff in it at the end
articles.append("http://www.sweclockers.com%s" % tr.a.get("href")[:len(tr.a.get("href"))-13])
break
else:
quit()
return articles
with open("old_posts.txt", "r+") as old_posts:
# Forever loop that checks the keywords and if true sends a pushbullet
for article_url in get_catalog():
article = sweclockers(article_url)
print(article.url)
if article.check_keyword() and article.check_old():
print("Pushing %s" % article.headline())
push = pb.push_link(article.headline(), article.url)
article.make_old()
示例14: new_deals_alert
# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_link [as 别名]
def new_deals_alert(better_deals):
pb = Pushbullet(settings.PUSHBULLET_API)
for deal in better_deals:
pb.push_link(deal['product-name'] + ' - ' + deal['price'] + ' - ' + deal['retailer'] +
' - ' + deal['title'], deal['link'])
示例15: ServicePushbullet
# 需要导入模块: from pushbullet import Pushbullet [as 别名]
# 或者: from pushbullet.Pushbullet import push_link [as 别名]
class ServicePushbullet(ServicesMgr):
"""
Service Pushbullet
"""
def __init__(self, token=None, **kwargs):
super(ServicePushbullet, self).__init__(token, **kwargs)
self.AUTH_URL = 'https://pushbullet.com/authorize'
self.ACC_TOKEN = 'https://pushbullet.com/access_token'
self.REQ_TOKEN = 'https://api.pushbullet.com/oauth2/token'
self.consumer_key = settings.TH_PUSHBULLET_KEY['client_id']
self.consumer_secret = settings.TH_PUSHBULLET_KEY['client_secret']
self.scope = 'everything'
self.service = 'ServicePushbullet'
self.oauth = 'oauth2'
if token:
self.token = token
self.pushb = Pushb(token)
def read_data(self, **kwargs):
"""
get the data from the service
as the pushbullet service does not have any date
in its API linked to the note,
add the triggered date to the dict data
thus the service will be triggered when data will be found
:param kwargs: contain keyword args : trigger_id at least
:type kwargs: dict
:rtype: list
"""
trigger_id = kwargs.get('trigger_id')
trigger = Pushbullet.objects.get(trigger_id=trigger_id)
date_triggered = kwargs.get('date_triggered')
data = list()
pushes = self.pushb.get_pushes()
for p in pushes:
title = 'From Pushbullet'
created = arrow.get(p.get('created'))
if created > date_triggered and p.get('type') == trigger.type and\
(p.get('sender_email') == p.get('receiver_email') or p.get('sender_email') is None):
title = title + ' Channel' if p.get('channel_iden') and p.get('title') is None else title
# if sender_email and receiver_email are the same ;
# that means that "I" made a note or something
# if sender_email is None, then "an API" does the post
body = p.get('body')
data.append({'title': title, 'content': body})
# digester
self.send_digest_event(trigger_id, title, '')
cache.set('th_pushbullet_' + str(trigger_id), data)
return data
def save_data(self, trigger_id, **data):
"""
let's save the data
:param trigger_id: trigger ID from which to save data
:param data: the data to check to be used and save
:type trigger_id: int
:type data: dict
:return: the status of the save statement
:rtype: boolean
"""
title, content = super(ServicePushbullet, self).save_data(trigger_id, **data)
if self.token:
trigger = Pushbullet.objects.get(trigger_id=trigger_id)
if trigger.type == 'note':
status = self.pushb.push_note(title=title, body=content)
elif trigger.type == 'link':
status = self.pushb.push_link(title=title, body=content, url=data.get('link'))
sentence = str('pushbullet {} created').format(title)
logger.debug(sentence)
else:
# no valid type of pushbullet specified
msg = "no valid type of pushbullet specified"
logger.critical(msg)
update_result(trigger_id, msg=msg, status=False)
status = False
else:
msg = "no token or link provided for trigger ID {} ".format(trigger_id)
logger.critical(msg)
update_result(trigger_id, msg=msg, status=False)
status = False
return status