Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
# import yt_dlp as youtube_dl
|
| 3 |
+
import tempfile
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
YT_LENGTH_LIMIT_S = 3600
|
| 8 |
+
FILE_LIMIT_MB = 1000
|
| 9 |
+
|
| 10 |
+
def _return_yt_html_embed(yt_url):
|
| 11 |
+
video_id = yt_url.split("?v=")[-1]
|
| 12 |
+
HTML_str = (
|
| 13 |
+
f'<center> <iframe width="500" height="320" src="https://www.youtube.com/embed/{video_id}"> </iframe>'
|
| 14 |
+
" </center>"
|
| 15 |
+
)
|
| 16 |
+
return HTML_str
|
| 17 |
+
demo = gr.Interface(
|
| 18 |
+
fn=_return_yt_html_embed,
|
| 19 |
+
inputs="text",
|
| 20 |
+
# outputs=["html", "text"],
|
| 21 |
+
outputs="html",
|
| 22 |
+
layout="horizontal",
|
| 23 |
+
theme="huggingface",
|
| 24 |
+
title="YouTube Video Viwer",
|
| 25 |
+
description=("YouTube Video Viwer"),
|
| 26 |
+
allow_flagging="never",
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
demo.queue(max_size=2).launch()
|