1 parent
882194310a
commit
341d6ef1fe
6 files changed
+33
-22
No files matched your search
+2
-1
@@ -41,4 +41,5 @@ qrcode.png
|
||||
/biliup/stream-gears/
|
||||
data/
|
||||
.next
|
||||
out
|
||||
out
|
||||
downloads/
|
||||
+1
-1
@@ -2,7 +2,7 @@ import logging
|
||||
import platform
|
||||
import sys
|
||||
|
||||
__version__ = "0.4.87"
|
||||
__version__ = "0.4.88"
|
||||
|
||||
LOG_CONF = {
|
||||
'version': 1,
|
||||
|
||||
@@ -59,10 +59,10 @@ class DownloadBase(ABC):
|
||||
self.opt_args = opt_args
|
||||
self.live_cover_url = None
|
||||
self.fake_headers = {
|
||||
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
'accept-encoding': DEFAULT_ACCEPT_ENCODING,
|
||||
'accept-language': 'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
|
||||
'user-agent': random_user_agent(),
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
'Accept-Encoding': DEFAULT_ACCEPT_ENCODING,
|
||||
'Accept-Language': 'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
|
||||
'User-Agent': random_user_agent(),
|
||||
}
|
||||
self.segment_time = config.get('segment_time', '01:00:00')
|
||||
self.time_range = config.get('time_range')
|
||||
|
||||
+24
-14
@@ -13,13 +13,15 @@ from ..engine.decorators import Plugin
|
||||
from ..engine.download import DownloadBase
|
||||
from ..plugins import logger, match1, random_user_agent
|
||||
|
||||
HUYA_WEB_BASE_URL = "https://www.huya.com"
|
||||
HUYA_MOBILE_BASE_URL = "https://m.huya.com"
|
||||
|
||||
@Plugin.download(regexp=r'https?://(?:(?:www|m)\.)?huya\.com')
|
||||
class Huya(DownloadBase):
|
||||
def __init__(self, fname, url, suffix='flv'):
|
||||
super().__init__(fname, url, suffix)
|
||||
self.fake_headers['referer'] = url
|
||||
self.fake_headers['cookie'] = config.get('user', {}).get('huya_cookie', '')
|
||||
# self.fake_headers['cookie'] = config.get('user', {}).get('huya_cookie', '')
|
||||
self.__room_id = url.split('huya.com/')[1].split('?')[0]
|
||||
self.huya_danmaku = config.get('huya_danmaku', False)
|
||||
self.huya_max_ratio = config.get('huya_max_ratio', 0)
|
||||
@@ -44,13 +46,19 @@ class Huya(DownloadBase):
|
||||
REPLAY: 重播
|
||||
OFF: 未开播
|
||||
'''
|
||||
logger.debug(f"{self.plugin_msg} : 未开播")
|
||||
logger.debug(f"{self.plugin_msg}: 未开播")
|
||||
self.raw_stream_url = None
|
||||
return False
|
||||
|
||||
if not room_profile['liveData'].get('bitRateInfo'):
|
||||
# 主播未推流
|
||||
logger.debug(f"{self.plugin_msg} : 未推流")
|
||||
logger.debug(f"{self.plugin_msg}: 未推流")
|
||||
return False
|
||||
|
||||
self.room_title = room_profile['liveData']['introduction']
|
||||
# 虎牙回放
|
||||
if self.room_title.startswith('【回放】'):
|
||||
logger.debug(f"{self.plugin_msg}: {self.room_title}")
|
||||
return False
|
||||
|
||||
if is_check:
|
||||
@@ -77,7 +85,7 @@ class Huya(DownloadBase):
|
||||
logger.error(f"{self.plugin_msg}: 在确定码率时发生错误 {e}")
|
||||
return False
|
||||
|
||||
is_xingxiu = room_profile['liveData']['gid'] == 1663
|
||||
is_xingxiu = (room_profile['liveData']['gid'] == 1663)
|
||||
|
||||
try:
|
||||
stream_urls = await self.get_stream_urls(self.huya_protocol, self.huya_mobile_api, self.huya_imgplus, is_xingxiu)
|
||||
@@ -89,6 +97,9 @@ class Huya(DownloadBase):
|
||||
if not self.huya_cdn or self.huya_cdn not in cdn_name:
|
||||
self.huya_cdn = cdn_name[0]
|
||||
|
||||
# Thx stream-rec
|
||||
update_user_agent(self.fake_headers)
|
||||
|
||||
# 虎牙直播流只允许连接一次
|
||||
if self.huya_cdn_fallback:
|
||||
_url = await self.acheck_url_healthy(stream_urls[self.huya_cdn])
|
||||
@@ -106,7 +117,6 @@ class Huya(DownloadBase):
|
||||
return False
|
||||
stream_urls = await self.get_stream_urls(self.huya_protocol, self.huya_mobile_api, self.huya_imgplus, is_xingxiu)
|
||||
|
||||
self.room_title = room_profile['liveData']['introduction']
|
||||
self.raw_stream_url = stream_urls[self.huya_cdn]
|
||||
|
||||
if self.huya_max_ratio and record_ratio != max_ratio:
|
||||
@@ -159,23 +169,20 @@ class Huya(DownloadBase):
|
||||
suffix, anti_code = stream[f's{protocol}UrlSuffix'], stream[f's{protocol}AntiCode']
|
||||
if not allow_imgplus:
|
||||
stream_name = stream_name.replace('-imgplus', '')
|
||||
anti_code = anti_code if is_xingxiu else \
|
||||
anti_code = anti_code + "&codec=264" \
|
||||
if is_xingxiu else \
|
||||
self.__build_query(stream_name, anti_code, _get_uid(self.fake_headers['cookie'], stream_name))
|
||||
for stream in stream_info:
|
||||
# 优先级<0代表不可用
|
||||
priority = (
|
||||
stream['iPCPriorityRate'],
|
||||
stream['iWebPriorityRate'],
|
||||
stream['iMobilePriorityRate']
|
||||
)
|
||||
if any(rate < 0 for rate in priority):
|
||||
priority = stream['iWebPriorityRate']
|
||||
if priority < 0:
|
||||
continue
|
||||
cdn_name = stream['sCdnType']
|
||||
secure_url = stream[f's{protocol}Url'].replace('http://', 'https://')
|
||||
stream_url = f"{secure_url}/{stream_name}.{suffix}?{anti_code}"
|
||||
streams[cdn_name] = stream_url
|
||||
if len(weights) < len(stream_info):
|
||||
weights[cdn_name] = max(0, *priority)
|
||||
if cdn_name not in weights:
|
||||
weights[cdn_name] = priority
|
||||
return _weight_sorting(streams, weights)
|
||||
|
||||
@staticmethod
|
||||
@@ -265,3 +272,6 @@ def _get_uid(cookie: str, stream_name: str) -> int:
|
||||
# "data": {},
|
||||
# }
|
||||
# )['data']['uid']
|
||||
|
||||
def update_user_agent(headers: dict):
|
||||
headers['User-Agent'] = f"HYSDK(Windows, {int(time.time())})"
|
||||
+1
-1
@@ -24,7 +24,7 @@ filtering_threshold = 20
|
||||
#submit_api = "client"
|
||||
### 选择全局默认上传插件,Noop为不上传,但会执行后处理,可选bili_web,biliup-rs(默认值)
|
||||
#uploader = "Noop"
|
||||
### b站上传线路选择,默认为自动模式,目前可手动切换为bda2, kodo, ws, qn, bldsa, cos, cos-internal(支持腾讯云内网免流+提速,目前已失效)
|
||||
### b站上传线路选择,默认自动选择最优线路。目前可手动切换为alia(海外), bda2(大陆), bldsa(大陆), qn(全球), tx(大陆), txa(海外)
|
||||
lines = "AUTO"
|
||||
### 单文件并发上传数,未达到带宽上限时,增大此值可提高上传速度(不要设置过大,部分线路限制为8,如速度不佳优先调整上传线路)
|
||||
threads = 3
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ filtering_threshold: 20
|
||||
#uploader: Noop
|
||||
### b站提交接口,默认自动选择,可选web,client
|
||||
#submit_api: client
|
||||
### b站上传线路选择,默认为自动模式,目前可手动切换为bda2, kodo, ws, qn, bldsa, cos, cos-internal(支持腾讯云内网免流+提速)
|
||||
### b站上传线路选择,默认自动选择最优线路。目前可手动切换为alia(海外), bda2(大陆), bldsa(大陆), qn(全球), tx(大陆), txa(海外)
|
||||
lines: AUTO
|
||||
### 单文件并发上传数,未达到带宽上限时,增大此值可提高上传速度(不要设置过大,部分线路限制为8,如速度不佳优先调整上传线路)
|
||||
threads: 3
|
||||
|
||||
Reference in new issue
Block a user