feat: YouTube Shorts 파이프라인 완성 및 HJW TV 업로드 연동
- youtube_uploader.py: YOUTUBE_REFRESH_TOKEN/CLIENT_ID/CLIENT_SECRET 환경변수 폴백 추가 (token.json 없는 Docker 환경에서 브랜드 계정 인증 가능) - shorts_config.json: corners_eligible를 실제 블로그 코너명으로 수정 - caption_renderer.py: render_captions() 반환값 누락 수정 - get_token.py: web→installed 타입 변환, port 8080 고정, prompt=consent 추가 - get_youtube_token.py: YouTube 전용 OAuth 토큰 발급 스크립트 (별도 클라이언트) - CLAUDE.md: 프로젝트 개요, 배포 방법, 핵심 파일, YouTube 채널 정보 추가 - publisher_bot.py: 이미지 분산 배치, SEO 검증, 버그 수정 - scheduler.py: 알림 강화, atomic write, 중복 방지, hot reload 개선 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -39,8 +39,13 @@ def main():
|
||||
creds.refresh(Request())
|
||||
print("[OK] 기존 토큰 갱신 완료")
|
||||
else:
|
||||
flow = InstalledAppFlow.from_client_secrets_file(CREDENTIALS_PATH, SCOPES)
|
||||
creds = flow.run_local_server(port=0)
|
||||
# credentials.json이 "web" 타입이면 "installed"로 변환
|
||||
with open(CREDENTIALS_PATH) as f:
|
||||
client_config = json.load(f)
|
||||
if 'web' in client_config and 'installed' not in client_config:
|
||||
client_config['installed'] = client_config.pop('web')
|
||||
flow = InstalledAppFlow.from_client_config(client_config, SCOPES)
|
||||
creds = flow.run_local_server(port=8080, prompt='consent')
|
||||
print("[OK] 새 토큰 발급 완료")
|
||||
|
||||
with open(TOKEN_PATH, 'w') as token_file:
|
||||
|
||||
47
scripts/get_youtube_token.py
Normal file
47
scripts/get_youtube_token.py
Normal file
@@ -0,0 +1,47 @@
|
||||
"""
|
||||
YouTube 전용 OAuth2 토큰 발급 스크립트
|
||||
credentials_youtube.json 사용 (Blogger와 별도 OAuth 클라이언트)
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
from google_auth_oauthlib.flow import InstalledAppFlow
|
||||
from google.oauth2.credentials import Credentials
|
||||
from google.auth.transport.requests import Request
|
||||
|
||||
SCOPES = [
|
||||
'https://www.googleapis.com/auth/youtube.upload',
|
||||
'https://www.googleapis.com/auth/youtube',
|
||||
]
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
CREDENTIALS_PATH = os.path.join(BASE_DIR, 'credentials_youtube.json')
|
||||
|
||||
|
||||
def main():
|
||||
if not os.path.exists(CREDENTIALS_PATH):
|
||||
print(f"[ERROR] credentials_youtube.json 없음: {CREDENTIALS_PATH}")
|
||||
sys.exit(1)
|
||||
|
||||
with open(CREDENTIALS_PATH) as f:
|
||||
client_config = json.load(f)
|
||||
if 'web' in client_config and 'installed' not in client_config:
|
||||
client_config['installed'] = client_config.pop('web')
|
||||
|
||||
flow = InstalledAppFlow.from_client_config(client_config, SCOPES)
|
||||
creds = flow.run_local_server(port=8080, prompt='consent')
|
||||
print("[OK] 새 토큰 발급 완료")
|
||||
|
||||
token_data = json.loads(creds.to_json())
|
||||
refresh_token = token_data.get('refresh_token', '')
|
||||
|
||||
print("\n" + "=" * 50)
|
||||
print("YouTube 토큰 발급 성공!")
|
||||
print("=" * 50)
|
||||
print(f"\nYOUTUBE_REFRESH_TOKEN:\n{refresh_token}")
|
||||
print(f"\n이 값을 .env 파일의 YOUTUBE_REFRESH_TOKEN 에 붙여넣으세요.")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user