mirror of
https://github.com/placeAtlas/atlas.git
synced 2024-06-26 15:18:37 +02:00
Take only the first object, remove escapes, add more info on errors
This commit is contained in:
parent
713ebec844
commit
1da79b806b
|
@ -1,11 +1,11 @@
|
||||||
|
|
||||||
from array import array
|
|
||||||
import praw
|
import praw
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
import re
|
|
||||||
import os
|
import os
|
||||||
from formatter import format_all
|
from formatter import format_all
|
||||||
|
import traceback
|
||||||
|
import re
|
||||||
|
|
||||||
outfile = open('temp_atlas.json', 'w', encoding='utf-8')
|
outfile = open('temp_atlas.json', 'w', encoding='utf-8')
|
||||||
failfile = open('manual_atlas.json', 'w', encoding='utf-8')
|
failfile = open('manual_atlas.json', 'w', encoding='utf-8')
|
||||||
|
@ -67,6 +67,11 @@
|
||||||
try:
|
try:
|
||||||
|
|
||||||
text = submission.selftext
|
text = submission.selftext
|
||||||
|
rawtext = text
|
||||||
|
|
||||||
|
text = text.replace("\\", "")
|
||||||
|
text = re.compile(r".*(\{.+\}).*", re.DOTALL).search(text).group(1)
|
||||||
|
|
||||||
submission_json = json.loads(text)
|
submission_json = json.loads(text)
|
||||||
|
|
||||||
if submission_json:
|
if submission_json:
|
||||||
|
@ -88,10 +93,15 @@
|
||||||
successcount += 1
|
successcount += 1
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
failfile.write(text+"\n\n" + "="*40 + "\n\n")
|
failfile.write(
|
||||||
|
"\n\n" + "="*40 + "\n\n" +
|
||||||
|
submission.id + "\n\n" +
|
||||||
|
traceback.format_exc() + "\n\n" +
|
||||||
|
rawtext
|
||||||
|
)
|
||||||
failcount += 1
|
failcount += 1
|
||||||
|
|
||||||
print("written "+submission.id+" submitted "+str(round(time.time()-submission.created_utc))+" seconds ago")
|
print("written "+submission.id+", submitted "+str(round(time.time()-submission.created_utc))+" seconds ago")
|
||||||
totalcount += 1
|
totalcount += 1
|
||||||
|
|
||||||
# Remove ,\n
|
# Remove ,\n
|
||||||
|
|
Loading…
Reference in a new issue