Spaces:
Sleeping
Sleeping
Update webui/app.py
Browse files- webui/app.py +12 -4
webui/app.py
CHANGED
|
@@ -152,10 +152,18 @@ def run_viral_cutter(input_source, project_name, url, video_file, segments, vira
|
|
| 152 |
yield i18n("Error: No video file uploaded."), gr.update(value=i18n("Start Processing"), interactive=True), gr.update(visible=False), None
|
| 153 |
return
|
| 154 |
|
| 155 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 157 |
-
project_name_upload = f"
|
| 158 |
project_path = os.path.join(VIRALS_DIR, project_name_upload)
|
|
|
|
| 159 |
os.makedirs(project_path, exist_ok=True)
|
| 160 |
|
| 161 |
target_path = os.path.join(project_path, "input.mp4")
|
|
@@ -328,8 +336,8 @@ with gr.Blocks(title=i18n("ViralCutter WebUI"), theme=gr.themes.Default(primary_
|
|
| 328 |
with gr.Column(scale=1):
|
| 329 |
input_source = gr.Radio([(i18n("YouTube URL"), "YouTube URL"), (i18n("Existing Project"), "Existing Project"), (i18n("Upload Video"), "Upload Video")], label=i18n("Input Source"), value="Upload Video")
|
| 330 |
|
| 331 |
-
url_input = gr.Textbox(label=i18n("YouTube URL"), placeholder="https://www.youtube.com/watch?v=...", visible=
|
| 332 |
-
video_upload = gr.File(label=i18n("Upload Video"), file_count="single", file_types=["video"], visible=
|
| 333 |
|
| 334 |
with gr.Row():
|
| 335 |
video_quality_input = gr.Dropdown(choices=["best", "1080p", "720p", "480p"], label=i18n("Video Quality"), value="best")
|
|
|
|
| 152 |
yield i18n("Error: No video file uploaded."), gr.update(value=i18n("Start Processing"), interactive=True), gr.update(visible=False), None
|
| 153 |
return
|
| 154 |
|
| 155 |
+
# Determine project name from filename
|
| 156 |
+
original_filename = os.path.basename(video_file)
|
| 157 |
+
name_no_ext = os.path.splitext(original_filename)[0]
|
| 158 |
+
# Sanitize: Allow alphanumeric, space, dash, underscore
|
| 159 |
+
safe_name = "".join([c for c in name_no_ext if c.isalnum() or c in " _-"]).strip()
|
| 160 |
+
if not safe_name: safe_name = "Untitled_Upload"
|
| 161 |
+
|
| 162 |
+
# Always append timestamp as requested
|
| 163 |
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 164 |
+
project_name_upload = f"{safe_name}_{timestamp}"
|
| 165 |
project_path = os.path.join(VIRALS_DIR, project_name_upload)
|
| 166 |
+
|
| 167 |
os.makedirs(project_path, exist_ok=True)
|
| 168 |
|
| 169 |
target_path = os.path.join(project_path, "input.mp4")
|
|
|
|
| 336 |
with gr.Column(scale=1):
|
| 337 |
input_source = gr.Radio([(i18n("YouTube URL"), "YouTube URL"), (i18n("Existing Project"), "Existing Project"), (i18n("Upload Video"), "Upload Video")], label=i18n("Input Source"), value="Upload Video")
|
| 338 |
|
| 339 |
+
url_input = gr.Textbox(label=i18n("YouTube URL"), placeholder="https://www.youtube.com/watch?v=...", visible=False)
|
| 340 |
+
video_upload = gr.File(label=i18n("Upload Video"), file_count="single", file_types=["video"], visible=True)
|
| 341 |
|
| 342 |
with gr.Row():
|
| 343 |
video_quality_input = gr.Dropdown(choices=["best", "1080p", "720p", "480p"], label=i18n("Video Quality"), value="best")
|