ignore
Browse files- download_audio.py +14 -10
download_audio.py
CHANGED
@@ -3,6 +3,7 @@ import tarfile
|
|
3 |
import zipfile
|
4 |
import gzip
|
5 |
import traceback
|
|
|
6 |
from os.path import join as p_join
|
7 |
from tqdm import tqdm
|
8 |
from multiprocessing import Pool
|
@@ -27,17 +28,20 @@ def wget(url: str, cache_dir: str, filename: Optional[str] = None):
|
|
27 |
os.makedirs(cache_dir, exist_ok=True)
|
28 |
filename = os.path.basename(url) if not filename else filename
|
29 |
output_file = p_join(cache_dir, filename)
|
30 |
-
|
31 |
-
|
32 |
-
except (ConnectionError, HTTPError):
|
33 |
-
traceback.print_exc()
|
34 |
-
if os.path.exists(output_file):
|
35 |
-
os.remove(output_file)
|
36 |
return False
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
if output_file.endswith('.tar.gz') or output_file.endswith('.tgz') or output_file.endswith('.tar'):
|
43 |
if output_file.endswith('.tar'):
|
|
|
3 |
import zipfile
|
4 |
import gzip
|
5 |
import traceback
|
6 |
+
import subprocess
|
7 |
from os.path import join as p_join
|
8 |
from tqdm import tqdm
|
9 |
from multiprocessing import Pool
|
|
|
28 |
os.makedirs(cache_dir, exist_ok=True)
|
29 |
filename = os.path.basename(url) if not filename else filename
|
30 |
output_file = p_join(cache_dir, filename)
|
31 |
+
subprocess.run(["wget", url, "-O", output_file])
|
32 |
+
if not os.path.exists(output_file):
|
|
|
|
|
|
|
|
|
33 |
return False
|
34 |
+
# try:
|
35 |
+
# urllib.request.urlretrieve(url, output_file)
|
36 |
+
# except (ConnectionError, HTTPError):
|
37 |
+
# traceback.print_exc()
|
38 |
+
# if os.path.exists(output_file):
|
39 |
+
# os.remove(output_file)
|
40 |
+
# return False
|
41 |
+
# except KeyboardInterrupt:
|
42 |
+
# if os.path.exists(output_file):
|
43 |
+
# os.remove(output_file)
|
44 |
+
# exit()
|
45 |
|
46 |
if output_file.endswith('.tar.gz') or output_file.endswith('.tgz') or output_file.endswith('.tar'):
|
47 |
if output_file.endswith('.tar'):
|