I’m encountering an issue where the YouTubeTranscriptApi library works perfectly on my local machine but fails when run on the server. The script I’m using is as follows:
from youtube_transcript_api import YouTubeTranscriptApi
from youtube_transcript_api import YouTubeTranscriptApi
video_id = 'DxL2HoqLbyA'
try:
transcript = YouTubeTranscriptApi.get_transcript(video_id)
print(transcript)
except Exception as e:
print(f"Error: {e}")
When executed on the server, it throws an error, but it runs without issues on my local setup. Here is the exact error message I receive on the server:Failed to retrieve transcript:
Could not retrieve a transcript for the video https://www.youtube.com/watch?v=DxL2HoqLbyA! 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 https://github.com/jdepoix/youtube-transcript-api/issues. 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 attempted to use a proxy library to bypass the connection issue, but this resulted in a new error. The error message I received is:
HTTPSConnectionPool(host=’www.youtube.com’, port=443):
Max retries exceeded with url: /watch?v=DxL2HoqLbyA
(Caused by ProxyError(‘Unable to connect to proxy’,
NewConnectionError(‘<urllib3.connection.HTTPSConnection object at
0x101b62510>: Failed to establish a new connection: [Errno 61] Connection refused’)))
This indicates that the proxy connection could not be established. Despite configuring various proxy settings and trying different regions on my AWS EC2 instance, I am unable to connect to the YouTube API through the proxy. I expected that resolving the proxy connection issue would allow me to successfully retrieve the transcript on the server, similar to how it works locally.
Additionally, I attempted to solve the problem using Node.js as an alternative approach, but the issue persists.
2
Answers
Confirmed. It’s down for over a week on all YouTube transcript summarization iOS apps. Obviously YT changed something. Unknown what.
YT seems to be blocking the static ip of your server. It has implemented this change a few weeks ago.