add ctype to result
This commit is contained in:
parent
c1db637b94
commit
631393d4c2
@ -119,7 +119,7 @@ class StreamProvider():
|
||||
self.proxy = proxy
|
||||
def process(self):
|
||||
data = self.stream()
|
||||
if not isinstance(data.upstream(), str):
|
||||
if not isinstance(data.upstream(), str) or isinstance(data.ctype(), str):
|
||||
return data
|
||||
proxies = None
|
||||
if isinstance(self.proxy, str):
|
||||
@ -128,11 +128,13 @@ class StreamProvider():
|
||||
proxies["https"] = "socks5://" + self.proxy
|
||||
ctype = "binary/octet-stream"
|
||||
try:
|
||||
resp = requests.head(data.upstream(), proxies=proxies)
|
||||
resp = requests.head(data.upstream(), proxies=proxies, timeout=5)
|
||||
except Exception as e:
|
||||
self.logger.info(e)
|
||||
else:
|
||||
ctype = resp.headers.get("Content-Type", "binary/octet-stream")
|
||||
if "mpegurl" in ctype.lower():
|
||||
ctype = "application/vnd.apple.mpegurl"
|
||||
return StreamData(data.upstream(), ctype, data.thumbnail(), data.title(), data.description(), data.override)
|
||||
async def run(self):
|
||||
data = None
|
||||
@ -273,6 +275,7 @@ async def get_any(upstream, proxy, logger):
|
||||
temp_result = await task
|
||||
if isinstance(temp_result, StreamData):
|
||||
result.update("upstream", temp_result.upstream(), temp_result.override)
|
||||
result.update("ctype", temp_result.ctype(), temp_result.override)
|
||||
result.update("thumbnail", temp_result.thumbnail(), temp_result.override)
|
||||
result.update("title", temp_result.title(), temp_result.override)
|
||||
result.update("description", temp_result.description(), temp_result.override)
|
||||
|
Loading…
Reference in New Issue
Block a user