Set default title with timestamp if no title is provided by the Instapaper API
This commit is contained in:
parent
c55deab6cb
commit
611e5f2160
1 changed files with 2 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
import requests
|
||||
import time
|
||||
|
||||
from platypush.plugins import action
|
||||
from platypush.plugins.http.request import Plugin
|
||||
|
@ -60,7 +61,7 @@ class HttpWebpagePlugin(Plugin):
|
|||
if not response or not response.ok:
|
||||
raise RuntimeError("Unable to parse content for {}: {}".format(url, response.reason))
|
||||
|
||||
title = response.json()['title']
|
||||
title = response.json().get('title', 'No_title_{}'.format(int(time.time())))
|
||||
content = '<body style="{body_style}"><h1>{title}</h1>{content}</body>'.\
|
||||
format(title=title, content=response.json()['content'],
|
||||
body_style='font-size: 22px; font-family: Tahoma, Geneva, sans-serif')
|
||||
|
|
Loading…
Reference in a new issue