Spaces:
Sleeping
Sleeping
| from blogGenerator.state.state import State | |
| from youtube_transcript_api import YouTubeTranscriptApi | |
| class YTTranscriptNode: | |
| """ | |
| Get Youtube transcription | |
| """ | |
| def process(self, state: State) -> dict: | |
| """Fetches transcript from a given YouTube URL""" | |
| # print(f"Node Called : yt_transcipt") | |
| video_id = state["yt_url"].replace("https://www.youtube.com/watch?v=", "") | |
| try: | |
| transcript = YouTubeTranscriptApi.get_transcript(video_id) | |
| output = "\n".join([x["text"] for x in transcript]) | |
| # print(f"Output : {output}") | |
| print("✅ Transcription fetched successfully.") | |
| except Exception as e: | |
| print(f"❌ Error fetching transcript: {e}") | |
| output = "" | |
| return {"yt_transcript": output} | |