seawolf2357 commited on
Commit
f31d39f
ยท
verified ยท
1 Parent(s): 19ef13d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -23,20 +23,25 @@ def gradio_fetch_and_parse(url):
23
 
24
  def get_main_content(html_content):
25
  soup = BeautifulSoup(html_content, 'html.parser')
26
- # ์˜ˆ: ๋ณธ๋ฌธ ๋‚ด์šฉ์ด <div class="main-content"> ์•ˆ์— ์žˆ๋‹ค๊ณ  ๊ฐ€์ •
27
  main_content = soup.find('div', class_='main-content')
28
- return main_content.get_text(strip=True) if main_content else ''
 
 
 
 
 
29
 
30
  def format_script(text):
31
- # ํ…์ŠคํŠธ๋ฅผ ๋ฌธ์žฅ๋ณ„๋กœ ๋ถ„๋ฆฌ
32
  sentences = text.split('.')
33
- # 2๋ฌธ์žฅ์”ฉ ๋ฌถ์–ด์„œ ์Šคํฌ๋ฆฝํŠธ ํ˜•ํƒœ๋กœ ์ž‘์„ฑ
34
  script = ""
35
  for i in range(0, min(len(sentences), 10), 2):
36
- script += sentences[i].strip() + '. '
37
  if i+1 < len(sentences):
38
- script += sentences[i+1].strip() + '\n'
 
 
39
  return script
 
40
 
41
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ํ•จ์ˆ˜
42
  def gradio_fetch_and_format_script(url):
 
23
 
24
  def get_main_content(html_content):
25
  soup = BeautifulSoup(html_content, 'html.parser')
 
26
  main_content = soup.find('div', class_='main-content')
27
+ if main_content:
28
+ text = main_content.get_text(strip=True)
29
+ print("์ถ”์ถœ๋œ ํ…์ŠคํŠธ:", text) # ๋””๋ฒ„๊น…์„ ์œ„ํ•œ ๋กœ๊ทธ
30
+ return text
31
+ else:
32
+ return ''
33
 
34
  def format_script(text):
 
35
  sentences = text.split('.')
 
36
  script = ""
37
  for i in range(0, min(len(sentences), 10), 2):
38
+ line = sentences[i].strip() + '. '
39
  if i+1 < len(sentences):
40
+ line += sentences[i+1].strip() + '\n'
41
+ script += line
42
+ print("ํ˜„์žฌ ์Šคํฌ๋ฆฝํŠธ:", script) # ๋””๋ฒ„๊น…์„ ์œ„ํ•œ ๋กœ๊ทธ
43
  return script
44
+
45
 
46
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ํ•จ์ˆ˜
47
  def gradio_fetch_and_format_script(url):