diff --git a/BiliModule/Main.py b/BiliModule/Main.py
index 7d19226..e0ea3fc 100644
--- a/BiliModule/Main.py
+++ b/BiliModule/Main.py
@@ -73,6 +73,10 @@ def __init__(self, parent=None):
indict['dl_err'] = tempr.get('dl_err')
if tempr.get('chunk_size'):
indict['chunk_size'] = tempr.get('chunk_size')
+ if tempr.get('ProxyAuth'):
+ indict['ProxyAuth']['inuse'] = tempr['ProxyAuth'].get('inuse', False)
+ indict['ProxyAuth']['usr'] = tempr['ProxyAuth'].get('usr', '')
+ indict['ProxyAuth']['pwd'] = tempr['ProxyAuth'].get('pwd', '')
except:
indict["Output"] = DF_Path
indict["sys"] = sys.platform
@@ -116,7 +120,8 @@ def closeEvent(self, QCloseEvent):
"useProxy": indict["useProxy"],
"Proxy": indict["Proxy"],
"dl_err": indict["dl_err"],
- "chunk_size": indict["chunk_size"]
+ "chunk_size": indict["chunk_size"],
+ "ProxyAuth": indict["ProxyAuth"]
}
f.write(json.dumps(temp_dict, sort_keys=True, indent=4))
f.close()
diff --git a/BiliModule/Setting.py b/BiliModule/Setting.py
index 9f0285e..0d127e1 100644
--- a/BiliModule/Setting.py
+++ b/BiliModule/Setting.py
@@ -20,6 +20,12 @@ def __init__(self, ins_dict, parent=None):
self.lineEdit.setText(ins_dict["Proxy"]["http"])
self.dl_err.setValue(ins_dict["dl_err"])
self.chunk_size.setValue(ins_dict["chunk_size"])
+ if self.ins_dict['ProxyAuth']['inuse']:
+ self.cb_useAuth.setChecked(True)
+ self.le_AuthUsr.setEnabled(True)
+ self.le_AuthPwd.setEnabled(True)
+ self.le_AuthUsr.setText(ins_dict['ProxyAuth']['usr'])
+ self.le_AuthPwd.setText(ins_dict['ProxyAuth']['pwd'])
# 设置父窗口阻塞与窗口透明
self.setWindowModality(Qt.ApplicationModal)
self.setWindowFlags(Qt.FramelessWindowHint)
@@ -40,6 +46,7 @@ def __init__(self, ins_dict, parent=None):
self.btn_wherecookie.clicked.connect(self.forHelp)
self.btn_testProxy.clicked.connect(self.testProxy)
self.btn_huseProxy.clicked.connect(self.ProxyHelp)
+ self.cb_useAuth.clicked.connect(self.inUseAuth)
# ###################### RW Part ##########################
# 鼠标点击事件产生
@@ -68,7 +75,13 @@ def closeEvent(self, QCloseEvent):
def testProxy(self):
proxy_url = self.lineEdit.text()
proxy_temp = {'http': proxy_url, 'https': proxy_url, }
- self.ts = checkProxy(proxy_temp)
+ auth_tmp = None
+ if self.cb_useAuth:
+ auth_tmp = {
+ 'usr': self.le_AuthUsr,
+ 'pwd': self.le_AuthPwd
+ }
+ self.ts = checkProxy(proxy_temp, auth_tmp)
self.lineEdit.setEnabled(False)
self.btn_testProxy.setEnabled(False)
self.btn_testProxy.setText("正在检测")
@@ -78,14 +91,14 @@ def testProxy(self):
# 确定设置函数
def setConfig(self):
self.ins_dict["cookie"] = self.edit_cookies.toPlainText()
- if self.cb_useProxy.isChecked():
- self.ins_dict["useProxy"] = True
- else:
- self.ins_dict["useProxy"] = False
+ self.ins_dict["useProxy"] = self.cb_useProxy.isChecked()
proxy_url = self.lineEdit.text()
self.ins_dict["Proxy"] = {'http': proxy_url, 'https': proxy_url, }
self.ins_dict["dl_err"] = self.dl_err.value()
self.ins_dict["chunk_size"] = self.chunk_size.value()
+ self.ins_dict["ProxyAuth"]["inuse"] = self.cb_useAuth.isChecked()
+ self.ins_dict["ProxyAuth"]["usr"] = self.le_AuthUsr.text()
+ self.ins_dict["ProxyAuth"]["pwd"] = self.le_AuthPwd.text()
self._signal.emit({"code": 1, "indict": self.ins_dict})
self.close()
@@ -101,6 +114,15 @@ def forHelp(self):
def ProxyHelp(self):
webbrowser.open("https://jimmyliang-lzm.github.io/2021/10/07/bilid_GUI_help/#3-5-“僅限港澳台地區”视频下载")
+ # 使用代理检查框按下事件
+ def inUseAuth(self):
+ if self.cb_useAuth.isChecked():
+ self.le_AuthUsr.setEnabled(True)
+ self.le_AuthPwd.setEnabled(True)
+ else:
+ self.le_AuthUsr.setEnabled(False)
+ self.le_AuthPwd.setEnabled(False)
+
# ########################## 槽函数 ################################
# 代理地址测试线程槽函数
def proxy_catch(self, in_dict):
diff --git a/BiliWorker/extra.py b/BiliWorker/extra.py
index b9acf9d..ebb0932 100644
--- a/BiliWorker/extra.py
+++ b/BiliWorker/extra.py
@@ -53,19 +53,28 @@ def run(self):
class checkProxy(QThread):
_feedback = Signal(dict)
- def __init__(self, in_Proxy):
+ def __init__(self, in_Proxy, auth=None):
super(checkProxy, self).__init__()
self.use_Proxy = in_Proxy
self.index_headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/72.0.3626.121 Safari/537.36 "
}
+ self.Auth = auth
+ if auth:
+ from requests.auth import HTTPProxyAuth
+ self.Auth = HTTPProxyAuth(auth.get('usr'), auth.get('pwd'))
def run(self):
try:
temp = {"code": 1}
des = request.get("https://api.live.bilibili.com/xlive/web-room/v1/index/getIpInfo",
- headers=self.index_headers, timeout=10, stream=False, proxies=self.use_Proxy)
+ headers=self.index_headers,
+ timeout=10,
+ stream=False,
+ proxies=self.use_Proxy,
+ auth=self.Auth
+ )
res = json.loads(des.content.decode('utf-8'))["data"]
temp["ip"] = res["addr"]
temp["area"] = res["country"]
@@ -96,14 +105,17 @@ def __init__(self, args, model=0, parent=None):
self.re_INITIAL_STATE = 'window.__INITIAL_STATE__=([\s\S]*?);\(function'
if args["useCookie"]:
self.index_headers["cookie"] = args["cookie"]
- # self.second_headers["cookie"] = args["cookie"]
else:
self.index_headers["cookie"] = ""
- # self.second_headers["cookie"] = ""
+ # 使用代理
+ self.Proxy = None
if args["useProxy"]:
self.Proxy = args["Proxy"]
- else:
- self.Proxy = {}
+ # 若使用代理验证
+ self.ProxyAuth = None
+ if args["ProxyAuth"]["inuse"]:
+ from requests.auth import HTTPProxyAuth
+ self.ProxyAuth = HTTPProxyAuth(args['ProxyAuth']['usr'], args['ProxyAuth']['pwd'])
self.iscache = args['imgcache']
self.cache_path = args['cache_path'] + "/temp"
# 初始化缓存图片下载类
@@ -187,7 +199,14 @@ def change_method(self, mode: int, **kwargs):
# Interactive video initial information
def Get_Init_Info(self, url):
try:
- res = request.get(url, headers=self.index_headers, stream=False, timeout=10, proxies=self.Proxy)
+ res = request.get(
+ url,
+ headers=self.index_headers,
+ stream=False,
+ timeout=10,
+ proxies=self.Proxy,
+ auth=self.ProxyAuth
+ )
dec = res.content.decode('utf-8')
playinfo = re.findall(self.re_playinfo, dec, re.S)
INITIAL_STATE = re.findall(self.re_INITIAL_STATE, dec, re.S)
@@ -211,7 +230,14 @@ def isInteract(self):
'bvid': self.now_interact["bvid"],
}
try:
- res = request.get(make_API, headers=self.index_headers, params=param, timeout=10, proxies=self.Proxy)
+ res = request.get(
+ make_API,
+ headers=self.index_headers,
+ params=param,
+ timeout=10,
+ proxies=self.Proxy,
+ auth=self.ProxyAuth
+ )
des = res.json()
if "interaction" not in des["data"]:
raise Exception("非交互视频")
@@ -230,7 +256,14 @@ def Get_Edge(self):
'node_id': self.now_interact["node_id"],
}
try:
- des = request.get(make_API, headers=self.index_headers, params=param, timeout=10, proxies=self.Proxy)
+ des = request.get(
+ make_API,
+ headers=self.index_headers,
+ params=param,
+ timeout=10,
+ proxies=self.Proxy,
+ auth=self.ProxyAuth
+ )
res = des.json()
except Exception as e:
print("Get Edges:", e)
@@ -282,7 +315,14 @@ def recursion_GET_List(self, inword):
'node_id': self.now_interact["node_id"],
}
try:
- des = request.get(make_API, headers=self.index_headers, params=param, timeout=10, proxies=self.Proxy)
+ des = request.get(
+ make_API,
+ headers=self.index_headers,
+ params=param,
+ timeout=10,
+ proxies=self.Proxy,
+ auth=self.ProxyAuth
+ )
desp = des.json()
except Exception as e:
self.business_info.emit("获取节点信息出现网络问题:节点提取可能不全")
@@ -345,14 +385,18 @@ def __init__(self, req_dict: dict):
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/72.0.3626.121 Safari/537.36 "
}
+ self.index_headers["cookie"] = ""
if req_dict["useCookie"]:
self.index_headers["cookie"] = req_dict["cookie"]
- else:
- self.index_headers["cookie"] = ""
+ # 使用代理
+ self.Proxy = None
if req_dict["useProxy"]:
self.Proxy = req_dict["Proxy"]
- else:
- self.Proxy = {}
+ # 若使用代理验证
+ self.ProxyAuth = None
+ if req_dict["ProxyAuth"]["inuse"]:
+ from requests.auth import HTTPProxyAuth
+ self.ProxyAuth = HTTPProxyAuth(req_dict['ProxyAuth']['usr'], req_dict['ProxyAuth']['pwd'])
self.cache_path = req_dict['cache_path'] + "/temp"
# 初始化递归字典
self.recur_dict = {}
@@ -379,7 +423,13 @@ def img_cache(self, cid):
if Path(output_file).is_file():
return 0
try:
- res = request.get(url, headers=self.index_headers, timeout=10, proxies=self.Proxy)
+ res = request.get(
+ url,
+ headers=self.index_headers,
+ timeout=10,
+ proxies=self.Proxy,
+ auth=self.ProxyAuth
+ )
file = res.content
with open(output_file, 'wb') as f:
f.write(file)
diff --git a/BiliWorker/main.py b/BiliWorker/main.py
index 66f4a22..67baaf6 100644
--- a/BiliWorker/main.py
+++ b/BiliWorker/main.py
@@ -61,10 +61,16 @@ def __init__(self, args, model=0):
else:
self.index_headers["cookie"] = ""
self.second_headers["cookie"] = ""
+ # 使用代理
+ self.Proxy = None
if args["useProxy"]:
self.Proxy = args["Proxy"]
- else:
- self.Proxy = None
+ # 代理验证
+ self.ProxyAuth = None
+ if args["ProxyAuth"]["inuse"]:
+ from requests.auth import HTTPProxyAuth
+ self.ProxyAuth = HTTPProxyAuth(args['ProxyAuth']['usr'], args['ProxyAuth']['pwd'])
+
# 运行模式设置函数
def model_set(self, innum):
@@ -104,7 +110,14 @@ def ssADDRCheck(self, inurl):
checking2 = re.findall('/play/ep', inurl.split("?")[0], re.S)
try:
if checking1 != []:
- res = request.get(inurl, headers=self.index_headers, stream=False, timeout=10, proxies=self.Proxy)
+ res = request.get(
+ inurl,
+ headers=self.index_headers,
+ stream=False,
+ timeout=10,
+ proxies=self.Proxy,
+ auth=self.ProxyAuth
+ )
dec = res.content.decode('utf-8')
INITIAL_STATE = re.findall(self.re_INITIAL_STATE, dec, re.S)
temp = json.loads(INITIAL_STATE[0])
@@ -123,7 +136,14 @@ def search_preinfo(self, index_url):
# Get Html Information
index_url = self.ssADDRCheck(index_url)
try:
- res = request.get(index_url[1], headers=self.index_headers, stream=False, timeout=10, proxies=self.Proxy)
+ res = request.get(
+ index_url[1],
+ headers=self.index_headers,
+ stream=False,
+ timeout=10,
+ proxies=self.Proxy,
+ auth=self.ProxyAuth
+ )
dec = res.content.decode('utf-8')
except:
print("初始化信息获取失败。")
@@ -204,7 +224,14 @@ def tmp_dffss(self, re_GET):
# Search the list of Video download address.
def search_videoList(self, index_url):
try:
- res = request.get(index_url, headers=self.index_headers, stream=False, timeout=10, proxies=self.Proxy)
+ res = request.get(
+ index_url,
+ headers=self.index_headers,
+ stream=False,
+ timeout=10,
+ proxies=self.Proxy,
+ auth=self.ProxyAuth
+ )
dec = res.content.decode('utf-8')
except:
return 0, {}
@@ -289,8 +316,14 @@ def d_processor(self, url_list, output_dir, output_file, dest):
self.business_info.emit('使用线路:{}'.format(line.split("?")[0]))
try:
# video stream length sniffing
- video_bytes = request.get(line, headers=self.second_headers, stream=False, timeout=(5, 10),
- proxies=self.Proxy)
+ video_bytes = request.get(
+ line,
+ headers=self.second_headers,
+ stream=False,
+ timeout=(5, 10),
+ proxies=self.Proxy,
+ auth=self.ProxyAuth
+ )
vc_range = video_bytes.headers['Content-Range'].split('/')[1]
self.business_info.emit("获取{}流范围为:{}".format(dest, vc_range))
self.business_info.emit('{} 文件大小:{} MB'.format(dest, round(float(vc_range) / 1024 / 1024), 4))
@@ -300,8 +333,14 @@ def d_processor(self, url_list, output_dir, output_file, dest):
while err <= self.set_err:
try:
self.second_headers['range'] = 'bytes=' + str(proc["Now"]) + '-' + vc_range
- m4sv_bytes = request.get(line, headers=self.second_headers, stream=True, timeout=10,
- proxies=self.Proxy)
+ m4sv_bytes = request.get(
+ line,
+ headers=self.second_headers,
+ stream=True,
+ timeout=10,
+ proxies=self.Proxy,
+ auth=self.ProxyAuth
+ )
self.progr_bar.emit(proc)
if not os.path.exists(output_dir):
os.makedirs(output_dir)
@@ -648,7 +687,14 @@ def Set_Structure(self, now_interact, iv_structure):
# Interactive video initial information
def Get_Init_Info(self, url):
try:
- res = request.get(url, headers=self.index_headers, stream=False, timeout=10, proxies=self.Proxy)
+ res = request.get(
+ url,
+ headers=self.index_headers,
+ stream=False,
+ timeout=10,
+ proxies=self.Proxy,
+ auth=self.ProxyAuth
+ )
dec = res.content.decode('utf-8')
playinfo = re.findall(self.re_playinfo, dec, re.S)
INITIAL_STATE = re.findall(self.re_INITIAL_STATE, dec, re.S)
@@ -672,7 +718,14 @@ def isInteract(self):
'bvid': self.now_interact["bvid"],
}
try:
- res = request.get(make_API, headers=self.index_headers, params=param, timeout=10, proxies=self.Proxy)
+ res = request.get(
+ make_API,
+ headers=self.index_headers,
+ params=param,
+ timeout=10,
+ proxies=self.Proxy,
+ auth=self.ProxyAuth
+ )
des = json.loads(res.content.decode('utf-8'))
if "interaction" not in des["data"]:
raise Exception("非交互视频")
@@ -696,7 +749,14 @@ def down_list_make(self, cid_num):
'session': self.now_interact["session"]
}
try:
- des = request.get(make_API, headers=self.index_headers, params=param, timeout=10, proxies=self.Proxy)
+ des = request.get(
+ make_API,
+ headers=self.index_headers,
+ params=param,
+ timeout=10,
+ proxies=self.Proxy,
+ auth=self.ProxyAuth
+ )
playinfo = json.loads(des.content.decode('utf-8'))
except Exception as e:
return False, str(e)
@@ -768,7 +828,14 @@ def AuList_Maker(self, sid, modeNUM):
if modeNUM == 1:
try:
makeURL = "https://www.bilibili.com/audio/music-service-c/web/song/info?sid=" + sid
- res = request.get(makeURL, headers=self.index_headers, stream=False, timeout=10, proxies=self.Proxy)
+ res = request.get(
+ makeURL,
+ headers=self.index_headers,
+ stream=False,
+ timeout=10,
+ proxies=self.Proxy,
+ auth=self.ProxyAuth
+ )
des = res.content.decode('utf-8')
auinfo = json.loads(des)["data"]
temp = {
@@ -789,7 +856,14 @@ def AuList_Maker(self, sid, modeNUM):
while True:
makeURL = "https://www.bilibili.com/audio/music-service-c/web/song/of-menu?sid=" + sid + "&pn=" + str(
pn) + "&ps=30"
- res = request.get(makeURL, headers=self.index_headers, stream=False, timeout=10, proxies=self.Proxy)
+ res = request.get(
+ makeURL,
+ headers=self.index_headers,
+ stream=False,
+ timeout=10,
+ proxies=self.Proxy,
+ auth=self.ProxyAuth
+ )
des = res.content.decode('utf-8')
mu_dic = json.loads(des)["data"]
for sp in mu_dic["data"]:
@@ -839,7 +913,14 @@ def Audio_Show(self):
# 获取单个音频下载地址
def Audio_getDownloadList(self, sid):
make_url = "https://www.bilibili.com/audio/music-service-c/web/url?sid=" + sid
- res = request.get(make_url, headers=self.index_headers, stream=False, timeout=10, proxies=self.Proxy)
+ res = request.get(
+ make_url,
+ headers=self.index_headers,
+ stream=False,
+ timeout=10,
+ proxies=self.Proxy,
+ auth=self.ProxyAuth
+ )
des = res.content.decode('utf-8')
au_list = json.loads(des)["data"]["cdns"]
return au_list
@@ -847,7 +928,13 @@ def Audio_getDownloadList(self, sid):
# 附带资源下载
def simple_downloader(self, url, output_dir, output_file):
try:
- res = request.get(url, headers=self.index_headers, timeout=10, proxies=self.Proxy)
+ res = request.get(
+ url,
+ headers=self.index_headers,
+ timeout=10,
+ proxies=self.Proxy,
+ auth=self.ProxyAuth
+ )
file = res.content
if not os.path.exists(output_dir):
os.makedirs(output_dir)
diff --git a/UI/bilidsetting.py b/UI/bilidsetting.py
index 33ebe5b..60bec6b 100644
--- a/UI/bilidsetting.py
+++ b/UI/bilidsetting.py
@@ -290,7 +290,9 @@ def setupUi(self, Form):
self.cb_useAuth.setGeometry(QRect(120, 70, 151, 31))
self.le_AuthUsr = QLineEdit(self.groupBox_2)
self.le_AuthUsr.setObjectName(u"le_AuthUsr")
+ self.le_AuthUsr.setEnabled(False)
self.le_AuthUsr.setGeometry(QRect(90, 110, 151, 31))
+ self.le_AuthUsr.setAlignment(Qt.AlignCenter)
self.label_5 = QLabel(self.groupBox_2)
self.label_5.setObjectName(u"label_5")
self.label_5.setGeometry(QRect(20, 110, 72, 31))
@@ -299,7 +301,10 @@ def setupUi(self, Form):
self.label_6.setGeometry(QRect(260, 110, 31, 31))
self.le_AuthPwd = QLineEdit(self.groupBox_2)
self.le_AuthPwd.setObjectName(u"le_AuthPwd")
+ self.le_AuthPwd.setEnabled(False)
self.le_AuthPwd.setGeometry(QRect(300, 110, 151, 31))
+ self.le_AuthPwd.setEchoMode(QLineEdit.Password)
+ self.le_AuthPwd.setAlignment(Qt.AlignCenter)
self.btn_editconfig = QPushButton(self.mainwidget)
self.btn_editconfig.setObjectName(u"btn_editconfig")
self.btn_editconfig.setGeometry(QRect(200, 480, 141, 31))
diff --git a/UI/bilidsetting.ui b/UI/bilidsetting.ui
index ccc475a..880016f 100644
--- a/UI/bilidsetting.ui
+++ b/UI/bilidsetting.ui
@@ -466,6 +466,9 @@ QLineEdit{
+
+ false
+
90
@@ -474,6 +477,9 @@ QLineEdit{
31
+
+ Qt::AlignCenter
+
输入登录用户名
@@ -505,6 +511,9 @@ QLineEdit{
+
+ false
+
300
@@ -513,6 +522,12 @@ QLineEdit{
31
+
+ QLineEdit::Password
+
+
+ Qt::AlignCenter
+
输入登录验证密码
diff --git a/etc/__init__.py b/etc/__init__.py
index 21ba51f..5e2f28e 100644
--- a/etc/__init__.py
+++ b/etc/__init__.py
@@ -1,7 +1,7 @@
import os, sys
# 发布版本信息
-Release_INFO = ["V1.6.20220605", "2022/06/05"]
+Release_INFO = ["V1.6.20220610", "2022/06/10"]
# 保存个人信息模板初始化
indict = {
@@ -21,6 +21,11 @@
"Proxy": {
'http': '',
'https': '',
+ },
+ "ProxyAuth": {
+ 'inuse': False,
+ 'usr': '',
+ 'pwd': '',
}
}