Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,8 @@ from datasets import load_dataset
|
|
| 3 |
import subprocess
|
| 4 |
import os
|
| 5 |
import tempfile
|
|
|
|
|
|
|
| 6 |
|
| 7 |
def convert_ts_to_mp4(dataset_name, file_name, hf_token):
|
| 8 |
"""
|
|
@@ -38,6 +40,7 @@ def convert_ts_to_mp4(dataset_name, file_name, hf_token):
|
|
| 38 |
for example in dataset[split]:
|
| 39 |
if "file" in example and os.path.basename(example["file"]) == file_name:
|
| 40 |
file_url = example["file"]
|
|
|
|
| 41 |
break
|
| 42 |
elif isinstance(example, dict): # Check for nested file paths.
|
| 43 |
for key, value in example.items():
|
|
@@ -56,7 +59,6 @@ def convert_ts_to_mp4(dataset_name, file_name, hf_token):
|
|
| 56 |
# downloading, especially with large files, consider
|
| 57 |
# using 'requests' with streaming.
|
| 58 |
try:
|
| 59 |
-
import urllib.request
|
| 60 |
urllib.request.urlretrieve(file_url, ts_file.name)
|
| 61 |
except Exception as e:
|
| 62 |
return f"Error downloading file: {e}"
|
|
|
|
| 3 |
import subprocess
|
| 4 |
import os
|
| 5 |
import tempfile
|
| 6 |
+
import urllib.request
|
| 7 |
+
from pathlib import Path
|
| 8 |
|
| 9 |
def convert_ts_to_mp4(dataset_name, file_name, hf_token):
|
| 10 |
"""
|
|
|
|
| 40 |
for example in dataset[split]:
|
| 41 |
if "file" in example and os.path.basename(example["file"]) == file_name:
|
| 42 |
file_url = example["file"]
|
| 43 |
+
print(file_url)
|
| 44 |
break
|
| 45 |
elif isinstance(example, dict): # Check for nested file paths.
|
| 46 |
for key, value in example.items():
|
|
|
|
| 59 |
# downloading, especially with large files, consider
|
| 60 |
# using 'requests' with streaming.
|
| 61 |
try:
|
|
|
|
| 62 |
urllib.request.urlretrieve(file_url, ts_file.name)
|
| 63 |
except Exception as e:
|
| 64 |
return f"Error downloading file: {e}"
|