Spaces:
Sleeping
Sleeping
Commit ·
43bad80
1
Parent(s): 0054399
fix: Add Instagram cross-maps for hashtag_sets/captions/content_ideas
Browse files- services/utils.py +21 -0
services/utils.py
CHANGED
|
@@ -263,6 +263,27 @@ def cross_map_fields(data: dict) -> dict:
|
|
| 263 |
data["viral_hashtags"] = [{"tag": h, "post_count": "N/A"} for h in data["hashtags"]]
|
| 264 |
if "best_posting_time" in data and "strategy_tips" not in data:
|
| 265 |
data["strategy_tips"] = [f"Post during: {data['best_posting_time']}"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 266 |
return data
|
| 267 |
|
| 268 |
|
|
|
|
| 263 |
data["viral_hashtags"] = [{"tag": h, "post_count": "N/A"} for h in data["hashtags"]]
|
| 264 |
if "best_posting_time" in data and "strategy_tips" not in data:
|
| 265 |
data["strategy_tips"] = [f"Post during: {data['best_posting_time']}"]
|
| 266 |
+
|
| 267 |
+
# Instagram cross-maps
|
| 268 |
+
if "hashtag_sets" in data and isinstance(data["hashtag_sets"], dict) and "hashtags" not in data:
|
| 269 |
+
all_tags = []
|
| 270 |
+
for tier in ["small", "medium", "large"]:
|
| 271 |
+
if tier in data["hashtag_sets"] and isinstance(data["hashtag_sets"][tier], list):
|
| 272 |
+
all_tags.extend(data["hashtag_sets"][tier])
|
| 273 |
+
if all_tags:
|
| 274 |
+
data["hashtags"] = all_tags
|
| 275 |
+
if "hashtags" in data and "core_keywords" not in data:
|
| 276 |
+
data["core_keywords"] = [{"keyword": t.lstrip("#"), "search_volume": "Medium", "competition": "Medium", "relevance": 80} for t in data["hashtags"]]
|
| 277 |
+
if "captions" in data and "content_titles" not in data:
|
| 278 |
+
data["content_titles"] = [c.get("caption", str(c)) for c in data["captions"] if isinstance(c, dict)]
|
| 279 |
+
if "content_ideas" in data and isinstance(data["content_ideas"], dict) and "strategy_tips" not in data:
|
| 280 |
+
ideas = []
|
| 281 |
+
for key in ["reels", "carousels", "stories"]:
|
| 282 |
+
if key in data["content_ideas"] and isinstance(data["content_ideas"][key], list):
|
| 283 |
+
ideas.extend(data["content_ideas"][key])
|
| 284 |
+
if ideas:
|
| 285 |
+
data["strategy_tips"] = ideas
|
| 286 |
+
|
| 287 |
return data
|
| 288 |
|
| 289 |
|