feat: Add February 2026 content calendar and thread publishing support
- Generate 24 posts for February: 12 tips, 4 threads, 8 promotional - Schedule automatic publication at optimal times - Update publish_to_platform to handle hilo_educativo as threads - Parse JSON thread posts and publish using publish_thread() Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -67,6 +67,7 @@ def publish_scheduled_posts():
|
||||
)
|
||||
def publish_to_platform(self, post_id: int, platform: str):
|
||||
"""Publicar un post en una plataforma específica."""
|
||||
import json
|
||||
db = SessionLocal()
|
||||
|
||||
try:
|
||||
@@ -74,19 +75,33 @@ def publish_to_platform(self, post_id: int, platform: str):
|
||||
if not post:
|
||||
return f"Post {post_id} no encontrado"
|
||||
|
||||
# Obtener contenido para esta plataforma
|
||||
content = post.get_content_for_platform(platform)
|
||||
|
||||
# Obtener publisher
|
||||
try:
|
||||
publisher = get_publisher(platform)
|
||||
except ValueError as e:
|
||||
return f"Error: {e}"
|
||||
|
||||
# Publicar
|
||||
result = run_async(
|
||||
publisher.publish(content, post.image_url)
|
||||
)
|
||||
# Verificar si es un hilo
|
||||
if post.content_type == "hilo_educativo":
|
||||
# Parsear posts del hilo desde content_x (JSON)
|
||||
try:
|
||||
thread_posts = json.loads(post.content_x) if post.content_x else []
|
||||
if not thread_posts:
|
||||
# Fallback: separar contenido por doble salto de línea
|
||||
thread_posts = [p.strip() for p in post.content.split("\n\n") if p.strip()]
|
||||
except json.JSONDecodeError:
|
||||
thread_posts = [p.strip() for p in post.content.split("\n\n") if p.strip()]
|
||||
|
||||
# Publicar como hilo
|
||||
result = run_async(
|
||||
publisher.publish_thread(thread_posts)
|
||||
)
|
||||
else:
|
||||
# Publicación normal
|
||||
content = post.get_content_for_platform(platform)
|
||||
result = run_async(
|
||||
publisher.publish(content, post.image_url)
|
||||
)
|
||||
|
||||
if result.success:
|
||||
# Guardar ID del post en la plataforma
|
||||
|
||||
Reference in New Issue
Block a user