fantaxy commited on
Commit
1d000f2
ยท
verified ยท
1 Parent(s): 6e10955

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -13
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": converted_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("๋ธ”๋กœ๊ฑฐ์— ์ „์†ก ์ค‘ ์˜ˆ์ƒ์น˜ ๋ชปํ•œ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: %s", str(e))
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
- # Pexels API๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ด๋ฏธ์ง€ URL ๊ฐ€์ ธ์˜ค๊ธฐ
693
- image_url = get_image_url(topic)
694
-
695
  if image_url:
696
- # ์ด๋ฏธ์ง€ URL์„ HTML <img> ํƒœ๊ทธ๋กœ ๋ธ”๋กœ๊ทธ ๋‚ด์šฉ ์ƒ๋‹จ์— ์ถ”๊ฐ€
697
- blog_content = f'<img src="{image_url}">\n\n{blog_content}'
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