aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Harrison <me@jasonharrison.us>2017-02-20 20:01:58 -0500
committerJason Harrison <me@jasonharrison.us>2017-02-20 20:01:58 -0500
commit73010502b7d32d564833d3b3cf8bb4c282ddc20d (patch)
tree840d0420e634eee01c244070934539cb745e74b6
parent18b74197e8cf7b9c6ba9791a155234e87bfbc190 (diff)
downloadguppy-73010502b7d32d564833d3b3cf8bb4c282ddc20d.tar.gz
guppy-73010502b7d32d564833d3b3cf8bb4c282ddc20d.tar.bz2
Decode webpage content to UTF-8, do not announce if a title was not found
-rw-r--r--plugins/urltitle.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/plugins/urltitle.py b/plugins/urltitle.py
index e0cb08f..8d5e407 100644
--- a/plugins/urltitle.py
+++ b/plugins/urltitle.py
@@ -52,7 +52,9 @@ class Urltitle(object):
r=requests.get(url, allow_redirects=True)
except requests.exceptions.ConnectionError:
return None
- title=title_regex.search(r.content).group(1)
+ title=title_regex.search(r.content.decode('utf-8')).group(1)
+ if not title:
+ return None
#title = fromstring(r.content).findtext('.//title')
if len(title) > 75:
title = title[:75] + "..."
@@ -81,7 +83,7 @@ class Urltitle(object):
if title is not None:
self.server.doMessage(channel, title)
# Clean up the timestamps stored
- for url in self.ts.items(): # loop over an independent copy of the container
+ for url, dt in self.ts.items(): # loop over an independent copy of the container
timeThen = self.ts[url]
timeNow = datetime.datetime.now()
timeDiff = timeNow - timeThen

Return to:

Send suggestions and report system problems to the System administrator.