LangChain_Tutorials icon indicating copy to clipboard operation
LangChain_Tutorials copied to clipboard

Error Fetching YouTube Transcript Using YouTubeTranscriptApi on Server but Works Locally

Open orbimatrix opened this issue 1 year ago • 1 comments

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 = 'Iv9dewmcFbs' 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=Iv9dewmcFbs! 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=Iv9dewmcFbs

(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')))

orbimatrix avatar Jan 10 '25 21:01 orbimatrix