Skip to content

Commit

Permalink
Merge branch 'dev' into toran/open-2036-add-jina-and-unreal-to-hidden…
Browse files Browse the repository at this point in the history
…-credentials-list-in-frontend
  • Loading branch information
Torantulino authored Nov 14, 2024
2 parents b57ad33 + 639242a commit f4a8cdd
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion autogpt_platform/backend/backend/blocks/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,22 @@ def extract_video_id(url: str) -> str:

@staticmethod
def get_transcript(video_id: str):
return YouTubeTranscriptApi.get_transcript(video_id)
try:
transcript_list = YouTubeTranscriptApi.list_transcripts(video_id)

if not transcript_list:
raise ValueError(f"No transcripts found for the video: {video_id}")

for transcript in transcript_list:
first_transcript = transcript_list.find_transcript(
[transcript.language_code]
)
return YouTubeTranscriptApi.get_transcript(
video_id, languages=[first_transcript.language_code]
)

except Exception:
raise ValueError(f"No transcripts found for the video: {video_id}")

def run(self, input_data: Input, **kwargs) -> BlockOutput:
video_id = self.extract_video_id(input_data.youtube_url)
Expand Down

0 comments on commit f4a8cdd

Please sign in to comment.