From dc0d94a2747b284cd9e3e6165c1c5ebdd7b8b46c Mon Sep 17 00:00:00 2001 From: nanos Date: Thu, 30 Mar 2023 11:24:53 +0100 Subject: [PATCH] Add Context when adding posts --- find_posts.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/find_posts.py b/find_posts.py index 330e5c7..1ccea7e 100644 --- a/find_posts.py +++ b/find_posts.py @@ -133,7 +133,7 @@ def add_user_posts(server, access_token, followings, know_followings, all_known_ failed = 0 for post in posts: if post['url'] != None and post['url'] not in seen_urls: - added = add_context_url(post['url'], server, access_token) + added = add_post_with_context(post, server, access_token, seen_urls) if added is True: seen_urls.add(post['url']) count += 1 @@ -144,6 +144,20 @@ def add_user_posts(server, access_token, followings, know_followings, all_known_ know_followings.add(user['acct']) all_known_users.add(user['acct']) +def add_post_with_context(post, server, access_token, seen_urls): + added = add_context_url(post['url'], server, access_token) + if added is True: + seen_urls.add(post['url']) + parsed_urls = {} + parsed = parse_url(post['url'], parsed_urls) + if parsed == None: + return True + known_context_urls = get_all_known_context_urls(server, [post],parsed_urls) + add_context_urls(server, access_token, known_context_urls, seen_urls) + return True + + return False + def get_user_posts(user, know_followings, server): parsed_url = parse_user_url(user['url'])