Spaces:
Runtime error
Runtime error
Commit ·
45c7a65
1
Parent(s): 261ba55
Add application file
Browse files
app.py
CHANGED
|
@@ -1,11 +1,24 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
return "Yes"
|
| 7 |
-
else:
|
| 8 |
-
return "No"
|
| 9 |
-
|
| 10 |
-
demo = gr.Interface(fn=check_link, inputs="text", outputs="text")
|
| 11 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from pytube import YouTube
|
| 3 |
|
| 4 |
+
def get_youtube_details(link):
|
| 5 |
+
try:
|
| 6 |
+
yt = YouTube(link)
|
| 7 |
+
|
| 8 |
+
# Get the thumbnail URL
|
| 9 |
+
thumbnail_url = yt.thumbnail_url
|
| 10 |
+
|
| 11 |
+
# Get captions (if available)
|
| 12 |
+
caption_text = "No captions available."
|
| 13 |
+
if yt.captions:
|
| 14 |
+
# Choose the first caption track available
|
| 15 |
+
caption = yt.captions.get_by_language_code('en')
|
| 16 |
+
if caption:
|
| 17 |
+
caption_text = caption.generate_srt_captions()
|
| 18 |
+
|
| 19 |
+
return caption_text, thumbnail_url
|
| 20 |
+
except Exception as e:
|
| 21 |
+
return str(e), None
|
| 22 |
|
| 23 |
+
demo = gr.Interface(fn=get_youtube_details, inputs="text", outputs=["text", "image"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
demo.launch()
|