GuglielmoTor commited on
Commit
738320e
·
verified ·
1 Parent(s): b5c877f

Update Linkedin_Data_API_Calls.py

Browse files
Files changed (1) hide show
  1. Linkedin_Data_API_Calls.py +3 -3
Linkedin_Data_API_Calls.py CHANGED
@@ -115,7 +115,7 @@ def fetch_linkedin_posts_core(comm_client_id, community_token, org_urn, count):
115
  "published_at_iso": published_at_iso,
116
  # These are placeholders for actual fields from LinkedIn API response. Verify field names.
117
  "organization_urn": p.get("author", "urn:li:unknown"), # e.g., "urn:li:person:xxxx" or "urn:li:organization:xxxx"
118
- "is_ad": p.get("is_ad", False) # LinkedIn might use a different field like 'sponsored' or 'promoted'
119
  #"media_type": p.get("mediaCategory", "NONE") # e.g., ARTICLE, IMAGE, VIDEO, NONE
120
  })
121
  logging.info(f"Processed {len(processed_raw_posts)} posts with core data.")
@@ -290,7 +290,7 @@ def compile_detailed_posts(processed_raw_posts, stats_map, sentiments_per_post):
290
  "summary": proc_post["summary"],
291
  "category": proc_post["category"],
292
  "organization_urn": proc_post["organization_urn"],
293
- "is_ad": proc_post["is_ad"],
294
  #"media_type": proc_post["media_type"],
295
  "published_at": proc_post["published_at_iso"] # ISO format datetime string
296
  })
@@ -314,7 +314,7 @@ def prepare_data_for_bubble(detailed_posts, all_actual_comments_data):
314
  li_posts.append({
315
  "organization_urn": post_data["organization_urn"],
316
  "id": post_data["id"], # Post URN
317
- "is_ad": post_data["is_ad"],
318
  #"media_type": post_data["media_type"],
319
  "published_at": post_data["published_at"], # ISO datetime string
320
  "sentiment": post_data["sentiment"], # Overall sentiment of the post based on its comments
 
115
  "published_at_iso": published_at_iso,
116
  # These are placeholders for actual fields from LinkedIn API response. Verify field names.
117
  "organization_urn": p.get("author", "urn:li:unknown"), # e.g., "urn:li:person:xxxx" or "urn:li:organization:xxxx"
118
+ "is_ad": 'adContext' in p
119
  #"media_type": p.get("mediaCategory", "NONE") # e.g., ARTICLE, IMAGE, VIDEO, NONE
120
  })
121
  logging.info(f"Processed {len(processed_raw_posts)} posts with core data.")
 
290
  "summary": proc_post["summary"],
291
  "category": proc_post["category"],
292
  "organization_urn": proc_post["organization_urn"],
293
+ "is_ad": 'adContext' in proc_post,
294
  #"media_type": proc_post["media_type"],
295
  "published_at": proc_post["published_at_iso"] # ISO format datetime string
296
  })
 
314
  li_posts.append({
315
  "organization_urn": post_data["organization_urn"],
316
  "id": post_data["id"], # Post URN
317
+ "is_ad": 'adContext' in post_data,
318
  #"media_type": post_data["media_type"],
319
  "published_at": post_data["published_at"], # ISO datetime string
320
  "sentiment": post_data["sentiment"], # Overall sentiment of the post based on its comments