diff --git a/tools/redditcrawl.py b/tools/redditcrawl.py index 70069391..b6c6d3cd 100755 --- a/tools/redditcrawl.py +++ b/tools/redditcrawl.py @@ -69,8 +69,10 @@ text = submission.selftext rawtext = text - text = text.replace("\\", "") text = re.compile(r".*(\{.+\}).*", re.DOTALL).search(text).group(1) + # Test if it needs to escape the escape character. Usually happens on fancy mode. + try: json.loads(text) + except json.JSONDecodeError: text = re.sub(r"\\(.)", r"\1", text) submission_json = json.loads(text)