Update app.py
Browse files
app.py
CHANGED
@@ -608,13 +608,10 @@ def send_to_blogger(blog_title, blog_content):
|
|
608 |
logger.error("WEBHOOK_URL์ด ์ค์ ๋์ง ์์์ต๋๋ค.")
|
609 |
return "WEBHOOK_URL์ด ์ค์ ๋์ง ์์ ํฌ์คํ
์ ์ ์กํ ์ ์์ต๋๋ค."
|
610 |
|
611 |
-
converted_content = convert_markdown_images(blog_content)
|
612 |
-
logger.debug("๋ณํ๋ ๋ด์ฉ: %s", converted_content)
|
613 |
-
|
614 |
payload = {
|
615 |
"blogger_id": BLOGGER_ID,
|
616 |
"title": blog_title,
|
617 |
-
"content":
|
618 |
}
|
619 |
|
620 |
try:
|
@@ -631,7 +628,7 @@ def send_to_blogger(blog_title, blog_content):
|
|
631 |
logger.error("๋ธ๋ก๊ฑฐ์ ์ ์ก ์ค ์ค๋ฅ ๋ฐ์: %s", str(e))
|
632 |
return f"๋คํธ์ํฌ ์ค๋ฅ ๋ฐ์: {str(e)}"
|
633 |
except Exception as e:
|
634 |
-
logger.error("
|
635 |
return f"์ค๋ฅ ๋ฐ์: {str(e)}"
|
636 |
|
637 |
def convert_markdown_images(content):
|
@@ -683,21 +680,20 @@ def process_all_titles(category, style, topic, num_titles):
|
|
683 |
results = []
|
684 |
for title in titles[:num_titles]:
|
685 |
try:
|
|
|
|
|
|
|
|
|
686 |
_, _, _, _, _, blog_content, _ = fetch_references_and_generate_all_steps(category, style, topic, title)
|
687 |
|
688 |
if blog_content.startswith("API ํธ์ถ ์คํจ"):
|
689 |
results.append(f"์ ๋ชฉ: {title}\n์์ฑ ์คํจ: {blog_content}\n\n")
|
690 |
continue
|
691 |
|
692 |
-
#
|
693 |
-
image_url = get_image_url(topic)
|
694 |
-
|
695 |
if image_url:
|
696 |
-
|
697 |
-
|
698 |
-
else:
|
699 |
-
logger.warning(f"์ ๋ชฉ '{title}'์ ๋ํ ์ด๋ฏธ์ง๋ฅผ ์ฐพ์ง ๋ชปํ์ต๋๋ค.")
|
700 |
-
|
701 |
# ํฌ์คํ
์ ์ก
|
702 |
send_result = send_to_blogger(title, blog_content)
|
703 |
|
|
|
608 |
logger.error("WEBHOOK_URL์ด ์ค์ ๋์ง ์์์ต๋๋ค.")
|
609 |
return "WEBHOOK_URL์ด ์ค์ ๋์ง ์์ ํฌ์คํ
์ ์ ์กํ ์ ์์ต๋๋ค."
|
610 |
|
|
|
|
|
|
|
611 |
payload = {
|
612 |
"blogger_id": BLOGGER_ID,
|
613 |
"title": blog_title,
|
614 |
+
"content": blog_content
|
615 |
}
|
616 |
|
617 |
try:
|
|
|
628 |
logger.error("๋ธ๋ก๊ฑฐ์ ์ ์ก ์ค ์ค๋ฅ ๋ฐ์: %s", str(e))
|
629 |
return f"๋คํธ์ํฌ ์ค๋ฅ ๋ฐ์: {str(e)}"
|
630 |
except Exception as e:
|
631 |
+
logger.error("๋ธ๋ก๊ทธ์ ์ ์ก ์ค ์์์น ๋ชปํ ์ค๋ฅ ๋ฐ์: %s", str(e))
|
632 |
return f"์ค๋ฅ ๋ฐ์: {str(e)}"
|
633 |
|
634 |
def convert_markdown_images(content):
|
|
|
680 |
results = []
|
681 |
for title in titles[:num_titles]:
|
682 |
try:
|
683 |
+
# ์ด๋ฏธ์ง URL ๊ฐ์ ธ์ค๊ธฐ
|
684 |
+
image_url = get_image_url(topic)
|
685 |
+
|
686 |
+
# ๋ธ๋ก๊ทธ ๋ด์ฉ ์์ฑ
|
687 |
_, _, _, _, _, blog_content, _ = fetch_references_and_generate_all_steps(category, style, topic, title)
|
688 |
|
689 |
if blog_content.startswith("API ํธ์ถ ์คํจ"):
|
690 |
results.append(f"์ ๋ชฉ: {title}\n์์ฑ ์คํจ: {blog_content}\n\n")
|
691 |
continue
|
692 |
|
693 |
+
# ์ด๋ฏธ์ง URL์ ๋ธ๋ก๊ทธ ๋ด์ฉ์ ์ถ๊ฐ
|
|
|
|
|
694 |
if image_url:
|
695 |
+
blog_content = f'<img src="{image_url}" alt="{topic}">\n\n{blog_content}'
|
696 |
+
|
|
|
|
|
|
|
697 |
# ํฌ์คํ
์ ์ก
|
698 |
send_result = send_to_blogger(title, blog_content)
|
699 |
|