Skip to content

Commit

Permalink
fix: 合并冲突
Browse files Browse the repository at this point in the history
  • Loading branch information
linyuan0213 committed Apr 28, 2023
2 parents 56be5c9 + 0e2e41d commit b923925
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 28 deletions.
4 changes: 2 additions & 2 deletions app/downloader/client/qbittorrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __login_qbittorrent(self):
username=self.username,
password=self.password,
VERIFY_WEBUI_CERTIFICATE=False,
REQUESTS_ARGS={'timeout': (10, 30)})
REQUESTS_ARGS={'timeout': (15, 60)})
try:
qbt.auth_log_in()
self.ver = qbt.app_version()
Expand Down Expand Up @@ -580,7 +580,7 @@ def get_download_dirs(self):
return []
ret_dirs = []
try:
categories = self.qbc.torrents_categories(requests_args={'timeout': (5, 10)}) or {}
categories = self.qbc.torrents_categories(requests_args={'timeout': (10, 30)}) or {}
except Exception as err:
ExceptionUtils.exception_traceback(err)
return []
Expand Down
4 changes: 2 additions & 2 deletions app/downloader/client/transmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __login_transmission(self):
port=self.port,
username=self.username,
password=self.password,
timeout=30)
timeout=60)
return trt
except Exception as err:
ExceptionUtils.exception_traceback(err)
Expand Down Expand Up @@ -482,7 +482,7 @@ def get_download_dirs(self):
if not self.trc:
return []
try:
return [self.trc.get_session(timeout=10).download_dir]
return [self.trc.get_session(timeout=30).download_dir]
except Exception as err:
ExceptionUtils.exception_traceback(err)
return []
Expand Down
10 changes: 6 additions & 4 deletions app/media/meta/customization.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ def match(self, title=None):
if not self.customization:
return ""
customization_re = re.compile(r"%s" % self.customization)
# 处理重复多次的情况,保留先后顺序
unique_customization = []
# 处理重复多次的情况,保留先后顺序(按添加自定义占位符的顺序)
unique_customization = {}
for item in re.findall(customization_re, title):
if item not in unique_customization:
unique_customization.append(item)
for i in range(len(item)):
if item[i] and unique_customization.get(item[i]) is None:
unique_customization[item[i]] = i
unique_customization = list(dict(sorted(unique_customization.items(), key=lambda x: x[1])).keys())
separator = self.custom_separator or "@"
return separator.join(unique_customization)

Expand Down
22 changes: 20 additions & 2 deletions app/plugins/modules/_autosignin/hdchina.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,37 @@ def signin(self, site_info: dict):
ua = site_info.get("ua")
proxy = Config().get_proxies() if site_info.get("proxy") else None

# 尝试解决瓷器cookie每天签到后过期,只保留hdchina=部分
cookie = ""
# 按照分号进行字符串拆分
sub_strs = site_cookie.split(";")
# 遍历每个子字符串
for sub_str in sub_strs:
if "hdchina=" in sub_str:
# 如果子字符串包含"hdchina=",则保留该子字符串
cookie += sub_str + ";"

if "hdchina=" not in cookie:
self.error(f"签到失败,cookie失效")
return False, f'【{site}】签到失败,cookie失效'

site_cookie = cookie
# 获取页面html
html_res = RequestUtils(cookies=site_cookie,
headers=ua,
proxies=proxy
).get_res(url="https://hdchina.org/")
).get_res(url="https://hdchina.org/index.php")
if not html_res or html_res.status_code != 200:
self.error(f"签到失败,请检查站点连通性")
return False, f'【{site}】签到失败,请检查站点连通性'

if "login.php" in html_res.text:
if "login.php" in html_res.text or "阻断页面" in html_res.text:
self.error(f"签到失败,cookie失效")
return False, f'【{site}】签到失败,cookie失效'

# 获取新返回的cookie进行签到
site_cookie = ';'.join(['{}={}'.format(k, v) for k, v in html_res.cookies.get_dict().items()])

# 判断是否已签到
html_res.encoding = "utf-8"
sign_status = self.sign_in_result(html_res=html_res.text,
Expand Down
1 change: 1 addition & 0 deletions app/plugins/modules/_autosignin/pterclub.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def signin(self, site_info: dict):
return False, f'【{site}】签到失败,请检查cookie是否失效'

sign_dict = json.loads(sign_res.text)
self.debug(f"签到接口返回参数 {sign_dict}")
if sign_dict['status'] == 1:
# {"status":"1","data":" (签到已成功300)","message":"<p>这是您的第<b>237</b>次签到,
# 已连续签到<b>237</b>天。</p><p>本次签到获得<b>300</b>克猫粮。</p>"}
Expand Down
7 changes: 7 additions & 0 deletions app/plugins/modules/_autosignin/u2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import random
import re
import datetime

from lxml import etree

Expand Down Expand Up @@ -45,6 +46,12 @@ def signin(self, site_info: dict):
ua = site_info.get("ua")
proxy = Config().get_proxies() if site_info.get("proxy") else None

now = datetime.datetime.now()
# 判断当前时间是否小于9点
if now.hour < 9:
self.error(f"签到失败,9点前不签到")
return False, f'【{site}】签到失败,9点前不签到'

# 获取页面html
html_res = RequestUtils(cookies=site_cookie,
headers=ua,
Expand Down
4 changes: 3 additions & 1 deletion app/plugins/modules/autobackup.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,12 @@ def __backup(self):

# 发送通知
if self._notify:
next_run_time = self._scheduler.get_jobs()[0].next_run_time.strftime('%Y-%m-%d %H:%M:%S')
self.send_message(title="【自动备份任务完成】",
text=f"创建备份{'成功' if zip_file else '失败'}\n"
f"清理备份数量 {del_cnt}\n"
f"剩余备份数量 {bk_cnt - del_cnt}")
f"剩余备份数量 {bk_cnt - del_cnt} \n"
f"下次备份时间: {next_run_time}")

def stop_service(self):
"""
Expand Down
3 changes: 3 additions & 0 deletions app/plugins/modules/autosignin.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,14 @@ def sign_in(self, event=None):

# 发送通知
if self._notify:
next_run_time = self._scheduler.get_jobs()[0].next_run_time.strftime('%Y-%m-%d %H:%M:%S')
# 签到汇总信息
self.send_message(title="【自动签到任务完成】",
text=f"本次签到数量: {len(sign_sites)} \n"
f"命中重试数量: {len(retry_sites) if self._retry_keyword else 0} \n"
f"强制签到数量: {len(self._special_sites)} \n"
f"下次签到数量: {len(set(retry_sites + self._special_sites))} \n"
f"下次签到时间: {next_run_time} \n"
f"详见签到消息")
else:
self.error("站点签到任务失败!")
Expand Down
11 changes: 4 additions & 7 deletions app/plugins/modules/customization.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def get_fields():
{
'title': '自定义分隔符',
'required': "",
'tooltip': '当匹配到多个结果时,使用此分隔符进行分隔,留空使用@;如名称中识别出A和B,分隔符为@,则结果为A@B',
'tooltip': '当匹配到多个结果时,使用此分隔符进行分隔,留空使用@;如名称中识别出A和B,分隔符为@,则结果为A@B,按添加自定义占位符的顺序',
'type': 'text',
'content': [
{
Expand All @@ -77,15 +77,12 @@ def init_config(self, config=None):
customization = config.get('customization')
custom_separator = config.get('separator')
if customization:
if customization.startswith(';'):
customization = customization[1:]
if customization.endswith(';'):
customization = customization[:-1]
customization = customization.replace(";", "|").replace("\n", "|")
customization = customization.replace("\n", ";").strip(";").split(";")
customization = "|".join([f"({item})" for item in customization])
if customization:
self.info("自定义占位符已加载")
if custom_separator:
self.info(f"自定义分隔符{custom_separator}已加载")
self.info(f"自定义分隔符 {custom_separator} 已加载")
self._customization_matcher.update_custom(customization, custom_separator)
self._customization = customization
self._custom_separator = custom_separator
Expand Down
2 changes: 1 addition & 1 deletion app/plugins/modules/customreleasegroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def init_config(self, config=None):
if custom_release_groups:
self.info("自定义制作组/字幕组已加载")
if custom_separator:
self.info(f"自定义分隔符{custom_separator}已加载")
self.info(f"自定义分隔符 {custom_separator} 已加载")
self._release_groups_matcher.update_custom(custom_release_groups, custom_separator)
self._custom_release_groups = custom_release_groups
self._custom_separator = custom_separator
Expand Down
3 changes: 3 additions & 0 deletions app/plugins/modules/iyuuautoseed.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,9 @@ def __download_torrent(self, seed, downloader, save_path):
self.fail += 1
self.cached += 1
return False
# 强制使用Https
if not torrent_url.startswith("https://"):
torrent_url = torrent_url.replace("http://", "https://")
meta_info = MetaInfo(title="IYUU自动辅种")
meta_info.set_torrent_info(site=site_info.get("name"),
enclosure=torrent_url)
Expand Down
Binary file modified config/sites.dat
Binary file not shown.
2 changes: 1 addition & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,5 @@ def traystart():
# 初始化浏览器驱动
init_chrome()

# gunicorn 启动
# Flask启动
App.run(**get_run_config(is_windows_exe))
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
APP_VERSION = 'v3.2.0'
APP_VERSION = 'v3.2.1'
9 changes: 8 additions & 1 deletion web/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -2090,6 +2090,7 @@ def mediainfo_dict(media_info):
"effect": media_info.resource_effect,
"pix": media_info.resource_pix,
"team": media_info.resource_team,
"customization": media_info.customization,
"video_codec": media_info.video_encode,
"audio_codec": media_info.audio_encode,
"org_string": media_info.org_string,
Expand Down Expand Up @@ -5161,4 +5162,10 @@ def get_commands(self):
"""
获取命令列表
"""
return [{"id": cid, "name": cmd.get("desc")} for cid, cmd in self._commands.items()]
return [{
"id": cid,
"name": cmd.get("desc")
} for cid, cmd in self._commands.items()] + [{
"id": item.get("cmd"),
"name": item.get("desc")
} for item in PluginManager().get_plugin_commands()]
1 change: 0 additions & 1 deletion web/backend/web_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import io
from functools import lru_cache

import cn2an
Expand Down
24 changes: 20 additions & 4 deletions web/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1656,17 +1656,27 @@ def logging_handler(ws):
"""
实时日志WebSocket
"""
source = ""
while True:
message = ws.receive()
_source = json.loads(message).get("source")
if not message:
continue
try:
_source = json.loads(message).get("source")
except Exception as err:
print(str(err))
continue
if _source != source:
log.LOG_INDEX = len(log.LOG_QUEUE)
source = _source
if log.LOG_INDEX > 0:
logs = list(log.LOG_QUEUE)[-log.LOG_INDEX:]
log.LOG_INDEX = 0
if _source:
logs = [l for l in logs if l.get("source") == _source]
ws.send((json.dumps(logs)))
else:
ws.send(json.dumps([]))
logs = []
ws.send((json.dumps(logs)))


@Sock.route('/message')
Expand All @@ -1677,7 +1687,13 @@ def message_handler(ws):
"""
while True:
data = ws.receive()
msgbody = json.loads(data)
if not data:
continue
try:
msgbody = json.loads(data)
except Exception as err:
print(str(err))
continue
if msgbody.get("text"):
# 发送的消息
WebAction().handle_message_job(msg=msgbody.get("text"),
Expand Down
2 changes: 1 addition & 1 deletion web/static/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ function render_message(ret) {
</div>
<div class="col text-truncate">
<span class="text-wrap">${msg.title}</span>
<div class="d-block text-muted text-truncate mt-n1 text-wrap" title="${msg.content}">${msg.content}</div>
<div class="d-block text-muted text-truncate mt-n1 text-wrap">${msg.content}</div>
<div class="d-block text-muted text-truncate mt-n1 text-wrap">${msg.time}</div>
</div>
</div>
Expand Down

0 comments on commit b923925

Please sign in to comment.