From 611e5f2160938284d798d998c3cefb3ccc10c3c6 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 13 Apr 2019 08:03:42 +0000 Subject: [PATCH] Set default title with timestamp if no title is provided by the Instapaper API --- platypush/plugins/http/webpage.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platypush/plugins/http/webpage.py b/platypush/plugins/http/webpage.py index 52ef278ca..cfa6dc8cc 100644 --- a/platypush/plugins/http/webpage.py +++ b/platypush/plugins/http/webpage.py @@ -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 = '

{title}

{content}'.\ format(title=title, content=response.json()['content'], body_style='font-size: 22px; font-family: Tahoma, Geneva, sans-serif')