seawolf2357
commited on
Commit
β’
b183030
1
Parent(s):
da8c445
Update app.py
Browse files
app.py
CHANGED
@@ -174,21 +174,32 @@ async def generate_replies(comments, transcript):
|
|
174 |
logging.debug(f'μμ±λ λ΅κΈ: {replies}')
|
175 |
return replies
|
176 |
|
|
|
|
|
177 |
async def send_webhook_data(session, chunk_data, chunk_number):
|
178 |
-
|
|
|
|
|
|
|
179 |
try:
|
180 |
-
async with session.post(WEBHOOK_URL, json=chunk_data) as
|
181 |
-
if
|
182 |
-
logging.info(f"μΉν
μΌλ‘ λ°μ΄ν° μ μ‘ μ±κ³΅: {chunk_number}
|
183 |
return True # μ±κ³΅ μ μ’
λ£
|
184 |
else:
|
185 |
-
logging.error(f"μΉν
μΌλ‘ λ°μ΄ν° μ μ‘ μ€ν¨: {
|
186 |
except aiohttp.ClientError as e:
|
187 |
-
logging.error(f"μΉν
μ μ‘ μ€ μ€λ₯ λ°μ: {e}, {chunk_number}
|
188 |
-
|
|
|
189 |
|
|
|
|
|
|
|
190 |
return False # μ¬μλ νμ μ΄κ³Ό μ μ€ν¨λ‘ κ°μ£Ό
|
191 |
|
|
|
|
|
192 |
async def create_thread_and_send_replies(message, video_id, comments, replies, session):
|
193 |
thread = await message.channel.create_thread(name=f"{message.author.name}μ λκΈ λ΅κΈ", message=message)
|
194 |
webhook_data = {"video_id": video_id, "replies": []}
|
|
|
174 |
logging.debug(f'μμ±λ λ΅κΈ: {replies}')
|
175 |
return replies
|
176 |
|
177 |
+
|
178 |
+
|
179 |
async def send_webhook_data(session, chunk_data, chunk_number):
|
180 |
+
max_retries = 3 # μ΅λ μ¬μλ νμ
|
181 |
+
retry_delay = 1 # μ¬μλ μ¬μ΄μ λκΈ° μκ° (μ΄)
|
182 |
+
|
183 |
+
for attempt in range(max_retries):
|
184 |
try:
|
185 |
+
async with session.post(WEBHOOK_URL, json=chunk_data) as response:
|
186 |
+
if response.status == 200:
|
187 |
+
logging.info(f"μΉν
μΌλ‘ λ°μ΄ν° μ μ‘ μ±κ³΅: μ²ν¬ {chunk_number}, μλ {attempt+1}")
|
188 |
return True # μ±κ³΅ μ μ’
λ£
|
189 |
else:
|
190 |
+
logging.error(f"μΉν
μΌλ‘ λ°μ΄ν° μ μ‘ μ€ν¨: HTTP {response.status}, μ²ν¬ {chunk_number}, μλ {attempt+1}")
|
191 |
except aiohttp.ClientError as e:
|
192 |
+
logging.error(f"μΉν
μ μ‘ μ€ HTTP μ€λ₯ λ°μ: {e}, μ²ν¬ {chunk_number}, μλ {attempt+1}")
|
193 |
+
except Exception as e:
|
194 |
+
logging.error(f"μΉν
μ μ‘ μ€ μ μ μλ μ€λ₯ λ°μ: {e}, μ²ν¬ {chunk_number}, μλ {attempt+1}")
|
195 |
|
196 |
+
await asyncio.sleep(retry_delay) # μ¬μλ μ μ 1μ΄ λκΈ°
|
197 |
+
|
198 |
+
logging.error(f"μΉν
λ°μ΄ν° μ μ‘ μ€ν¨, λͺ¨λ μ¬μλ μμ§: μ²ν¬ {chunk_number}")
|
199 |
return False # μ¬μλ νμ μ΄κ³Ό μ μ€ν¨λ‘ κ°μ£Ό
|
200 |
|
201 |
+
|
202 |
+
|
203 |
async def create_thread_and_send_replies(message, video_id, comments, replies, session):
|
204 |
thread = await message.channel.create_thread(name=f"{message.author.name}μ λκΈ λ΅κΈ", message=message)
|
205 |
webhook_data = {"video_id": video_id, "replies": []}
|