youtube-dl --proxy socks5://127.0.0.1:1080 $link -o $dir
can download video on youtube embedded socks5 proxy in bash shell.
With the following codes,we embedded youtube-dl in python codes.
from __future__ import unicode_literals
import youtube_dl
ydl_opts = {}
link = "some_youtube_url"
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([link])
How to embed socks5 proxy in python codes?
I had read the document on https://github.com/rg3/youtube-dl ,still don't know how to add socks5 proxy in youtube-dl's python codes.
Simply set the proxy
option:
ydl_opts = {
'proxy': 'socks5://127.0.0.1:1080',
}
and keep the rest of the code unchanged.