Existance commited on
Commit
633f420
·
1 Parent(s): 3e0de48

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
18
+
19
+ with gr.Blocks(title='YT-Video-Viewer') as demo:
20
+ gr.Markdown("YT-Video-Viewer")
21
+
22
+ URL = gr.Textbox("Enter URL here", interactive=True,label="Youtube URL")
23
+
24
+ gr.Interface(
25
+ fn=_return_yt_html_embed,
26
+ inputs=[URL],
27
+ # outputs=["html", "text"],
28
+ outputs=["html"],
29
+ layout="horizontal",
30
+ theme="huggingface",
31
+ title="YouTube Video Viwer",
32
+ description=("YouTube Video Viwer"),
33
+ allow_flagging="never",
34
+ )
35
+ demo.queue(max_size=20).launch(debug=True)