Browse Source

testing to print multifeeder posts

master
televex 3 years ago
parent
commit
6e3f0e75ad
  1. 1
      .gitignore
  2. 17
      print/start.py

1
.gitignore

@ -3,3 +3,4 @@ venv*
*__pycache__*
*.pyc
print/printed.json
screen/tools/ascii-art-but-with-unicode/asciiWriter/__pycache__/*

17
print/start.py

@ -37,10 +37,14 @@ scheduler.start()
def update_db(item):
items = json.loads(open(db).read())
if not item in items['printed']:
new_item = True
with open(db, 'w') as out:
items['printed'].append(item)
out.write(json.dumps(items, indent=4))
out.close()
else:
new_item = False
return new_item
def html2plain(html):
plain = re.sub('<[^<]+?>', '', text)
@ -48,8 +52,6 @@ def html2plain(html):
@scheduler.task('interval', id='check', minutes=10)
def check():
print('Checking the Multifeeder!')
url = 'https://multi.vvvvvvaria.org/API/latest/10'
response = urllib.request.urlopen(url).read()
feed = json.loads(response)
@ -66,7 +68,13 @@ def check():
'date' : post_date,
'printed' : plaintext
}
update_db(item)
new_item = update_db(item)
if new_item == True:
# print RSS post
buffer.text(plaintext)
buffer.cut()
lp._raw(buffer.output)
@APP.route('/print/', methods=['GET', 'POST'])
def print():
@ -83,7 +91,6 @@ def print():
date = datetime.now()
date_str = date.strftime('%Y-%m-%d_%H-%M-%S')
item = {
'source' : 'TeleVex',
'date' : date_str,
@ -95,9 +102,7 @@ def print():
@APP.route('/printed/', methods=['GET', 'POST'])
def printed():
items = json.loads(open(db).read())
return flask.render_template('printed.html', items=items)
if __name__ == '__main__':

Loading…
Cancel
Save