From 9a57e4f1a13d841b0ba07bdaea09788916adf2da Mon Sep 17 00:00:00 2001 From: Anders Glent Buch Date: Tue, 26 Mar 2024 14:06:31 +0100 Subject: [PATCH] Add coauthors to Post --- ensta/Guest.py | 13 ++++++++++++- ensta/containers/Post.py | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ensta/Guest.py b/ensta/Guest.py index fada640..a9d2ec4 100644 --- a/ensta/Guest.py +++ b/ensta/Guest.py @@ -443,6 +443,16 @@ def __process_post_data(data: dict, reel: bool = False) -> Post: latest_reel_media=user_data.get("latest_reel_media", 0) ) + coauthors = [] + for coauthor in data.get("coauthor_producers", []): + coauthors.append( + { + "uid": coauthor.get("pk", ""), + "username": coauthor.get("username", ""), + "full_name": coauthor.get("full_name", ""), + } + ) + return Post( share_url=f"https://www.instagram.com/reel/{data.get('code', '')}" if reel @@ -482,5 +492,6 @@ def __process_post_data(data: dict, reel: bool = False) -> Post: explore_hide_comments=data.get("explore_hide_comments", False), has_delayed_metadata=data.get("has_delayed_metadata", False), location_latitude=data.get("lat", 0), - location_longitude=data.get("lng", 0) + location_longitude=data.get("lng", 0), + coauthors=coauthors, ) diff --git a/ensta/containers/Post.py b/ensta/containers/Post.py index ed5a691..0453805 100644 --- a/ensta/containers/Post.py +++ b/ensta/containers/Post.py @@ -41,3 +41,4 @@ class Post: has_delayed_metadata: bool = False location_latitude: float = 0 location_longitude: float = 0 + coauthors: list[dict] = field(default_factory=list)