Spaces:
Sleeping
Sleeping
Download youtube_processing.py from I-AdityaGoyal/NoteBot: direct link, hf CLI and curl.
- Browser
- Download file 509 Bytes
-
https://huggingface.co/spaces/I-AdityaGoyal/NoteBot/resolve/main/youtube_processing.py
- Command line
-
hf download hf://spaces/I-AdityaGoyal/NoteBot/youtube_processing.py
-
curl -L -o youtube_processing.py https://huggingface.co/spaces/I-AdityaGoyal/NoteBot/resolve/main/youtube_processing.py
509 Bytes
| from youtube_transcript_api import YouTubeTranscriptApi | |
| import re | |
| def extract_text_from_youtube(video_url): | |
| video_id = re.search(r"(?<=v=)[^&#]+", video_url) | |
| if not video_id: | |
| return "" | |
| video_id = video_id.group(0) | |
| try: | |
| transcript = YouTubeTranscriptApi.get_transcript(video_id) | |
| text = " ".join([item['text'] for item in transcript]) | |
| return text | |
| except Exception as e: | |
| print(f"Error fetching transcript: {e}") | |
| return "" | |