Skip to content

Commit

Permalink
fix(javdb): cookie (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
sqzw-x committed Mar 7, 2024
1 parent 65c3382 commit 04181ba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/controllers/main_window/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -2244,11 +2244,11 @@ def _check_javdb_cookie(self):
return tips
# self.Ui.pushButton_check_javdb_cookie.setEnabled(False)
tips = '✅ 连接正常!'
new_cookie = {'cookie': input_cookie}
cookies = config.javdb_cookie
header = {'cookie': input_cookie}
cookies = config.javdb
javdb_url = getattr(config, 'javdb_website', 'https://javdb.com') + '/v/D16Q5?locale=zh'
try:
result, response = scraper_html(javdb_url, cookies=new_cookie)
result, response = scraper_html(javdb_url, headers=header)
if not result:
if 'Cookie' in response:
if cookies != input_cookie:
Expand Down
8 changes: 1 addition & 7 deletions src/models/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

@singleton
class MDCxConfig(GeneratedConfig, ManualConfig):

mark_file_name = 'MDCx.config'

def __init__(self):
Expand All @@ -36,7 +35,7 @@ def path(self, path):
@path.getter
def path(self):
return self._path

def get_mac_default_config_folder(self):
"""
获取macOS下默认的配置文件夹路径
Expand Down Expand Up @@ -346,11 +345,6 @@ def update_config(self):
temp_l, temp_m, temp_n),
}

# 获取javdb_cookie
self.javdb_cookie = {'cookie': self.javdb} if self.javdb else None

self.javbus_cookie = {'cookie': self.javbus} if self.javbus else None

# 去掉^符号!!!
self.cnword_style = self.cnword_style.strip('^')

Expand Down
12 changes: 5 additions & 7 deletions src/models/crawlers/javdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,8 @@ def main(number, appoint_url='', log_info='', req_web='', language='jp', org_lan
req_web += '-> %s' % website_name

javdb_time = config.javdb_time
cookies = config.javdb_cookie
javdb_url = 'https://javdb.com'
if hasattr(config, 'javdb_website'):
javdb_url = config.javdb_website
header = {'cookie': config.javdb}
javdb_url = getattr(config, 'javdb_website', 'https://javdb.com')
if appoint_url and '?locale' not in appoint_url:
appoint_url += '?locale=zh'
real_url = appoint_url
Expand Down Expand Up @@ -230,7 +228,7 @@ def main(number, appoint_url='', log_info='', req_web='', language='jp', org_lan
log_info += web_info + debug_info

# 先使用scraper方法请求,失败时再使用get请求
result, html_search = curl_html(url_search, cookies=cookies)
result, html_search = curl_html(url_search, headers=header)
if not result:
# 判断返回内容是否有问题
if html_search.startswith('403'):
Expand Down Expand Up @@ -272,7 +270,7 @@ def main(number, appoint_url='', log_info='', req_web='', language='jp', org_lan
debug_info = '番号地址: %s ' % real_url
log_info += web_info + debug_info

result, html_info = curl_html(real_url, cookies=cookies)
result, html_info = curl_html(real_url, headers=header)
if not result:
debug_info = '请求错误: %s' % html_info
log_info += web_info + debug_info
Expand All @@ -294,7 +292,7 @@ def main(number, appoint_url='', log_info='', req_web='', language='jp', org_lan
if "/password_resets" in html_info:
debug_info = f'此內容需要登入才能查看或操作!点击 {real_url} 查看详情!'
log_info += web_info + debug_info
if cookies and cookies.get('cookie'):
if config.javdb:
debug_info = 'Cookie 已失效,请到设置中更新 javdb Cookie!'
log_info += web_info + debug_info
else:
Expand Down

0 comments on commit 04181ba

Please sign in to comment.