File size: 861 Bytes
633f420
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import gradio as gr
import yt_dlp as youtube_dl
import tempfile
import os


YT_LENGTH_LIMIT_S = 3600
FILE_LIMIT_MB = 1000

def _return_yt_html_embed(yt_url):
    video_id = yt_url.split("?v=")[-1]
    HTML_str = (
        f'<center> <iframe width="500" height="320" src="https://www.youtube.com/embed/{video_id}"> </iframe>'
        " </center>"
    )
    return HTML_str


with gr.Blocks(title='YT-Video-Viewer') as demo:
    gr.Markdown("YT-Video-Viewer")
    
    URL = gr.Textbox("Enter URL here", interactive=True,label="Youtube URL")
    
    gr.Interface(
    fn=_return_yt_html_embed,
    inputs=[URL],
    # outputs=["html", "text"],
    outputs=["html"],
    layout="horizontal",
    theme="huggingface",
    title="YouTube Video Viwer",
    description=("YouTube Video Viwer"),
    allow_flagging="never",
)
demo.queue(max_size=20).launch(debug=True)