mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-05-03 08:51:16 -05:00
SpiffyTitles: better error handling
This commit is contained in:
parent
e086f78679
commit
8fb4618d79
@ -228,7 +228,12 @@ class SpiffyTitles(callbacks.Plugin):
|
|||||||
(html, is_redirect) = self.get_source_by_url(url, channel)
|
(html, is_redirect) = self.get_source_by_url(url, channel)
|
||||||
if html:
|
if html:
|
||||||
title = self.get_title_from_html(html)
|
title = self.get_title_from_html(html)
|
||||||
if title:
|
if not title:
|
||||||
|
log.error(
|
||||||
|
"SpiffyTitles: Unable to parse title from html response for %s"
|
||||||
|
% (url)
|
||||||
|
)
|
||||||
|
title = self.registryValue("badLinkText", channel=channel)
|
||||||
title_template = default_template.render(
|
title_template = default_template.render(
|
||||||
title=title, redirect=is_redirect
|
title=title, redirect=is_redirect
|
||||||
)
|
)
|
||||||
@ -392,7 +397,10 @@ class SpiffyTitles(callbacks.Plugin):
|
|||||||
title = None
|
title = None
|
||||||
soup = BeautifulSoup(html)
|
soup = BeautifulSoup(html)
|
||||||
if soup:
|
if soup:
|
||||||
|
try:
|
||||||
title = soup.title.string.strip()
|
title = soup.title.string.strip()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
if title:
|
if title:
|
||||||
return title
|
return title
|
||||||
else:
|
else:
|
||||||
@ -468,7 +476,7 @@ class SpiffyTitles(callbacks.Plugin):
|
|||||||
log.error(
|
log.error(
|
||||||
"SpiffyTitles HTTP response code %s" % (request.status_code,)
|
"SpiffyTitles HTTP response code %s" % (request.status_code,)
|
||||||
)
|
)
|
||||||
text = self.registryValue("badLinkText")
|
text = self.registryValue("badLinkText", channel=channel)
|
||||||
text = (
|
text = (
|
||||||
"<html><head><title>{0}</title>"
|
"<html><head><title>{0}</title>"
|
||||||
"</head><body></body></html>".format(text)
|
"</head><body></body></html>".format(text)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user