seawolf2357 commited on
Commit
b66c71d
ยท
verified ยท
1 Parent(s): 87b9b05

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -61,9 +61,20 @@ def is_recent_news(time_str):
61
  elif unit in ['day', 'days']:
62
  return value <= 1
63
  else:
64
- return False
 
 
 
 
 
65
  except ValueError:
66
- return False
 
 
 
 
 
 
67
 
68
  def format_results(results):
69
  all_results = "## ๋ชจ๋“  ๋‰ด์Šค ๊ฒฐ๊ณผ\n\n"
@@ -91,7 +102,7 @@ def format_results(results):
91
  time_str = result.get("time", "์•Œ ์ˆ˜ ์—†๋Š” ์‹œ๊ฐ„")
92
 
93
  is_recent = is_recent_news(time_str)
94
- debug_info += f"๊ธฐ์‚ฌ: {title}\n์‹œ๊ฐ„: {time_str}, ์ตœ๊ทผ ์—ฌ๋ถ€: {is_recent}\n\n"
95
 
96
  article_info = f"""
97
  ### [{title}]({url})
 
61
  elif unit in ['day', 'days']:
62
  return value <= 1
63
  else:
64
+ # 'ago'๊ฐ€ ํฌํ•จ๋œ ๊ฒฝ์šฐ (์˜ˆ: '2 hours ago')
65
+ if 'ago' in time_str.lower():
66
+ if unit in ['minute', 'minutes', 'hour', 'hours']:
67
+ return True
68
+ elif unit in ['day', 'days']:
69
+ return value <= 1
70
  except ValueError:
71
+ # ๋‚ ์งœ ํ˜•์‹์ธ ๊ฒฝ์šฐ (์˜ˆ: 'Sep 22, 2024')
72
+ try:
73
+ date = datetime.strptime(time_str, '%b %d, %Y')
74
+ return (datetime.now() - date).days <= 1
75
+ except ValueError:
76
+ pass
77
+ return False
78
 
79
  def format_results(results):
80
  all_results = "## ๋ชจ๋“  ๋‰ด์Šค ๊ฒฐ๊ณผ\n\n"
 
102
  time_str = result.get("time", "์•Œ ์ˆ˜ ์—†๋Š” ์‹œ๊ฐ„")
103
 
104
  is_recent = is_recent_news(time_str)
105
+ debug_info += f"๊ธฐ์‚ฌ: {title}\n์‹œ๊ฐ„: {time_str}, ์ตœ๊ทผ ์—ฌ๋ถ€: {is_recent}\n์›๋ณธ ์‹œ๊ฐ„ ๋ฌธ์ž์—ด: {time_str}\n\n"
106
 
107
  article_info = f"""
108
  ### [{title}]({url})