RSS: Use HTTP(S) proxy. Closes GH-1234.

This commit is contained in:
Valentin Lorentz 2016-08-16 10:56:29 +02:00
parent fa755c3a9c
commit 3776404628

View File

@ -52,6 +52,11 @@ import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('RSS')
if minisix.PY2:
from urllib2 import ProxyHandler
else:
from urllib.request import ProxyHandler
def get_feedName(irc, msg, args, state):
if ircutils.isChannel(args[0]):
state.errorInvalid('feed name', args[0], 'must not be channel names.')
@ -289,9 +294,15 @@ class RSS(callbacks.Plugin):
# Feed fetching
def update_feed(self, feed):
handlers = []
if utils.web.proxy():
handlers.append(ProxyHandler(
{'http': utils.force(utils.web.proxy())}))
handlers.append(ProxyHandler(
{'https': utils.force(utils.web.proxy())}))
with feed.lock:
d = feedparser.parse(feed.url, etag=feed.etag,
modified=feed.modified)
modified=feed.modified, handlers=handlers)
if 'status' not in d or d.status != 304: # Not modified
if 'etag' in d:
feed.etag = d.etag