Handle escaping escape characters

This commit is contained in:
Hans5958 2022-04-08 07:28:20 +07:00
parent 1da79b806b
commit cd87520c87

View file

@ -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)