# app.py import gradio as gr from bs4 import BeautifulSoup import re import logging import requests # 추가코드에서 사용 # 디버깅 로깅 설정 (전체 통합을 위해 포맷 포함) logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(levelname)s - %(message)s") # ---------- [모듈1: 기본코드] 시작 ---------- # 영어 월을 한국어 월로 변환하기 위한 매핑 month_mapping = { "January": "1월", "February": "2월", "March": "3월", "April": "4월", "May": "5월", "June": "6월", "July": "7월", "August": "8월", "September": "9월", "October": "10월", "November": "11월", "December": "12월" } def convert_date_range(date_range_str): """ 입력된 '6 January - 12 January' 형태의 날짜 문자열을 '1월 6일 ~ 1월 12일' 형태로 변환하는 함수. """ logging.debug("원본 날짜 범위: %s", date_range_str) parts = date_range_str.split('-') if len(parts) != 2: logging.debug("날짜 범위 형식이 올바르지 않음: %s", date_range_str) return date_range_str start = parts[0].strip() # 예: "6 January" end = parts[1].strip() # 예: "12 January" start_parts = start.split() end_parts = end.split() if len(start_parts) < 2 or len(end_parts) < 2: logging.debug("날짜 구성요소 부족: %s, %s", start, end) return date_range_str start_day = start_parts[0] start_month_en = start_parts[1] end_day = end_parts[0] end_month_en = end_parts[1] start_month = month_mapping.get(start_month_en, start_month_en) end_month = month_mapping.get(end_month_en, end_month_en) converted = f"{start_month} {start_day}일 ~ {end_month} {end_day}일" logging.debug("변환된 날짜 범위: %s", converted) return converted def process_html(html_text): """ 전체 페이지 HTML 입력을 받아서 과목명과 각 섹션별 동영상 강의 목록을 추출하는 함수. 추출 규칙: 1. 과목명: