honor titles too

This commit is contained in:
Kenneth Reitz
2013-09-26 21:05:51 -04:00
parent 981ea28ce1
commit e2b2bd35e3
+8 -3
View File
@@ -15,14 +15,19 @@ def readability(url):
params = {'url': url, 'token': token}
r = requests.get(READABILITY_URL, params=params)
return r.json()['content']
return r.json()['content'], r.json()['title']
def convert(html, title=None):
if title:
title = '# {}'.format(title)
html = '\n\n'.join([title, html])
def convert(html):
return html2text(html)
def meh(url):
try:
return convert(readability(url))
content, title = readability(url)
return convert(content, title=title)
except KeyError:
return None