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