Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -50,20 +50,26 @@ class CustomTheme(Base):
|
|
50 |
custom_theme = CustomTheme()
|
51 |
|
52 |
def save_uploaded_file(uploaded_file):
|
53 |
-
""
|
54 |
if uploaded_file is None:
|
55 |
-
return None #
|
56 |
|
57 |
-
#
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
67 |
|
68 |
def display_results(video_url, video_file, description):
|
69 |
"""Process video from URL or file upload and return the results."""
|
|
|
50 |
custom_theme = CustomTheme()
|
51 |
|
52 |
def save_uploaded_file(uploaded_file):
|
53 |
+
print(f"Received object type: {type(uploaded_file)}") # Debug: Check the object type
|
54 |
if uploaded_file is None:
|
55 |
+
return None # Handle cases where no file was uploaded
|
56 |
|
57 |
+
# Check if the received object has the expected 'file' and 'name' attributes
|
58 |
+
if hasattr(uploaded_file, 'name') and hasattr(uploaded_file, 'file'):
|
59 |
+
print(f"File name: {uploaded_file.name}") # Debug: Print file name
|
60 |
+
upload_dir = "uploaded_videos"
|
61 |
+
os.makedirs(upload_dir, exist_ok=True)
|
62 |
+
file_path = os.path.join(upload_dir, uploaded_file.name)
|
63 |
|
64 |
+
with open(file_path, "wb") as f:
|
65 |
+
# Attempt to read from the file object if possible
|
66 |
+
file_content = uploaded_file.file.read()
|
67 |
+
f.write(file_content) # Save file content to disk
|
68 |
+
return file_path
|
69 |
+
else:
|
70 |
+
# If expected attributes are not found, print available attributes
|
71 |
+
print(f"Available attributes: {dir(uploaded_file)}") # Debug: List attributes
|
72 |
+
return None
|
73 |
|
74 |
def display_results(video_url, video_file, description):
|
75 |
"""Process video from URL or file upload and return the results."""
|