Spaces:
Paused
Paused
Update app.py
Browse files
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 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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=
|
| 114 |
-
|
|
|
|
| 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 |
|