틱톡·영문 인스타/페북 채널 수집 추가
- apify: 틱톡 프로필 액터 - mock_urls.py: 클리닉별 채널 URL 매핑 (mockUrls.json → 파이썬 모듈) - api/analysis: homepage 매칭으로 미지원 채널 보충 (추후 DB) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
cb798f7acc
commit
9817b53be1
4 files changed
+215
-1
No files matched your search
+27
-1
@@ -8,10 +8,28 @@ from models.file import FileListItem, FileType, FileUploadResponse
|
||||
from models.status import AnalysisStatus
|
||||
from services.pipeline import run_pipeline
|
||||
from services.file import get_analysis_files_response, handle_analysis_file_upload, soft_delete_analysis_file
|
||||
from mock_urls import MOCK_CLINICS
|
||||
from common.utils import _normalize_homepage, _with_scheme
|
||||
|
||||
router = APIRouter(prefix="/api/analysis", tags=["analysis"], dependencies=[Depends(verify_api_key)])
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# 추후 DB에 클리닉별로 매핑할 채널(틱톡/영문 인스타·페북). 지금은 mock_urls에서 homepage 매칭으로 보충.
|
||||
def _extra_channels_from_mockurls(homepage_url: str) -> dict:
|
||||
"""homepage로 mock_urls에서 클리닉을 찾아 틱톡/영문 인스타·페북 URL 반환 (없으면 {})."""
|
||||
target = _normalize_homepage(homepage_url)
|
||||
if not target:
|
||||
return {}
|
||||
for c in MOCK_CLINICS:
|
||||
urls = c["urls"]
|
||||
if _normalize_homepage(urls.get("homepage", "")) == target:
|
||||
return {
|
||||
"tiktok": _with_scheme(urls.get("tiktok")),
|
||||
"instagram_en": _with_scheme(urls.get("instagramEn")),
|
||||
"facebook_en": _with_scheme(urls.get("facebookEn")),
|
||||
}
|
||||
return {}
|
||||
|
||||
|
||||
@router.post("", status_code=status.HTTP_202_ACCEPTED, response_model=AnalysisStartResponse)
|
||||
async def start_analysis(body: AnalysisCreate, background_tasks: BackgroundTasks):
|
||||
@@ -38,7 +56,15 @@ async def start_analysis(body: AnalysisCreate, background_tasks: BackgroundTasks
|
||||
ig_id, fb_id, nb_id, yt_id, gu_id,
|
||||
)
|
||||
|
||||
background_tasks.add_task(run_pipeline, analysis_run_id)
|
||||
# 클라 값 우선, 없으면 보충 (추후 DB에서 클리닉별로 가져올 값)
|
||||
mock_extra = _extra_channels_from_mockurls(hospital["url"])
|
||||
extra_channels = {
|
||||
"tiktok": body.channels.tiktok or mock_extra.get("tiktok"),
|
||||
"instagram_en": body.channels.instagram_en or mock_extra.get("instagram_en"),
|
||||
"facebook_en": body.channels.facebook_en or mock_extra.get("facebook_en"),
|
||||
}
|
||||
logger.info("[analysis] extra_channels=%s (mock_matched=%s)", extra_channels, bool(mock_extra))
|
||||
background_tasks.add_task(run_pipeline, analysis_run_id, extra_channels)
|
||||
|
||||
return AnalysisStartResponse(
|
||||
analysis_run_id=analysis_run_id,
|
||||
|
||||
Reference in new issue
Block a user