fix proxy elem
This commit is contained in:
parent
dca80369de
commit
d7bab22280
@ -13,6 +13,7 @@ import expiringdict
|
||||
import subprocess
|
||||
import json
|
||||
import re
|
||||
import config
|
||||
|
||||
try:
|
||||
streamlink_sessions = {}
|
||||
@ -122,8 +123,7 @@ class StreamProvider():
|
||||
self.upstream = upstream
|
||||
self.proxy = None
|
||||
self.logger = logger
|
||||
proxy = str(proxy)
|
||||
if len(proxy) > 5:
|
||||
if isinstance(proxy, config.ProxyElem):
|
||||
self.proxy = proxy
|
||||
def extract_mime(self, upstream):
|
||||
try:
|
||||
@ -156,10 +156,10 @@ class StreamProvider():
|
||||
if not isinstance(data.upstream(), str) or isinstance(data.ctype(), str):
|
||||
return data
|
||||
proxies = None
|
||||
if isinstance(self.proxy, str):
|
||||
if self.proxy is not None and self.proxy.proxy is not None:
|
||||
proxies = {}
|
||||
proxies["http"] = "socks5://" + self.proxy
|
||||
proxies["https"] = "socks5://" + self.proxy
|
||||
proxies["http"] = "socks5://" + self.proxy.proxy
|
||||
proxies["https"] = "socks5://" + self.proxy.proxy
|
||||
ctype = None
|
||||
upstream = data.upstream()
|
||||
try:
|
||||
@ -188,10 +188,10 @@ class StreamlinkRunner(StreamProvider):
|
||||
def stream(self):
|
||||
try:
|
||||
session = None
|
||||
if self.proxy is None:
|
||||
if self.proxy is None or self.proxy.proxy is None:
|
||||
session = streamlink_default_session
|
||||
else:
|
||||
session = streamlink_sessions.get(self.proxy)
|
||||
session = streamlink_sessions.get(self.proxy.proxy)
|
||||
media = session.resolve_url(self.upstream)
|
||||
streams = None
|
||||
if isinstance(media, tuple):
|
||||
@ -214,8 +214,9 @@ class YoutubeRunner(StreamProvider):
|
||||
try:
|
||||
opts = {}
|
||||
opts["logger"] = DummyLogger()
|
||||
if isinstance(self.proxy, str):
|
||||
opts["proxy"] = "socks5://" + self.proxy
|
||||
|
||||
if self.proxy is not None and self.proxy.proxy is not None:
|
||||
opts["proxy"] = "socks5://" + self.proxy.proxy
|
||||
with youtube_dl.YoutubeDL(opts) as ydl:
|
||||
info = ydl.extract_info(self.upstream, download=False)
|
||||
vformats = info.get("formats")
|
||||
|
Loading…
Reference in New Issue
Block a user