Salman11223's picture
Update app.py
91d54bf verified
raw
history blame
1.02 kB
import os
import requests
from youtube_video import download_youtube_video
import gradio as gr
def download_and_return(video_link):
try:
print(f"Received video link: {video_link}")
video_path = download_youtube_video(video_link)
if video_path:
print(f"Downloaded video path: {video_path}")
return gr.Video(video_path)
else:
return "Error downloading video. Please check the YouTube link."
except Exception as e:
return f"An error occurred: {e}"
def huggingface_app(video_link):
# You can use the video link to download the video and return the path
return download_and_return(video_link)
# Deploy the Gradio interface with the Hugging Face app
interface = gr.Interface(
fn=huggingface_app,
inputs=gr.Textbox(label="Enter YouTube link"),
outputs=gr.Video(label="Your result"),
live=True # Set live to True for continuous updates
)
# Launch the interface
interface.launch(debug = True)