Spaces:
Sleeping
Sleeping
Rivalcoder
commited on
Commit
·
3befc55
1
Parent(s):
898f1d6
Add
Browse files
app.py
CHANGED
|
@@ -10,14 +10,14 @@ ytt_api = YouTubeTranscriptApi(
|
|
| 10 |
)
|
| 11 |
)
|
| 12 |
|
| 13 |
-
# Function to fetch YouTube transcript using the video ID
|
| 14 |
def fetch_transcript(video_id: str):
|
| 15 |
try:
|
| 16 |
# Fetch transcript
|
| 17 |
transcript = ytt_api.fetch(video_id)
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
return
|
| 21 |
except Exception as e:
|
| 22 |
return f"Error fetching transcript: {str(e)}"
|
| 23 |
|
|
|
|
| 10 |
)
|
| 11 |
)
|
| 12 |
|
| 13 |
+
# Function to fetch and format YouTube transcript using the video ID
|
| 14 |
def fetch_transcript(video_id: str):
|
| 15 |
try:
|
| 16 |
# Fetch transcript
|
| 17 |
transcript = ytt_api.fetch(video_id)
|
| 18 |
+
# Extract and join only the text fields
|
| 19 |
+
full_text = " ".join([entry['text'] for entry in transcript])
|
| 20 |
+
return full_text
|
| 21 |
except Exception as e:
|
| 22 |
return f"Error fetching transcript: {str(e)}"
|
| 23 |
|