Skip to content

Commit 3a75ff9

Browse files
committed
Log: add permalink URL to all log entries
Adds a direct URL to each deleted item so you can verify what was deleted (Reddit keeps deleted items accessible by direct URL for a period). Uses comment.permalink / submission.permalink, prepended with https://reddit.com. deleted_comments.txt: date | score | permalink | body deleted_posts.txt: title, date, score, subreddit, permalink https://claude.ai/code/session_014HLhrFtCVRFnEyfRexiy3d
1 parent 41c9d31 commit 3a75ff9

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

PostCleaner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def delete_old_posts(reddit, username, days_old, posts_deleted):
103103
if submission.created_utc < (time.time() - (days_old * 86400)):
104104
# save post title, date, karma, and subreddit deleted to a file with utf-8 encoding
105105
with open("deleted_posts.txt", "a", encoding="utf-8") as f:
106-
f.write(f"{submission.title}, {datetime.utcfromtimestamp(submission.created_utc)}, {submission.score}, {submission.subreddit.display_name}\n")
106+
f.write(f"{submission.title}, {datetime.utcfromtimestamp(submission.created_utc)}, {submission.score}, {submission.subreddit.display_name}, https://reddit.com{submission.permalink}\n")
107107
try:
108108
submission.edit(".")
109109
submission.delete()

commentCleaner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def delete_old_comments(reddit, username, days_old, comments_deleted):
105105
comment_date = datetime.utcfromtimestamp(comment.created_utc).strftime("%Y-%m-%d %H:%M:%S")
106106
with open('deleted_comments.txt', 'a', encoding='utf-8') as f:
107107
# Write the date, karma score, and comment body to the file
108-
f.write(f"{comment_date} | {comment.score} | {comment.body}\n")
108+
f.write(f"{comment_date} | {comment.score} | https://reddit.com{comment.permalink} | {comment.body}\n")
109109
try:
110110
comment.edit(".")
111111
comment.delete()
@@ -131,7 +131,7 @@ def remove_comments_with_negative_karma(reddit, username, comments_deleted):
131131
comment_date = datetime.utcfromtimestamp(comment.created_utc).strftime("%Y-%m-%d %H:%M:%S")
132132
with open('deleted_comments.txt', 'a', encoding='utf-8') as f:
133133
# Write the date, karma score, and comment body to the file
134-
f.write(f"{comment_date} | {comment.score} | {comment.body}\n")
134+
f.write(f"{comment_date} | {comment.score} | https://reddit.com{comment.permalink} | {comment.body}\n")
135135
try:
136136
comment.edit(".")
137137
comment.delete()
@@ -166,7 +166,7 @@ def remove_comments_with_one_karma_and_no_replies(reddit, username, comments_del
166166

167167
with open('deleted_comments.txt', 'a', encoding='utf-8') as f:
168168
# Write the date, karma score, and comment to the file
169-
f.write(f"{comment_date} | {comment.score} | {comment.body}\n")
169+
f.write(f"{comment_date} | {comment.score} | https://reddit.com{comment.permalink} | {comment.body}\n")
170170
try:
171171
comment.edit(".")
172172
comment.delete()

web/app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def api_delete():
128128
comment = reddit.comment(cid)
129129
date_str = datetime.utcfromtimestamp(comment.created_utc).strftime("%Y-%m-%d %H:%M:%S")
130130
with open(DELETED_COMMENTS_FILE, "a", encoding="utf-8") as f:
131-
f.write(f"{date_str} | {comment.score} | {comment.body}\n")
131+
f.write(f"{date_str} | {comment.score} | https://reddit.com{comment.permalink} | {comment.body}\n")
132132
comment.edit(".")
133133
comment.delete()
134134
deleted_comments += 1
@@ -143,7 +143,8 @@ def api_delete():
143143
f"{submission.title}, "
144144
f"{datetime.utcfromtimestamp(submission.created_utc)}, "
145145
f"{submission.score}, "
146-
f"{submission.subreddit.display_name}\n"
146+
f"{submission.subreddit.display_name}, "
147+
f"https://reddit.com{submission.permalink}\n"
147148
)
148149
submission.edit(".")
149150
submission.delete()

weekly_cleanup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def main():
8181
if _should_delete(comment):
8282
date_str = datetime.fromtimestamp(comment.created_utc, tz=timezone.utc).strftime("%Y-%m-%d %H:%M:%S")
8383
with open("deleted_comments.txt", "a", encoding="utf-8") as f:
84-
f.write(f"{date_str} | {comment.score} | {comment.body}\n")
84+
f.write(f"{date_str} | {comment.score} | https://reddit.com{comment.permalink} | {comment.body}\n")
8585
try:
8686
comment.edit(".")
8787
comment.delete()
@@ -100,7 +100,8 @@ def main():
100100
f"{submission.title}, "
101101
f"{datetime.fromtimestamp(submission.created_utc, tz=timezone.utc)}, "
102102
f"{submission.score}, "
103-
f"{submission.subreddit.display_name}\n"
103+
f"{submission.subreddit.display_name}, "
104+
f"https://reddit.com{submission.permalink}\n"
104105
)
105106
try:
106107
submission.edit(".")

0 commit comments

Comments
 (0)