Spaces:
Building
Building
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})
|