I ran this code in the terminal and it worked perfectly. The output was the transcript of the video I provided.
import subprocess
import sys
# Function to install a library using pip
def install(package):
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
# Install the required library
install("youtube_transcript_api")
from youtube_transcript_api import YouTubeTranscriptApi
def fetch_video_transcript(video_url):
# Extracting Video ID from URL
if "youtu.be" in video_url:
video_id = video_url.split('/')[-1]
else:
video_id = video_url.split('v=')[-1].split('&')[0]
# Attempt to fetch the video transcript
try:
transcript_list = YouTubeTranscriptApi.get_transcript(video_id)
full_transcript = '\n'.join([item['text'] for item in transcript_list])
return full_transcript
except Exception as e:
return f"Failed to fetch transcript: {str(e)}"
# Main block to set the 'result' variable, as expected by the platform
video_url = "https://www.youtube.com/watch?v=u9m0nQ3-a58&ab_channel=JackRoberts"
result = {"data": fetch_video_transcript(video_url)}
However, when I ran it on Make with the module 0CodeKit, it said:
ResultCollection
data
Failed to fetch transcript: Could not retrieve a transcript for the video https://www.youtube.com/watch?v=u9m0nQ3-a58! This is most likely caused by: Subtitles are disabled for this video If you are sure that the described cause is not responsible for this error and that a transcript should be retrievable, please create an issue at Issues ¡ jdepoix/youtube-transcript-api ¡ GitHub. Please add which version of youtube_transcript_api you are using and provide the information needed to replicate the error. Also make sure that there are no open issues which already describe your problem!
I followed the instructions from 0codekit: I added âyoutube-transcript-apiâ to the requirements section to install the package, but the result is still the same.
from youtube_transcript_api import YouTubeTranscriptApi
def fetch_video_transcript(video_url):
# Extracting Video ID from URL
if "youtu.be" in video_url:
video_id = video_url.split('/')[-1]
else:
video_id = video_url.split('v=')[-1].split('&')[0]
# Attempt to fetch the video transcript
try:
transcript_list = YouTubeTranscriptApi.get_transcript(video_id)
full_transcript = '\n'.join([item['text'] for item in transcript_list])
return full_transcript
except Exception as e:
return f"Failed to fetch transcript: {str(e)}"
# Main block to set the 'result' variable, as expected by the platform
video_url = "{{2.data.`3a4nl`.value}}"
result ={'data': fetch_video_transcript(video_url)}
I see. I would maybe replicate the module in Postman and if that doesnât work open a ticket with 0CodeKit.
If it works in Postman but not Make then maybe open a ticket with Make unless someone spots an issue with the module.
I just ran into the same issue. Unfortunately I wasnât able to reproduce the call into postman directly since they auth method doesnât work with me.
I just wrote to their slack channel for clarification. I think the access to youtube might be stopped since I am able to execute the same python code in my local dev box.
Same problem here.
I have this message:
You are using implicit requirements. This feature is deprecated, since it is inaccurate and unreliable, and will be removed in the future. Please specify the dependencies of your Python code manually. The ârequirementsâ field should be set to â[âyoutube-transcript-apiâ]â.