Merge pull request 'fix: don't pull the same post twice' (#19) from knoflook/lumbunglib:master into master
Reviewed-on: ruangrupa/lumbunglib#19
This commit is contained in:
commit
aefdb15d48
@ -103,6 +103,10 @@ def main():
|
||||
if not os.path.exists(output_dir):
|
||||
os.mkdir(output_dir)
|
||||
|
||||
all_existing_posts = []
|
||||
for i in os.listdir(output_dir):
|
||||
all_existing_posts += os.listdir(os.path.join(output_dir, i))
|
||||
|
||||
for hashtag in hashtags:
|
||||
|
||||
hashtag_dir = os.path.join(output_dir, hashtag)
|
||||
@ -122,12 +126,13 @@ def main():
|
||||
post_dir = os.path.join(hashtag_dir, str(post_metadata["id"]))
|
||||
|
||||
# if there is a post in the feed we dont already have locally, make it
|
||||
if str(post_metadata["id"]) not in existing_posts:
|
||||
if str(post_metadata["id"]) not in all_existing_posts:
|
||||
|
||||
if not post_metadata[
|
||||
"local_only"
|
||||
]: # if you get an error here then you are using vanilla Mastodon, this is a Hometown or Glitch only feature
|
||||
create_post(post_dir, post_metadata)
|
||||
all_existing_posts.append(post_metadata["id"])
|
||||
else:
|
||||
print("not pulling post %s (post is local only)" % (post_metadata["id"]))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user