Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!python3
- import httplib2
- import bs4
- import os
- import sys
- URL = 'https://kvhcasting.com/' # hendry's site
- TITLE = 'WOT' # title for notifications
- def notify(preset, text):
- """notification function for visual feedback
- i made this for awesomewm under gnu/linux
- replace with call to your OS' notificatoon lib"""
- os.system('''echo 'local naughty = require("naughty"); naughty.notify({preset=naughty.config.presets.'''\
- + preset +\
- ''', title="'''\
- + TITLE +\
- '''", text="'''\
- + text +\
- '''"})'| awesome-client''')
- ### this is where the magic begins, DO NOT change this
- h = httplib2.Http('.cache')
- res, content = h.request(URL, 'GET')
- content_parsed = bs4.BeautifulSoup(content, features="html.parser")
- cards = content_parsed.findAll(attrs={'data-ux': 'ContentCard'})
- the_card = None
- for i in cards:
- if i.findChild(text='THE WHEEL OF TIME'):
- the_card = i
- break
- if not the_card: # no WoT card
- notify('info', 'card not found')
- sys.exit(1)
- link = the_card.findChild(name='a')
- if link:
- notify('critical', f'Casting is open: {link["href"]}') # submission mail address
- card_cont = the_card.findChild(attrs={'data-ux': 'ContentCard'}).findChild(name='p')
- if card_cont != 'UPDATES COMING SOON':
- notify('critical', f'update:\n{card_cont}') # updates?
Advertisement
Add Comment
Please, Sign In to add comment