fix rss bindhost implementation

This commit is contained in:
jesopo 2020-04-09 18:26:54 +01:00
parent b19e956f68
commit 74146f20bd

View file

@ -54,28 +54,36 @@ class Module(ModuleManager.BaseModule):
if server and channel_name in server.channels: if server and channel_name in server.channels:
channel = server.channels.get(channel_name) channel = server.channels.get(channel_name)
for url in urls: for url in urls:
if not url in hooks: bindhost = channel.get_setting("rss-bindhost",
hooks[url] = [] server.get_setting("rss-bindhost", None))
hooks[url].append((server, channel))
if url.startswith("www."):
url = url.replace("www.", "", 1)
key = (url, bindhost)
if not key in hooks:
hooks[key] = []
hooks[key].append((server, channel))
if not hooks: if not hooks:
return return
requests = [] requests = []
for url, (server, channel) in hooks.items(): for url, bindhost in hooks.keys():
bindhost = channel.get_setting("rss-bindhost", requests.append(utils.http.Request(url, id=f"{url} {bindhost}",
server.get_setting("rss-bindhost", None)) bindhost=bindhost))
requests.append(utils.http.Request(url, id=url, bindhost=bindhost))
pages = utils.http.request_many(requests) pages = utils.http.request_many(requests)
for url, channels in hooks.items(): for (url, bindhost), channels in hooks.items():
if not url in pages: key = f"{url} {bindhost}"
if not key in pages:
# async url get failed # async url get failed
continue continue
try: try:
data = pages[url].decode() data = pages[key].decode()
except Exception as e: except Exception as e:
self.log.error("Failed to decode rss URL %s", [url], self.log.error("Failed to decode rss URL %s", [url],
exc_info=True) exc_info=True)