diff --git a/package.json b/package.json index d2f90ff..0b8f879 100644 --- a/package.json +++ b/package.json @@ -959,6 +959,7 @@ "level": 2, "v2": true, "history": { + "v1.7.3": "修复检测登录的元素", "v1.7.2": "||wan参数细分,修复使用||wan时立即检测一次实际不生效,修复v1第三方备用通知可能无效,调整验证码获取", "v1.7.1": "允许使用'||wan2'选项及无法使用'立即检测一次'", "v1.7.0": "使用第三方通知时可IP变动后通知,拟支持多网络出口检查。", diff --git a/plugins/dynamicwechat/__init__.py b/plugins/dynamicwechat/__init__.py index 43a8c06..4b755b1 100644 --- a/plugins/dynamicwechat/__init__.py +++ b/plugins/dynamicwechat/__init__.py @@ -31,7 +31,7 @@ class DynamicWeChat(_PluginBase): # 插件图标 plugin_icon = "Wecom_A.png" # 插件版本 - plugin_version = "1.7.2" + plugin_version = "1.7.3" # 插件作者 plugin_author = "RamenRa" # 作者主页 @@ -730,19 +730,31 @@ class DynamicWeChat(_PluginBase): # 检查是否需要进行短信验证 if task != 'refresh_cookie': logger.info("检查登录状态...") - try: - # 先检查登录成功后的页面状态 - success_element = page.wait_for_selector('#check_corp_info', timeout=5000) # 检查登录成功的元素 - if success_element: - if task != 'refresh_cookie': - logger.info("登录成功!") - return True - except Exception as e: - logger.debug(str(e)) - pass + + success_selectors = [ + "//div[contains(@class, 'js_show_ipConfig_dialog')]//a[contains(@class, '_mod_card_operationLink') and text()='配置']", + '#_hmt_click > div.index_colRight > div > div.index_info > div > a', + '/html/body/div/section[3]/div[1]/main/div/div/div[2]/div/div[1]/div/a', + '#_hmt_click > div.index_colLeft > div.index_greeting.index_explore_text > div:nth-child(1)' + ] try: - # 在这里使用更安全的方式来检查元素是否存在 + for selector in success_selectors: + try: + # 先检查登录成功后的页面状态 + success_element = page.wait_for_selector(selector, timeout=3000) # 检查登录成功的元素 + if success_element: + if task != 'refresh_cookie': + logger.info("登录成功!") + return True + except Exception as e: + logger.debug(str(e)) + pass + except Exception as e: + logger.debug(f"登录检查异常: {e}") + + try: + # 检查是否进入验证码界面 captcha_panel = page.wait_for_selector('.receive_captcha_panel', timeout=5000) # 检查验证码面板 if captcha_panel: # 出现了短信验证界面 if task == 'local_scanning': @@ -758,20 +770,24 @@ class DynamicWeChat(_PluginBase): confirm_button = page.wait_for_selector('.confirm_btn', timeout=5000) # 获取确认按钮 confirm_button.click() # 点击确认 time.sleep(3) # 等待处理 - # 等待登录成功的元素出现 - success_element = page.wait_for_selector('#check_corp_info', timeout=5000) - if success_element: - self._verification_code = None - logger.info("验证码登录成功!") - return True + + # 再次检查登录状态 + for selector in success_selectors: + try: + success_element = page.wait_for_selector(selector, timeout=3000) + if success_element: + self._verification_code = None + logger.info("验证码登录成功!") + return True + except: + continue else: logger.error("未收到短信验证码") return False except Exception as e: # logger.debug(str(e)) # 基于bug运行,请不要将错误输出到日志 # try: # 没有登录成功,也没有短信验证码 - if self.find_qrc( - page) and not task == 'refresh_cookie' and not task == 'local_scanning': # 延长任务找到的二维码不会被发送,所以不算用户没有扫码 + if self.find_qrc(page) and task not in ['refresh_cookie', 'local_scanning']: # 延长任务找到的二维码不会被发送,所以不算用户没有扫码 logger.warning(f"用户没有扫描二维码") return False @@ -801,7 +817,7 @@ class DynamicWeChat(_PluginBase): app_urls = [f"{bash_url}{app_id.strip()}" for app_id in id_list] for app_url in app_urls: app_id = app_url.split("/")[-1] - if app_id.startswith("100000") and len(app_id) == 6: + if app_id.startswith("100000") and len(app_id) == 7: self._ip_changed = False logger.warning(f"请根据 https://github.com/RamenRa/MoviePilot-Plugins 的说明进行配置应用ID") return