# ThreadAuto 3타입 실전 업로드 테스트

## 목표
텍스트, 카드뉴스, 영상 3가지 타입을 **각각 다른 주제**로 Threads에 실제 업로드.
순차 실행 (Threads API rate limit 고려).

## 프로젝트 경로
- ThreadAuto: `/home/jay/projects/ThreadAuto`

## 사전 확인 (3건 모두 시작 전)
1. **OAuth 토큰 확인**: `/home/jay/projects/ThreadAuto/.tokens/token.json` 유효성 체크. 만료 임박 시 refresh.
2. **Tailscale Funnel 확인**: 카드뉴스/영상 업로드에 필요. `curl -s https://aidevserver.tail2cdab6.ts.net/images/ | head -5` 로 확인. 안 되면 ImageServer 가동.
3. **환경변수**: `source /home/jay/workspace/.env.keys`

## 테스트 1: 텍스트 업로드
1. 토픽 선택 (텍스트에 적합한 카테고리):
```python
from content.topic_selector import select_single_topic
topic = select_single_topic(category="공감/위로")  # 텍스트에 적합
```
2. 5단계 파이프라인 실행:
```python
from content.five_stage_pipeline import FiveStagePipeline
pipeline = FiveStagePipeline()
result = pipeline.generate(topic=topic, content_type="text_sns")
```
3. Threads 업로드:
```python
from publisher.threads_publisher import ThreadsPublisher
pub = ThreadsPublisher()
publish_result = pub.publish({"content": result, "image_path": "", "video_path": ""})
```
4. 결과 기록: `publish_result` (success, threads_post_id) 저장

## 테스트 2: 카드뉴스 (캐러셀) 업로드
1. 토픽 선택 (카드뉴스에 적합):
```python
topic = select_single_topic(category="정보제공")  # 카드뉴스에 적합
```
2. 5단계 파이프라인 실행:
```python
result = pipeline.generate(topic=topic, content_type="cardnews")
```
3. 카드뉴스 이미지 렌더링:
```python
from rendering.cardnews_renderer import CardNewsRenderer
renderer = CardNewsRenderer()
image_paths = renderer.render_from_slides(result["slides"], theme=result.get("card_type", "E"))
```
4. Threads 캐러셀 업로드:
```python
publish_result = pub.publish_cardnews(
    title=result["slides"][0].get("title", ""),
    items=result["slides"],
    content=result
)
```
5. 결과 기록

## 테스트 3: 영상 (숏폼) 업로드
1. 토픽 선택 (영상에 적합):
```python
topic = select_single_topic(category="전문성")  # 영상에 적합
```
2. 5단계 파이프라인 실행:
```python
result = pipeline.generate(topic=topic, content_type="cardnews")  # 영상도 카드뉴스 구조 기반
```
3. 숏폼 영상 렌더링 (Remotion 또는 ShortformRenderer):
```python
from rendering.shortform_renderer import ShortformRenderer
renderer = ShortformRenderer()
video_path = renderer.render(result)
```
※ ShortformRenderer 경로/인터페이스가 다르면 `rendering/` 디렉토리 구조 확인 후 적절히 호출
※ Remotion 기반이면 Node.js 실행 필요할 수 있음 - 확인 후 진행
4. Threads 비디오 업로드:
```python
from publisher.image_server import ImageServer
server = ImageServer()
video_url = server.get_public_url(video_path)
publish_result = pub.publish({"content": result, "image_path": "", "video_path": video_path})
```
5. 결과 기록

## 결과 보고 형식
각 테스트별로:
- 선택된 토픽 (id, title)
- 파이프라인 결과 (review_score)
- 업로드 성공 여부 (threads_post_id)
- 실패 시: 에러 메시지 + 스택트레이스 전문

## 주의사항
- **업로드된 게시물 절대 삭제 금지** (제이회장님 확인 전까지)
- **의미 있는 주제** 사용 (검정 화면, 테스트 문구 등 무의미 데이터 금지)
- **실패 로그 보존 필수** — 성공 건만 보고하지 말 것, 실패도 상세히 기록
- 각 테스트 사이 충분한 간격 (API rate limit)
- 모든 결과 파일을 `/home/jay/projects/ThreadAuto/output/upload_test_YYYYMMDD/` 에 저장
