Update app.py
Browse files
app.py
CHANGED
|
@@ -343,7 +343,11 @@ class App:
|
|
| 343 |
with gr.Column(scale=1):
|
| 344 |
tb_info = gr.Textbox(label="Output info", interactive=False, show_copy_button=True)
|
| 345 |
files_subtitles = gr.Files(label="Output data", interactive=False, file_count="multiple")
|
| 346 |
-
# btn_openfolder = gr.Button('📂', scale=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 347 |
|
| 348 |
params = [input_file_audio, input_file_video, input_file_multi, input_multi, tb_input_folder, dd_file_format, cb_timestamp_file, cb_translate_output, dd_translate_model, dd_target_lang, cb_timestamp_preview]
|
| 349 |
|
|
@@ -399,9 +403,18 @@ class App:
|
|
| 399 |
return gr.update(visible=False), gr.update(visible=False), gr.update(visible=True)
|
| 400 |
|
| 401 |
@staticmethod
|
| 402 |
-
def
|
| 403 |
-
|
| 404 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 405 |
|
| 406 |
# Create the parser for command-line arguments
|
| 407 |
parser = argparse.ArgumentParser()
|
|
|
|
| 343 |
with gr.Column(scale=1):
|
| 344 |
tb_info = gr.Textbox(label="Output info", interactive=False, show_copy_button=True)
|
| 345 |
files_subtitles = gr.Files(label="Output data", interactive=False, file_count="multiple")
|
| 346 |
+
# btn_openfolder = gr.Button('📂', scale=1)
|
| 347 |
+
|
| 348 |
+
btn_download = gr.Button("Download results")
|
| 349 |
+
html_script = gr.HTML()
|
| 350 |
+
btn_download.click(fn=self.trigger_download_script, inputs=[files_subtitles], outputs=[html_script])
|
| 351 |
|
| 352 |
params = [input_file_audio, input_file_video, input_file_multi, input_multi, tb_input_folder, dd_file_format, cb_timestamp_file, cb_translate_output, dd_translate_model, dd_target_lang, cb_timestamp_preview]
|
| 353 |
|
|
|
|
| 403 |
return gr.update(visible=False), gr.update(visible=False), gr.update(visible=True)
|
| 404 |
|
| 405 |
@staticmethod
|
| 406 |
+
def generate_download_script(files):
|
| 407 |
+
links = ""
|
| 408 |
+
for file in files:
|
| 409 |
+
links += f"""
|
| 410 |
+
var link = document.createElement('a');
|
| 411 |
+
link.href = '/file={file.name}';
|
| 412 |
+
link.download = '{file.name.split('/')[-1]}';
|
| 413 |
+
document.body.appendChild(link);
|
| 414 |
+
link.click();
|
| 415 |
+
document.body.removeChild(link);
|
| 416 |
+
"""
|
| 417 |
+
return f"<script>{links}</script>"
|
| 418 |
|
| 419 |
# Create the parser for command-line arguments
|
| 420 |
parser = argparse.ArgumentParser()
|