File size: 1,306 Bytes
a9cdbb3
 
 
 
 
6e267e3
 
 
e476302
 
 
210ef49
a9cdbb3
 
 
 
 
 
 
 
 
41a0342
a9cdbb3
 
 
 
 
3ff7c52
f61fd58
a9cdbb3
 
 
fea30cc
422df43
fea30cc
 
50b6665
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
36
37
import gradio as gr
import yt_dlp
import os
import random
import string
text="""Unleash The Power of GhostByte's YOutube Video Downloader!
Directly Download Original Quality Videos from server! No quality Loss!
Click on download button in output box to download video
Video format is webm and there is no problem with it!

NOTE: GOOGLE BLOCKS IP IF TOO MANY REQUESTS SENT. SO THE VIDEO WILL NOT DOWNLOAD THEN. I WILL RESOLVE IT AS SOON AS POSSIBLE!"""
gr.Markdown(text)
# Function to generate a random alphabet name for the video file
def generate_random_name(length=10):
    letters = string.ascii_lowercase
    return ''.join(random.choice(letters) for _ in range(length))

# Function to download YouTube video using yt-dlp
def download_youtube_video(url):
    # Set yt-dlp options
    ydl_opts = {
        'outtmpl': f'{generate_random_name()}'# Save video with a random name
    }
    
    # Download video
    with yt_dlp.YoutubeDL(ydl_opts) as ydl:
        info_dict = ydl.extract_info(url, download=True)
        filename = ydl.prepare_filename(info_dict) + ".webm"
        print(filename)
    return filename

# Interface for Gradio app
interface = gr.Interface(
    fn=download_youtube_video,
    inputs=gr.Textbox(label="Enter YouTube link"),
    outputs=gr.Video(label = "video_path")
).launch()