mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-04-29 06:51:12 -05:00
fix loop iteration
This commit is contained in:
parent
b4f1c0accf
commit
ab874f32d9
@ -411,7 +411,12 @@ class SpiffyTitles(callbacks.Plugin):
|
|||||||
if soup:
|
if soup:
|
||||||
try:
|
try:
|
||||||
title = soup.title.string.strip()
|
title = soup.title.string.strip()
|
||||||
except:
|
except AttributeError as err:
|
||||||
|
# handle this further down the pipeline
|
||||||
|
pass
|
||||||
|
except Exception as err:
|
||||||
|
# TODO: even better error handling
|
||||||
|
log.debug(err)
|
||||||
title = self.registryValue("badLinkText", channel=channel)
|
title = self.registryValue("badLinkText", channel=channel)
|
||||||
return title
|
return title
|
||||||
|
|
||||||
@ -422,7 +427,6 @@ class SpiffyTitles(callbacks.Plugin):
|
|||||||
max_retries = self.registryValue("maxRetries")
|
max_retries = self.registryValue("maxRetries")
|
||||||
size = conf.supybot.protocols.http.peekSize()
|
size = conf.supybot.protocols.http.peekSize()
|
||||||
generic_error = self.registryValue("badLinkText", channel=channel)
|
generic_error = self.registryValue("badLinkText", channel=channel)
|
||||||
response_size = 0
|
|
||||||
if retries >= max_retries:
|
if retries >= max_retries:
|
||||||
log.debug("SpiffyTitles: hit maximum retries for %s" % url)
|
log.debug("SpiffyTitles: hit maximum retries for %s" % url)
|
||||||
return (None, False)
|
return (None, False)
|
||||||
@ -439,8 +443,10 @@ class SpiffyTitles(callbacks.Plugin):
|
|||||||
stream=True,
|
stream=True,
|
||||||
proxies=self.proxies,
|
proxies=self.proxies,
|
||||||
) as request:
|
) as request:
|
||||||
|
response_size = 0
|
||||||
for chunk in request.iter_content(chunk_size=1024):
|
for chunk in request.iter_content(chunk_size=1024):
|
||||||
if response_size > size:
|
if response_size > size:
|
||||||
|
print("too big bailing")
|
||||||
request.close()
|
request.close()
|
||||||
return (generic_error, False)
|
return (generic_error, False)
|
||||||
if 'content-length' in request.headers:
|
if 'content-length' in request.headers:
|
||||||
@ -494,7 +500,9 @@ class SpiffyTitles(callbacks.Plugin):
|
|||||||
if chunk:
|
if chunk:
|
||||||
title = self.get_title_from_html(chunk, channel)
|
title = self.get_title_from_html(chunk, channel)
|
||||||
if not title:
|
if not title:
|
||||||
|
response_size += len(chunk)
|
||||||
continue
|
continue
|
||||||
|
else:
|
||||||
return (title, is_redirect)
|
return (title, is_redirect)
|
||||||
else:
|
else:
|
||||||
log.debug("SpiffyTitles: empty content from %s" % (url))
|
log.debug("SpiffyTitles: empty content from %s" % (url))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user