mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-30 19:36:25 +02:00
Merge pull request #336 from sandeeppainuly/fix-294-youtube-transcript-source-not-working-youtubetranscriptapi-has-no-attribute-get-transcript
Fix YouTube transcript API: replace deprecated get_transcript with fetch method
This commit is contained in:
commit
4e012845c4
1 changed files with 5 additions and 4 deletions
|
|
@ -136,13 +136,14 @@ async def add_youtube_video_document(
|
|||
)
|
||||
|
||||
try:
|
||||
captions = YouTubeTranscriptApi.get_transcript(video_id)
|
||||
ytt_api = YouTubeTranscriptApi()
|
||||
captions = ytt_api.fetch(video_id)
|
||||
# Include complete caption information with timestamps
|
||||
transcript_segments = []
|
||||
for line in captions:
|
||||
start_time = line.get("start", 0)
|
||||
duration = line.get("duration", 0)
|
||||
text = line.get("text", "")
|
||||
start_time = line.start
|
||||
duration = line.duration
|
||||
text = line.text
|
||||
timestamp = f"[{start_time:.2f}s-{start_time + duration:.2f}s]"
|
||||
transcript_segments.append(f"{timestamp} {text}")
|
||||
transcript_text = "\n".join(transcript_segments)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue