Update app.py
Browse files
app.py
CHANGED
|
@@ -12,26 +12,31 @@ def load_hidden_modules():
|
|
| 12 |
cleaned_code = youtube_transcript_code.replace("from youtube_transcript_module import", "# from youtube_transcript_module import")
|
| 13 |
exec(cleaned_code, globals())
|
| 14 |
|
| 15 |
-
# 2๋จ๊ณ: analyze_module ์ฝ๋ ๋ก๋
|
| 16 |
analyze_module_code = os.environ.get("ANALYZE_MODULE_CODE", "")
|
| 17 |
if analyze_module_code:
|
| 18 |
-
# import ๋ฌธ ์์
|
| 19 |
cleaned_code = analyze_module_code.replace("from youtube_transcript_module import YouTubeTranscriptClient", "# from youtube_transcript_module import YouTubeTranscriptClient")
|
|
|
|
|
|
|
| 20 |
exec(cleaned_code, globals())
|
| 21 |
|
| 22 |
-
# 3๋จ๊ณ: ๋๋จธ์ง blog ๋ชจ๋๋ค ๋ก๋
|
| 23 |
-
|
| 24 |
-
("GENERAL_BLOG_MODULE_CODE", "
|
| 25 |
-
("HEALTH_BLOG_MODULE_CODE", "
|
| 26 |
-
("TRAVEL_BLOG_MODULE_CODE", "
|
| 27 |
-
("PRODUCT_REVIEW_MODULE_CODE", "
|
| 28 |
]
|
| 29 |
|
| 30 |
-
for env_key,
|
| 31 |
module_code = os.environ.get(env_key, "")
|
| 32 |
if module_code:
|
| 33 |
-
# import ๋ฌธ ์ ๋ฆฌ
|
| 34 |
-
cleaned_code = module_code.replace(
|
|
|
|
|
|
|
|
|
|
| 35 |
exec(cleaned_code, globals())
|
| 36 |
|
| 37 |
# ์จ๊ฒจ์ง ๋ชจ๋๋ค ๋ก๋
|
|
@@ -53,18 +58,11 @@ def analyze_video(url):
|
|
| 53 |
def process_youtube_url(url, style):
|
| 54 |
"""์ผ๋ฐ ๋ธ๋ก๊ทธ API ์๋ํฌ์ธํธ - ๊ธฐ์กด ํ์ ์ ์ง"""
|
| 55 |
# general_blog_module์์ process_youtube_url ํจ์ ํธ์ถ
|
| 56 |
-
|
| 57 |
-
if not
|
| 58 |
-
# ํจ์๋ช
์ด ์ถฉ๋ํ๋ฏ๋ก ๋ค๋ฅธ ๋ฐฉ๋ฒ์ผ๋ก ์ฐพ๊ธฐ
|
| 59 |
-
for name, obj in globals().items():
|
| 60 |
-
if callable(obj) and name.startswith('process_youtube_url') and 'general' in name.lower():
|
| 61 |
-
process_youtube_url_func = obj
|
| 62 |
-
break
|
| 63 |
-
|
| 64 |
-
if not process_youtube_url_func:
|
| 65 |
return ["", "์ผ๋ฐ ๋ธ๋ก๊ทธ ๋ชจ๋์ ์ฐพ์ ์ ์์ต๋๋ค."]
|
| 66 |
|
| 67 |
-
results =
|
| 68 |
|
| 69 |
# ์ ๋๋ ์ดํฐ์์ ๋ง์ง๋ง ๊ฒฐ๊ณผ ๊ฐ์ ธํ๊ธฐ
|
| 70 |
last_result = None
|
|
@@ -77,18 +75,11 @@ def process_youtube_url(url, style):
|
|
| 77 |
def process_youtube_url_v1_2(url, style):
|
| 78 |
"""์ํ๊ฑด๊ฐ ๋ธ๋ก๊ทธ API ์๋ํฌ์ธํธ - ๊ธฐ์กด ํ์ ์ ์ง"""
|
| 79 |
# health_blog_module์์ process_youtube_url ํจ์ ํธ์ถ
|
| 80 |
-
|
| 81 |
-
if not
|
| 82 |
-
# ํจ์๋ช
์ด ์ถฉ๋ํ๋ฏ๋ก ๋ค๋ฅธ ๋ฐฉ๋ฒ์ผ๋ก ์ฐพ๊ธฐ
|
| 83 |
-
for name, obj in globals().items():
|
| 84 |
-
if callable(obj) and name.startswith('process_youtube_url') and 'health' in name.lower():
|
| 85 |
-
process_youtube_url_func = obj
|
| 86 |
-
break
|
| 87 |
-
|
| 88 |
-
if not process_youtube_url_func:
|
| 89 |
return ["", "์ํ๊ฑด๊ฐ ๋ธ๋ก๊ทธ ๋ชจ๋์ ์ฐพ์ ์ ์์ต๋๋ค."]
|
| 90 |
|
| 91 |
-
results =
|
| 92 |
|
| 93 |
# ์ ๋๋ ์ดํฐ์์ ๋ง์ง๋ง ๊ฒฐ๊ณผ ๊ฐ์ ธ์ค๊ธฐ
|
| 94 |
last_result = None
|
|
@@ -101,18 +92,11 @@ def process_youtube_url_v1_2(url, style):
|
|
| 101 |
def process_youtube_url_v2(url, style):
|
| 102 |
"""์ฌํ ๋ธ๋ก๊ทธ API ์๋ํฌ์ธํธ - ๊ธฐ์กด ํ์ ์ ์ง"""
|
| 103 |
# travel_blog_module์์ process_youtube_url ํจ์ ํธ์ถ
|
| 104 |
-
|
| 105 |
-
if not
|
| 106 |
-
# ํจ์๋ช
์ด ์ถฉ๋ํ๋ฏ๋ก ๋ค๋ฅธ ๋ฐฉ๋ฒ์ผ๋ก ์ฐพ๊ธฐ
|
| 107 |
-
for name, obj in globals().items():
|
| 108 |
-
if callable(obj) and name.startswith('process_youtube_url') and 'travel' in name.lower():
|
| 109 |
-
process_youtube_url_func = obj
|
| 110 |
-
break
|
| 111 |
-
|
| 112 |
-
if not process_youtube_url_func:
|
| 113 |
return ["", "์ฌํ ๋ธ๋ก๊ทธ ๋ชจ๋์ ์ฐพ์ ์ ์์ต๋๋ค."]
|
| 114 |
|
| 115 |
-
results =
|
| 116 |
|
| 117 |
# ์ ๋๋ ์ดํฐ์์ ๋ง์ง๋ง ๊ฒฐ๊ณผ ๊ฐ์ ธ์ค๊ธฐ
|
| 118 |
last_result = None
|
|
@@ -125,18 +109,11 @@ def process_youtube_url_v2(url, style):
|
|
| 125 |
def process_youtube_url_v3(url, style):
|
| 126 |
"""์ํํ๊ธฐ ๋ธ๋ก๊ทธ API ์๋ํฌ์ธํธ - ๊ธฐ์กด ํ์ ์ ์ง"""
|
| 127 |
# product_review_module์์ process_youtube_url ํจ์ ํธ์ถ
|
| 128 |
-
|
| 129 |
-
if not
|
| 130 |
-
# ํจ์๋ช
์ด ์ถฉ๋ํ๋ฏ๋ก ๋ค๋ฅธ ๋ฐฉ๋ฒ์ผ๋ก ์ฐพ๊ธฐ
|
| 131 |
-
for name, obj in globals().items():
|
| 132 |
-
if callable(obj) and name.startswith('process_youtube_url') and 'product' in name.lower():
|
| 133 |
-
process_youtube_url_func = obj
|
| 134 |
-
break
|
| 135 |
-
|
| 136 |
-
if not process_youtube_url_func:
|
| 137 |
return ["", "์ํํ๊ธฐ ๋ธ๋ก๊ทธ ๋ชจ๋์ ์ฐพ์ ์ ์์ต๋๋ค."]
|
| 138 |
|
| 139 |
-
results =
|
| 140 |
|
| 141 |
# ์ ๋๋ ์ดํฐ์์ ๋ง์ง๋ง ๊ฒฐ๊ณผ ๊ฐ์ ธ์ค๊ธฐ
|
| 142 |
last_result = None
|
|
|
|
| 12 |
cleaned_code = youtube_transcript_code.replace("from youtube_transcript_module import", "# from youtube_transcript_module import")
|
| 13 |
exec(cleaned_code, globals())
|
| 14 |
|
| 15 |
+
# 2๋จ๊ณ: analyze_module ์ฝ๋ ๋ก๋ (ํจ์๋ช
์ถฉ๋ ๋ฐฉ์ง)
|
| 16 |
analyze_module_code = os.environ.get("ANALYZE_MODULE_CODE", "")
|
| 17 |
if analyze_module_code:
|
| 18 |
+
# import ๋ฌธ ์์ ๋ฐ ํจ์๋ช
๋ณ๊ฒฝ
|
| 19 |
cleaned_code = analyze_module_code.replace("from youtube_transcript_module import YouTubeTranscriptClient", "# from youtube_transcript_module import YouTubeTranscriptClient")
|
| 20 |
+
cleaned_code = cleaned_code.replace("def get_youtube_script(", "def get_youtube_script_analyze(")
|
| 21 |
+
cleaned_code = cleaned_code.replace("get_youtube_script(url)", "get_youtube_script_analyze(url)")
|
| 22 |
exec(cleaned_code, globals())
|
| 23 |
|
| 24 |
+
# 3๋จ๊ณ: ๋๋จธ์ง blog ๋ชจ๋๋ค ๋ก๋ (๊ฐ๊ฐ ๊ณ ์ ํ ํจ์๋ช
์ฌ์ฉ)
|
| 25 |
+
module_configs = [
|
| 26 |
+
("GENERAL_BLOG_MODULE_CODE", "general", "general_process_youtube_url"),
|
| 27 |
+
("HEALTH_BLOG_MODULE_CODE", "health", "health_process_youtube_url"),
|
| 28 |
+
("TRAVEL_BLOG_MODULE_CODE", "travel", "travel_process_youtube_url"),
|
| 29 |
+
("PRODUCT_REVIEW_MODULE_CODE", "product", "product_process_youtube_url")
|
| 30 |
]
|
| 31 |
|
| 32 |
+
for env_key, prefix, func_name in module_configs:
|
| 33 |
module_code = os.environ.get(env_key, "")
|
| 34 |
if module_code:
|
| 35 |
+
# import ๋ฌธ ์ ๋ฆฌ ๋ฐ ํจ์๋ช
๋ณ๊ฒฝ์ผ๋ก ์ถฉ๋ ๋ฐฉ์ง
|
| 36 |
+
cleaned_code = module_code.replace("from youtube_transcript_module import YouTubeTranscriptClient", "# from youtube_transcript_module import YouTubeTranscriptClient")
|
| 37 |
+
cleaned_code = cleaned_code.replace("def get_youtube_script(", f"def get_youtube_script_{prefix}(")
|
| 38 |
+
cleaned_code = cleaned_code.replace("get_youtube_script(url)", f"get_youtube_script_{prefix}(url)")
|
| 39 |
+
cleaned_code = cleaned_code.replace("def process_youtube_url(", f"def {func_name}(")
|
| 40 |
exec(cleaned_code, globals())
|
| 41 |
|
| 42 |
# ์จ๊ฒจ์ง ๋ชจ๋๋ค ๋ก๋
|
|
|
|
| 58 |
def process_youtube_url(url, style):
|
| 59 |
"""์ผ๋ฐ ๋ธ๋ก๊ทธ API ์๋ํฌ์ธํธ - ๊ธฐ์กด ํ์ ์ ์ง"""
|
| 60 |
# general_blog_module์์ process_youtube_url ํจ์ ํธ์ถ
|
| 61 |
+
process_func = globals().get('general_process_youtube_url')
|
| 62 |
+
if not process_func:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
return ["", "์ผ๋ฐ ๋ธ๋ก๊ทธ ๋ชจ๋์ ์ฐพ์ ์ ์์ต๋๋ค."]
|
| 64 |
|
| 65 |
+
results = process_func(url, style)
|
| 66 |
|
| 67 |
# ์ ๋๋ ์ดํฐ์์ ๋ง์ง๋ง ๊ฒฐ๊ณผ ๊ฐ์ ธํ๊ธฐ
|
| 68 |
last_result = None
|
|
|
|
| 75 |
def process_youtube_url_v1_2(url, style):
|
| 76 |
"""์ํ๊ฑด๊ฐ ๋ธ๋ก๊ทธ API ์๋ํฌ์ธํธ - ๊ธฐ์กด ํ์ ์ ์ง"""
|
| 77 |
# health_blog_module์์ process_youtube_url ํจ์ ํธ์ถ
|
| 78 |
+
process_func = globals().get('health_process_youtube_url')
|
| 79 |
+
if not process_func:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
return ["", "์ํ๊ฑด๊ฐ ๋ธ๋ก๊ทธ ๋ชจ๋์ ์ฐพ์ ์ ์์ต๋๋ค."]
|
| 81 |
|
| 82 |
+
results = process_func(url, style)
|
| 83 |
|
| 84 |
# ์ ๋๋ ์ดํฐ์์ ๋ง์ง๋ง ๊ฒฐ๊ณผ ๊ฐ์ ธ์ค๊ธฐ
|
| 85 |
last_result = None
|
|
|
|
| 92 |
def process_youtube_url_v2(url, style):
|
| 93 |
"""์ฌํ ๋ธ๋ก๊ทธ API ์๋ํฌ์ธํธ - ๊ธฐ์กด ํ์ ์ ์ง"""
|
| 94 |
# travel_blog_module์์ process_youtube_url ํจ์ ํธ์ถ
|
| 95 |
+
process_func = globals().get('travel_process_youtube_url')
|
| 96 |
+
if not process_func:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
return ["", "์ฌํ ๋ธ๋ก๊ทธ ๋ชจ๋์ ์ฐพ์ ์ ์์ต๋๋ค."]
|
| 98 |
|
| 99 |
+
results = process_func(url, style)
|
| 100 |
|
| 101 |
# ์ ๋๋ ์ดํฐ์์ ๋ง์ง๋ง ๊ฒฐ๊ณผ ๊ฐ์ ธ์ค๊ธฐ
|
| 102 |
last_result = None
|
|
|
|
| 109 |
def process_youtube_url_v3(url, style):
|
| 110 |
"""์ํํ๊ธฐ ๋ธ๋ก๊ทธ API ์๋ํฌ์ธํธ - ๊ธฐ์กด ํ์ ์ ์ง"""
|
| 111 |
# product_review_module์์ process_youtube_url ํจ์ ํธ์ถ
|
| 112 |
+
process_func = globals().get('product_process_youtube_url')
|
| 113 |
+
if not process_func:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
return ["", "์ํํ๊ธฐ ๋ธ๋ก๊ทธ ๋ชจ๋์ ์ฐพ์ ์ ์์ต๋๋ค."]
|
| 115 |
|
| 116 |
+
results = process_func(url, style)
|
| 117 |
|
| 118 |
# ์ ๋๋ ์ดํฐ์์ ๋ง์ง๋ง ๊ฒฐ๊ณผ ๊ฐ์ ธ์ค๊ธฐ
|
| 119 |
last_result = None
|