mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-11-18 08:37:25 +01:00
RSS: Use HTTP(S) proxy. Closes GH-1234.
This commit is contained in:
parent
fa755c3a9c
commit
3776404628
@ -52,6 +52,11 @@ import supybot.callbacks as callbacks
|
|||||||
from supybot.i18n import PluginInternationalization, internationalizeDocstring
|
from supybot.i18n import PluginInternationalization, internationalizeDocstring
|
||||||
_ = PluginInternationalization('RSS')
|
_ = PluginInternationalization('RSS')
|
||||||
|
|
||||||
|
if minisix.PY2:
|
||||||
|
from urllib2 import ProxyHandler
|
||||||
|
else:
|
||||||
|
from urllib.request import ProxyHandler
|
||||||
|
|
||||||
def get_feedName(irc, msg, args, state):
|
def get_feedName(irc, msg, args, state):
|
||||||
if ircutils.isChannel(args[0]):
|
if ircutils.isChannel(args[0]):
|
||||||
state.errorInvalid('feed name', args[0], 'must not be channel names.')
|
state.errorInvalid('feed name', args[0], 'must not be channel names.')
|
||||||
@ -289,9 +294,15 @@ class RSS(callbacks.Plugin):
|
|||||||
# Feed fetching
|
# Feed fetching
|
||||||
|
|
||||||
def update_feed(self, feed):
|
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:
|
with feed.lock:
|
||||||
d = feedparser.parse(feed.url, etag=feed.etag,
|
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 'status' not in d or d.status != 304: # Not modified
|
||||||
if 'etag' in d:
|
if 'etag' in d:
|
||||||
feed.etag = d.etag
|
feed.etag = d.etag
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user