Files
site11/backup-services/rss-feed/backend/app/google_rss.py
jungwoo choi 070032006e feat: Implement async queue-based news pipeline with microservices
Major architectural transformation from synchronous to asynchronous processing:

## Pipeline Services (8 microservices)
- pipeline-scheduler: APScheduler for 30-minute periodic job triggers
- pipeline-rss-collector: RSS feed collection with deduplication (7-day TTL)
- pipeline-google-search: Content enrichment via Google Search API
- pipeline-ai-summarizer: AI summarization using Claude API (claude-sonnet-4-20250514)
- pipeline-translator: Translation using DeepL Pro API
- pipeline-image-generator: Image generation with Replicate API (Stable Diffusion)
- pipeline-article-assembly: Final article assembly and MongoDB storage
- pipeline-monitor: Real-time monitoring dashboard (port 8100)

## Key Features
- Redis-based job queue with deduplication
- Asynchronous processing with Python asyncio
- Shared models and queue manager for inter-service communication
- Docker containerization for all services
- Container names standardized with site11_ prefix

## Removed Services
- Moved to backup: google-search, rss-feed, news-aggregator, ai-writer

## Configuration
- DeepL Pro API: 3abbc796-2515-44a8-972d-22dcf27ab54a
- Claude Model: claude-sonnet-4-20250514
- Redis Queue TTL: 7 days for deduplication

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-13 19:22:14 +09:00

115 lines
3.6 KiB
Python

"""
Google News RSS Feed Generator
구글 뉴스 RSS 피드 URL 생성 및 구독 지원
"""
from typing import Optional, List
from urllib.parse import quote_plus
from enum import Enum
class GoogleNewsCategory(str, Enum):
"""구글 뉴스 카테고리"""
WORLD = "WORLD"
NATION = "NATION"
BUSINESS = "BUSINESS"
TECHNOLOGY = "TECHNOLOGY"
ENTERTAINMENT = "ENTERTAINMENT"
SPORTS = "SPORTS"
SCIENCE = "SCIENCE"
HEALTH = "HEALTH"
class GoogleNewsRSS:
"""Google News RSS 피드 URL 생성기"""
BASE_URL = "https://news.google.com/rss"
@staticmethod
def search_feed(query: str, lang: str = "ko", country: str = "KR") -> str:
"""
키워드 검색 RSS 피드 URL 생성
Args:
query: 검색 키워드
lang: 언어 코드 (ko, en, ja, zh-CN 등)
country: 국가 코드 (KR, US, JP, CN 등)
Returns:
RSS 피드 URL
"""
encoded_query = quote_plus(query)
return f"{GoogleNewsRSS.BASE_URL}/search?q={encoded_query}&hl={lang}&gl={country}&ceid={country}:{lang}"
@staticmethod
def topic_feed(category: GoogleNewsCategory, lang: str = "ko", country: str = "KR") -> str:
"""
카테고리별 RSS 피드 URL 생성
Args:
category: 뉴스 카테고리
lang: 언어 코드
country: 국가 코드
Returns:
RSS 피드 URL
"""
return f"{GoogleNewsRSS.BASE_URL}/headlines/section/topic/{category.value}?hl={lang}&gl={country}&ceid={country}:{lang}"
@staticmethod
def location_feed(location: str, lang: str = "ko", country: str = "KR") -> str:
"""
지역 뉴스 RSS 피드 URL 생성
Args:
location: 지역명 (예: Seoul, 서울, New York)
lang: 언어 코드
country: 국가 코드
Returns:
RSS 피드 URL
"""
encoded_location = quote_plus(location)
return f"{GoogleNewsRSS.BASE_URL}/headlines/section/geo/{encoded_location}?hl={lang}&gl={country}&ceid={country}:{lang}"
@staticmethod
def trending_feed(lang: str = "ko", country: str = "KR") -> str:
"""
트렌딩 뉴스 RSS 피드 URL 생성
Args:
lang: 언어 코드
country: 국가 코드
Returns:
RSS 피드 URL
"""
return f"{GoogleNewsRSS.BASE_URL}?hl={lang}&gl={country}&ceid={country}:{lang}"
@staticmethod
def get_common_feeds() -> List[dict]:
"""
자주 사용되는 RSS 피드 목록 반환
Returns:
피드 정보 리스트
"""
return [
{
"title": "구글 뉴스 - 한국 헤드라인",
"url": GoogleNewsRSS.trending_feed("ko", "KR"),
"description": "한국 주요 뉴스"
},
{
"title": "구글 뉴스 - 기술",
"url": GoogleNewsRSS.topic_feed(GoogleNewsCategory.TECHNOLOGY, "ko", "KR"),
"description": "기술 관련 뉴스"
},
{
"title": "구글 뉴스 - 비즈니스",
"url": GoogleNewsRSS.topic_feed(GoogleNewsCategory.BUSINESS, "ko", "KR"),
"description": "비즈니스 뉴스"
},
{
"title": "Google News - World",
"url": GoogleNewsRSS.topic_feed(GoogleNewsCategory.WORLD, "en", "US"),
"description": "World news in English"
}
]