From 1f4ced626ce69414cde73b9dd7ae04c357ab9381 Mon Sep 17 00:00:00 2001 From: fliiiix Date: Sat, 15 Dec 2018 20:01:42 +0100 Subject: [PATCH 1/2] 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 --- isso/migrate.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/isso/migrate.py b/isso/migrate.py index c32a63c..a1603f1 100644 --- a/isso/migrate.py +++ b/isso/migrate.py @@ -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("") From a3ac7b9081a38aa71851f4d4a6ad2066bacde2e5 Mon Sep 17 00:00:00 2001 From: fliiiix Date: Sat, 15 Dec 2018 20:06:16 +0100 Subject: [PATCH 2/2] Use default IP if none is found Fix #477 This is related to the email one. Disqus doesn't export ip for posts. If none is present '0.0.0.0' is used. --- isso/migrate.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/isso/migrate.py b/isso/migrate.py index a1603f1..201dba5 100644 --- a/isso/migrate.py +++ b/isso/migrate.py @@ -103,6 +103,7 @@ class Disqus(object): for post in tree.findall(Disqus.ns + 'post'): email = post.find('{0}author/{0}email'.format(Disqus.ns)) + ip = post.find(Disqus.ns + 'ipAddress') item = { 'dsq:id': post.attrib.get(Disqus.internals + 'id'), @@ -111,7 +112,7 @@ class Disqus(object): '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), + 'remote_addr': anonymize(ip.text if ip else '0.0.0.0'), 'mode': 1 if post.find(Disqus.ns + "isDeleted").text == "false" else 4 }