Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify archive file list #115

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,13 +532,13 @@ def download_yt_dlp(self, post:dict):
def load_archive(self):
# load archived posts
if self.archive_file and os.path.exists(self.archive_file):
with open(self.archive_file,'r') as f:
with open(self.archive_file,'r', encoding="utf-8") as f:
self.archive_list = f.read().splitlines()

def write_archive(self, post:dict):
if self.archive_file and self.post_errors == 0 and not self.simulate:
with open(self.archive_file,'a') as f:
f.write("https://{site}/{service}/user/{user_id}/post/{id}".format(**post['post_variables']) + '\n')
with open(self.archive_file,'a', encoding="utf-8") as f:
f.write("{service} {username}({user_id}) {title} ({id})".format(**post['post_variables']) + '\n')

def skip_user(self, user:dict):
# check last update date
Expand All @@ -551,7 +551,7 @@ def skip_user(self, user:dict):
def skip_post(self, post:dict):
# check if the post should be downloaded
if self.archive_file:
if "https://{site}/{service}/user/{user_id}/post/{id}".format(**post['post_variables']) in self.archive_list:
if "{service} {username}({user_id}) {title} ({id})".format(**post['post_variables']) in self.archive_list:
logger.info("Skipping post | post already archived")
return True

Expand Down