Aadhithya commited on
Commit
fcde479
1 Parent(s): 1948f3c

Update roop/utilities.py

Browse files
Files changed (1) hide show
  1. roop/utilities.py +26 -0
roop/utilities.py CHANGED
@@ -132,5 +132,31 @@ def is_video(video_path: str) -> bool:
132
  return bool(mimetype and mimetype.startswith('video/'))
133
  return False
134
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  def resolve_relative_path(path: str) -> str:
136
  return os.path.abspath(os.path.join(os.path.dirname(__file__), path))
 
132
  return bool(mimetype and mimetype.startswith('video/'))
133
  return False
134
 
135
+
136
+
137
+ def conditional_download(download_directory_path: str, urls: List[str]) -> None:
138
+ if not os.path.exists(download_directory_path):
139
+ os.makedirs(download_directory_path)
140
+ for url in urls:
141
+ download_file_path = os.path.join(download_directory_path, os.path.basename(url))
142
+ if not os.path.exists(download_file_path):
143
+ response = requests.get(url, stream=True)
144
+ total = int(response.headers.get('Content-Length', 0))
145
+ with open(download_file_path, 'wb') as file, tqdm(
146
+ total=total,
147
+ unit='B',
148
+ unit_scale=True,
149
+ unit_divisor=1024,
150
+ desc='Downloading'
151
+ ) as progress:
152
+ for data in response.iter_content(chunk_size=1024):
153
+ file.write(data)
154
+ progress.update(len(data))
155
+
156
+
157
+
158
+
159
+
160
+
161
  def resolve_relative_path(path: str) -> str:
162
  return os.path.abspath(os.path.join(os.path.dirname(__file__), path))