Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -524,8 +524,12 @@ courses_data = [
|
|
| 524 |
(5, "Mathematics", "Ms. Smith", "Intermediate")
|
| 525 |
]
|
| 526 |
|
|
|
|
|
|
|
|
|
|
| 527 |
def extract_video_id(url):
|
| 528 |
-
|
|
|
|
| 529 |
return match.group(1) if match else None
|
| 530 |
|
| 531 |
def get_video_metadata(video_id):
|
|
@@ -615,6 +619,11 @@ def process_youtube_video(url):
|
|
| 615 |
|
| 616 |
except Exception as e:
|
| 617 |
return None, f"Error: {str(e)}", "N/A"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 618 |
|
| 619 |
# Gradio Interface
|
| 620 |
with gr.Blocks(theme=gr.themes.Soft()) as app:
|
|
|
|
| 524 |
(5, "Mathematics", "Ms. Smith", "Intermediate")
|
| 525 |
]
|
| 526 |
|
| 527 |
+
# def extract_video_id(url):
|
| 528 |
+
# match = re.search(r"(?:v=|\/)([0-9A-Za-z_-]{11})", url)
|
| 529 |
+
# return match.group(1) if match else None
|
| 530 |
def extract_video_id(url):
|
| 531 |
+
# Improved regex to handle various YouTube URL formats
|
| 532 |
+
match = re.search(r"(?:v=|\/|be\/|embed\/|watch\?v=)([0-9A-Za-z_-]{11})", url)
|
| 533 |
return match.group(1) if match else None
|
| 534 |
|
| 535 |
def get_video_metadata(video_id):
|
|
|
|
| 619 |
|
| 620 |
except Exception as e:
|
| 621 |
return None, f"Error: {str(e)}", "N/A"
|
| 622 |
+
url = "https://www.youtube.com/watch?v=q1XFm21I-VQ"
|
| 623 |
+
thumbnail, summary, sentiment = process_youtube_video(url)
|
| 624 |
+
print(f"Thumbnail: {thumbnail}\n")
|
| 625 |
+
print(f"Summary:\n{summary}\n")
|
| 626 |
+
print(f"Sentiment: {sentiment}")
|
| 627 |
|
| 628 |
# Gradio Interface
|
| 629 |
with gr.Blocks(theme=gr.themes.Soft()) as app:
|