jdepoix / youtube-transcript-api

This is a python API which allows you to get the transcript/subtitles for a given YouTube video. It also works for automatically generated subtitles and it does not require an API key nor a headless browser, like other selenium based solutions do!
MIT License
2.55k stars 280 forks source link

Socks5 proxy support #231

Closed leohuang2013 closed 6 months ago

leohuang2013 commented 8 months ago

Is your feature request related to a problem? Please describe. Is possible to support sock5 as proxy?

Currently, youtube-transcript-api supports https as proxy, I think socks5 would be help as some project only allow socks5, like us.

jdepoix commented 6 months ago

Hi @leohuang2013, sorry for the late reply!

The proxies param is just passed through to requests. I haven't tried this myself, but according to stackoverflow, you only need to install requests[socks] to be able to use sock5 urls as part of the requests proxy config. So you should be able to do run this:

YouTubeTranscriptApi.get_transcript(video_id, proxies={
    'http': 'socks5://user:pass@host:port',
    'https': 'socks5://user:pass@host:port',
})