From d9e998750c8070b25bf538e940a320981fb1aaf9 Mon Sep 17 00:00:00 2001 From: likho Date: Sun, 16 Apr 2023 10:25:20 -0700 Subject: [PATCH] added http requests for remote profiles --- microblog.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/microblog.py b/microblog.py index ef5a837..25e1aa0 100644 --- a/microblog.py +++ b/microblog.py @@ -349,6 +349,8 @@ if __name__ == "__main__": import json # generate json basd on profile def export_profile(post_count, last_update, config): + if "profile" not in config: + return if "alias" not in config["profile"] \ or "url" not in config["profile"]: print("Warning: no profile exported", file=sys.stderr) @@ -359,9 +361,20 @@ if __name__ == "__main__": "last-updated": last_update, "post-count" : post_count } + if "avatar" in config["profile"]: + profile["avatar"] = config["profile"]["avatar"] with open(config["file_output"], 'w') as f: print(json.dumps(profile), file=f) + import urllib.request as http + def fetch(follow_list): + objects = [] + for eceleb in follow_list: + with http.urlopen(eceleb) as response: + data = response.read() + objects.append(json.loads(data)) + return objects + def main(): tpl, content = get_args() cfg = load_settings()