From 6faec6f11dbec776af800c06222cf83d0eb4bf69 Mon Sep 17 00:00:00 2001 From: Hans5958 Date: Sat, 9 Apr 2022 21:42:05 +0700 Subject: [PATCH] Store and check read edit entry ids --- tools/merge_out.py | 18 +++++++++++++----- tools/redditcrawl.py | 5 +++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tools/merge_out.py b/tools/merge_out.py index aa526705..6fabcf48 100644 --- a/tools/merge_out.py +++ b/tools/merge_out.py @@ -8,13 +8,14 @@ out_ids = [] out_dupe_ids = [] +out_edited_added_ids = [] atlas_ids = [] with open('temp_atlas.json', 'r', encoding='utf-8') as out_file: - out_json = json.loads(out_file) + out_json = json.loads(out_file.read()) -with open('../atlas.json', 'r', encoding='utf-8') as atlas_file: - atlas_json = json.loads(atlas_file) +with open('../web/atlas.json', 'r', encoding='utf-8') as atlas_file: + atlas_json = json.loads(atlas_file.read()) for entry in atlas_json: atlas_ids.append(entry['id']) @@ -32,10 +33,17 @@ if ('edit' in entry and entry['edit']) or entry['id'] in out_ids: index = next((i for i, item in enumerate(atlas_json) if item["id"] == entry['id']), None) if 'edit' in entry: + out_edited_added_ids.append(entry['edit']) del entry['edit'] atlas_json[index] = entry else: atlas_json.append(entry) -with open('../atlas.json', 'w', encoding='utf-8') as atlas_file: - atlas_file.write(per_line_entries(atlas_json)) \ No newline at end of file +print('Writing...') +with open('../web/atlas.json', 'w', encoding='utf-8') as atlas_file: + atlas_file.write(per_line_entries(atlas_json)) + +with open('../data/edit-ids.txt', 'a', encoding='utf-8') as edit_ids_file: + edit_ids_file.write('\n'.join(out_edited_added_ids) + '\n') + +print('All done.') \ No newline at end of file diff --git a/tools/redditcrawl.py b/tools/redditcrawl.py index e27c087b..cf942c93 100755 --- a/tools/redditcrawl.py +++ b/tools/redditcrawl.py @@ -36,6 +36,11 @@ for id in [x.strip() for x in edit_ids_file.readlines()]: existing_ids.append(id) +with open('../data/edit-ids.txt', 'r') as edit_ids_file: + for id in [x.strip() for x in edit_ids_file.readlines()]: + existing_ids.append(id) + + def set_flair(submission, flair): if has_write_access and submission.link_flair_text != flair: flair_choices = submission.flair.choices()