Import disqus posts without Email Fix #477

It looks like disqus has stoped to add a Email
into there exports. So this sets the email just
to ''. This can be changed to a default email
if that is prefered.

Signed-off-by: fliiiix <de-ch@hotmail.de>
This commit is contained in:
fliiiix 2018-12-15 20:01:42 +01:00
parent 40d011e6bb
commit 1f4ced626c

View File

@ -102,12 +102,13 @@ class Disqus(object):
res = defaultdict(list)
for post in tree.findall(Disqus.ns + 'post'):
email = post.find('{0}author/{0}email'.format(Disqus.ns))
item = {
'dsq:id': post.attrib.get(Disqus.internals + 'id'),
'text': post.find(Disqus.ns + 'message').text,
'author': post.find('{0}author/{0}name'.format(Disqus.ns)).text,
'email': post.find('{0}author/{0}email'.format(Disqus.ns)).text,
'email': email.text if email else '',
'created': mktime(strptime(
post.find(Disqus.ns + 'createdAt').text, '%Y-%m-%dT%H:%M:%SZ')),
'remote_addr': anonymize(post.find(Disqus.ns + 'ipAddress').text),
@ -150,10 +151,11 @@ class Disqus(object):
if post.attrib.get(Disqus.internals + "id") not in orphans:
continue
email = post.find("{0}author/{0}email".format(Disqus.ns))
print(" * {0} by {1} <{2}>".format(
post.attrib.get(Disqus.internals + "id"),
post.find("{0}author/{0}name".format(Disqus.ns)).text,
post.find("{0}author/{0}email".format(Disqus.ns)).text))
email.text if email else ""))
print(textwrap.fill(post.find(Disqus.ns + "message").text,
initial_indent=" ", subsequent_indent=" "))
print("")