Spaces:
Sleeping
Sleeping
File size: 814 Bytes
ed65c68 5d970ca ed65c68 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
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}
|