Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
65 |
except ValueError:
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
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})
|