aboutsummaryrefslogtreecommitdiff
path: root/modules/rss.py
diff options
context:
space:
mode:
authorGravatar jesopo2020-04-09 18:26:54 +0100
committerGravatar jesopo2020-04-09 18:26:54 +0100
commit74146f20bd42e4baea2da8733c91697c02e5fdc2 (patch)
treef7b67c96aefd52a427435b973310858aad21c805 /modules/rss.py
parentexperimental support for rss bindhost (diff)
signature
fix rss bindhost implementation
Diffstat (limited to 'modules/rss.py')
-rw-r--r--modules/rss.py28
1 files changed, 18 insertions, 10 deletions
diff --git a/modules/rss.py b/modules/rss.py
index f597e3dc..9ba23db4 100644
--- a/modules/rss.py
+++ b/modules/rss.py
@@ -54,28 +54,36 @@ class Module(ModuleManager.BaseModule):
if server and channel_name in server.channels:
channel = server.channels.get(channel_name)
for url in urls:
- if not url in hooks:
- hooks[url] = []
- hooks[url].append((server, channel))
+ bindhost = channel.get_setting("rss-bindhost",
+ server.get_setting("rss-bindhost", None))
+
+ 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:
return
requests = []
- for url, (server, channel) in hooks.items():
- bindhost = channel.get_setting("rss-bindhost",
- server.get_setting("rss-bindhost", None))
- requests.append(utils.http.Request(url, id=url, bindhost=bindhost))
+ for url, bindhost in hooks.keys():
+ requests.append(utils.http.Request(url, id=f"{url} {bindhost}",
+ bindhost=bindhost))
pages = utils.http.request_many(requests)
- for url, channels in hooks.items():
- if not url in pages:
+ for (url, bindhost), channels in hooks.items():
+ key = f"{url} {bindhost}"
+ if not key in pages:
# async url get failed
continue
try:
- data = pages[url].decode()
+ data = pages[key].decode()
except Exception as e:
self.log.error("Failed to decode rss URL %s", [url],
exc_info=True)