Spaces:
Running
Running
Update watcher.py
Browse files- watcher.py +12 -7
watcher.py
CHANGED
|
@@ -307,11 +307,11 @@ def merge_video_on_server(video_url, audio_url, video_id, quality, video_title,
|
|
| 307 |
monitor_url = result["data"]["result"]["monitor"]["http"]
|
| 308 |
|
| 309 |
# 完了するまでポーリング
|
| 310 |
-
max_attempts =
|
| 311 |
attempt = 0
|
| 312 |
|
| 313 |
while attempt < max_attempts:
|
| 314 |
-
time.sleep(
|
| 315 |
|
| 316 |
status_res = requests.get(monitor_url, timeout=30)
|
| 317 |
status_res.raise_for_status()
|
|
@@ -359,15 +359,20 @@ def upload_file_to_channel(file_url):
|
|
| 359 |
|
| 360 |
upload_url = "https://media.channel.io/cht/v1/pri-file/200605/groups/519217/message/send_yt_video_file.mp4"
|
| 361 |
|
| 362 |
-
files = {
|
| 363 |
-
"file": ("video.mp4", file_res.content, "video/mp4")
|
| 364 |
-
}
|
| 365 |
-
|
| 366 |
headers = {
|
| 367 |
"x-account": X_ACCOUNT,
|
|
|
|
|
|
|
| 368 |
}
|
| 369 |
|
| 370 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 371 |
res.raise_for_status()
|
| 372 |
|
| 373 |
return res.json() # ←これを messages POST の body.files に入れる
|
|
|
|
| 307 |
monitor_url = result["data"]["result"]["monitor"]["http"]
|
| 308 |
|
| 309 |
# 完了するまでポーリング
|
| 310 |
+
max_attempts = 5 # 最大60回試行(30秒間隔で約30分)
|
| 311 |
attempt = 0
|
| 312 |
|
| 313 |
while attempt < max_attempts:
|
| 314 |
+
time.sleep(20) # 30秒間隔でチェック
|
| 315 |
|
| 316 |
status_res = requests.get(monitor_url, timeout=30)
|
| 317 |
status_res.raise_for_status()
|
|
|
|
| 359 |
|
| 360 |
upload_url = "https://media.channel.io/cht/v1/pri-file/200605/groups/519217/message/send_yt_video_file.mp4"
|
| 361 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 362 |
headers = {
|
| 363 |
"x-account": X_ACCOUNT,
|
| 364 |
+
"Content-Type": "video/mp4",
|
| 365 |
+
"Content-Length": str(len(file_res.content)),
|
| 366 |
}
|
| 367 |
|
| 368 |
+
|
| 369 |
+
res = requests.post(
|
| 370 |
+
upload_url,
|
| 371 |
+
headers=headers,
|
| 372 |
+
data=file_res.content,
|
| 373 |
+
timeout=60
|
| 374 |
+
)
|
| 375 |
+
|
| 376 |
res.raise_for_status()
|
| 377 |
|
| 378 |
return res.json() # ←これを messages POST の body.files に入れる
|