Spaces:
Sleeping
Sleeping
Update watcher.py
Browse files- watcher.py +25 -3
watcher.py
CHANGED
|
@@ -109,14 +109,36 @@ def select_best_video_and_audio(items):
|
|
| 109 |
|
| 110 |
video_items.sort(key=lambda x: x[0], reverse=True)
|
| 111 |
return video_items[0][1], audio_item
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
-
# ===== ファイルダウンロード =====
|
| 114 |
def download_file(url, path):
|
| 115 |
-
with requests.get(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
r.raise_for_status()
|
| 117 |
with open(path, "wb") as f:
|
| 118 |
for chunk in r.iter_content(chunk_size=8192):
|
| 119 |
-
|
|
|
|
| 120 |
|
| 121 |
# ===== ffmpeg 結合 =====
|
| 122 |
def merge_video_audio(video_path, audio_path, output_path):
|
|
|
|
| 109 |
|
| 110 |
video_items.sort(key=lambda x: x[0], reverse=True)
|
| 111 |
return video_items[0][1], audio_item
|
| 112 |
+
HEADERS = {
|
| 113 |
+
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
| 114 |
+
"accept-encoding": "gzip, deflate, br, zstd",
|
| 115 |
+
"accept-language": "ja,en-US;q=0.9,en;q=0.8",
|
| 116 |
+
"cache-control": "max-age=0",
|
| 117 |
+
"if-modified-since": "Thu, 10 Apr 2025 12:43:39 GMT",
|
| 118 |
+
"range": "bytes=0-194096",
|
| 119 |
+
"sec-ch-ua": "\"Google Chrome\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\"",
|
| 120 |
+
"sec-ch-ua-mobile": "?0",
|
| 121 |
+
"sec-ch-ua-platform": "\"Windows\"",
|
| 122 |
+
"sec-fetch-dest": "document",
|
| 123 |
+
"sec-fetch-mode": "navigate",
|
| 124 |
+
"sec-fetch-site": "cross-site",
|
| 125 |
+
"sec-fetch-user": "?1",
|
| 126 |
+
"upgrade-insecure-requests": "1",
|
| 127 |
+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
| 128 |
+
}
|
| 129 |
|
|
|
|
| 130 |
def download_file(url, path):
|
| 131 |
+
with requests.get(
|
| 132 |
+
url,
|
| 133 |
+
headers=HEADERS,
|
| 134 |
+
stream=True,
|
| 135 |
+
timeout=60,
|
| 136 |
+
) as r:
|
| 137 |
r.raise_for_status()
|
| 138 |
with open(path, "wb") as f:
|
| 139 |
for chunk in r.iter_content(chunk_size=8192):
|
| 140 |
+
if chunk:
|
| 141 |
+
f.write(chunk)
|
| 142 |
|
| 143 |
# ===== ffmpeg 結合 =====
|
| 144 |
def merge_video_audio(video_path, audio_path, output_path):
|