admin commited on
Commit
7741f33
·
1 Parent(s): 21e99f3

refine try

Browse files
Files changed (1) hide show
  1. app.py +5 -9
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
- try:
15
- response = requests.get(url, stream=True)
16
- if response.status_code == 200:
17
- with open(local_file, "wb") as file:
18
- for chunk in response.iter_content(chunk_size=8192):
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