Spaces:
Running
Running
admin
commited on
Commit
·
7741f33
1
Parent(s):
21e99f3
refine try
Browse files
app.py
CHANGED
@@ -11,15 +11,11 @@ def download_file(url, video_id, cache_dir="./__pycache__"):
|
|
11 |
|
12 |
os.makedirs(cache_dir)
|
13 |
local_file = f"{cache_dir}/{video_id}.mp4"
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
file.write(chunk)
|
20 |
-
|
21 |
-
except requests.exceptions.RequestException as e:
|
22 |
-
print(f"Failed to download: {e}")
|
23 |
|
24 |
return local_file
|
25 |
|
|
|
11 |
|
12 |
os.makedirs(cache_dir)
|
13 |
local_file = f"{cache_dir}/{video_id}.mp4"
|
14 |
+
response = requests.get(url, stream=True)
|
15 |
+
if response.status_code == 200:
|
16 |
+
with open(local_file, "wb") as file:
|
17 |
+
for chunk in response.iter_content(chunk_size=8192):
|
18 |
+
file.write(chunk)
|
|
|
|
|
|
|
|
|
19 |
|
20 |
return local_file
|
21 |
|