Jeffgold commited on
Commit
b6be762
·
1 Parent(s): 4ad7b27

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -52,8 +52,12 @@ def upload_to_web3_storage(api_key, path):
52
  data=f,
53
  )
54
  response.raise_for_status() # Raises an exception if the request failed
55
- cid = response.json()["value"]["cid"]
56
- return f"https://dweb.link/ipfs/{cid}"
 
 
 
 
57
 
58
  def convert_video(video_file, quality, aspect_ratio, video_url, api_key, upload):
59
  """Converts a video to HLS format, adjusting the quality and aspect ratio as necessary."""
@@ -110,8 +114,9 @@ def main():
110
  gr.Interface(
111
  convert_video,
112
  inputs=[video_file, quality, aspect_ratio, video_url, api_key, upload],
113
- outputs='text'
114
- ).launch()
 
115
 
116
 
117
 
 
52
  data=f,
53
  )
54
  response.raise_for_status() # Raises an exception if the request failed
55
+ try:
56
+ cid = response.json()["value"]["cid"]
57
+ return f"https://dweb.link/ipfs/{cid}"
58
+ except KeyError:
59
+ logging.exception("An error occurred while uploading to web3.storage.")
60
+ return f"An error occurred while uploading to web3.storage: {response.json()}"
61
 
62
  def convert_video(video_file, quality, aspect_ratio, video_url, api_key, upload):
63
  """Converts a video to HLS format, adjusting the quality and aspect ratio as necessary."""
 
114
  gr.Interface(
115
  convert_video,
116
  inputs=[video_file, quality, aspect_ratio, video_url, api_key, upload],
117
+ outputs=gr.outputs.Download(label="Download File"),
118
+ live=True,
119
+ ).launch())
120
 
121
 
122