Jeffgold commited on
Commit
0c96b87
·
1 Parent(s): 66a5f0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -135,6 +135,20 @@ def convert_video(video_file, quality, aspect_ratio, video_url, api_key, upload)
135
  return [master_playlist_copy_path] + output_copy_paths
136
 
137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  def main():
139
  video_file = gr.inputs.File(label="Video File")
140
  quality = gr.inputs.Dropdown(
@@ -151,7 +165,8 @@ def main():
151
  gr.Interface(
152
  convert_video,
153
  inputs=[video_file, quality, aspect_ratio, video_url, api_key, upload],
154
- outputs=gr.outputs.File(label="Download File"),
 
155
  allow_flagging=False,
156
  live=False,
157
  ).launch()
 
135
  return [master_playlist_copy_path] + output_copy_paths
136
 
137
 
138
+ def process_output(output):
139
+ """Process output and display it appropriately."""
140
+ if isinstance(output, str):
141
+ # If output is a string, assume it's an error message and display it as text.
142
+ return gr.outputs.Textbox()(output)
143
+ elif isinstance(output, Path):
144
+ # If output is a Path, assume it's an error file and provide it as a downloadable file.
145
+ return gr.outputs.File()(str(output))
146
+ elif isinstance(output, list):
147
+ # If output is a list, assume it's a list of Paths or URLs and display it as a markdown list.
148
+ return gr.outputs.Markdown()("\n".join(f"- {o}" for o in output))
149
+ else:
150
+ raise TypeError("Unexpected output type")
151
+
152
  def main():
153
  video_file = gr.inputs.File(label="Video File")
154
  quality = gr.inputs.Dropdown(
 
165
  gr.Interface(
166
  convert_video,
167
  inputs=[video_file, quality, aspect_ratio, video_url, api_key, upload],
168
+ outputs=gr.outputs.Any(),
169
+ output_processor=process_output,
170
  allow_flagging=False,
171
  live=False,
172
  ).launch()