|
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) |
|
|
|
def generate_random_name(length=10): |
|
letters = string.ascii_lowercase |
|
return ''.join(random.choice(letters) for _ in range(length)) |
|
|
|
|
|
def download_youtube_video(url): |
|
|
|
ydl_opts = { |
|
'outtmpl': f'{generate_random_name()}' |
|
} |
|
|
|
|
|
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 = gr.Interface( |
|
fn=download_youtube_video, |
|
inputs=gr.Textbox(label="Enter YouTube link"), |
|
outputs=gr.Video(label = "video_path") |
|
).launch() |