Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
proxy_handler = ProxyHandler({
'http': args.http_proxy,
'https': args.http_proxy
})
handlers.append(proxy_handler)
elif args.socks_proxy:
try:
import socks
addr, port = args.socks_proxy.split(':')
socks.set_default_proxy(socks.SOCKS5, addr, int(port))
socket.socket = socks.socksocket
except:
print('Failed to set socks5 proxy. Please install PySocks.', file=sys.stderr)
opener = build_opener(*handlers)
install_opener(opener)
m, u = url_to_module(args.video_url)
info = m.parser(u)
# Is a playlist?
if m.list_only():
video_list = m.prepare_list()
result = [ {'title': match1(get_content(url), r'<title>(.+?)</title>'), 'url': url} for url in video_list ]
else:
result = info.jsonlize()
print(json.dumps(result, indent=4, sort_keys=True, ensure_ascii=False))
def install_default_handlers():
install_opener(build_opener(*default_handlers))