Commit cbabd9d6 by murtaugh

unescape HTML escapes in Site web (feed) URLs

parent 38611517
Showing with 11 additions and 3 deletions
......@@ -10,6 +10,8 @@ from mwclient import Site
from time import mktime
from mediawikiutils import ensure_unique_wiki_pagename, upload_file_to_wiki
import json
from html import unescape as html_unescape
"""
_ __ _ ___ _____
......@@ -254,7 +256,13 @@ class SiteWeb (object):
where="feed_url<>''",
order_by="pagename")
# print (json.dumps(result, indent=2))
return [cls(wiki=wiki, pagename=r['title']['pagename'], site_url=r['title']['site_url'], feed_url=r['title']['feed_url'], last_updated=cls.parse_dt(r['title']['last_updated'])) for r in result['cargoquery']]
# html_unescape is here cause URLs with & seem to get escaped!
return [cls(
wiki=wiki,
pagename=r['title']['pagename'],
site_url=html_unescape(r['title']['site_url']),
feed_url=html_unescape(r['title']['feed_url']),
last_updated=cls.parse_dt(r['title']['last_updated'])) for r in result['cargoquery']]
def __init__ (self, wiki, pagename, site_url=None, feed_url=None, last_updated=None):
self.wiki = wiki
......@@ -280,8 +288,8 @@ class SiteWeb (object):
result = result['cargoquery']
if len(result) > 0:
result = result[0]['title']
self.site_url = result['Site url']
self.feed_url = result['Feed url']
self.site_url = html_unescape(result['Site url'])
self.feed_url = html_unescape(result['Feed url'])
if result['Last updated']:
self.last_updated = self.parse_dt(result['Last updated'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment