| | |
| | | if not os.path.exists(self.cookie_path): |
| | | self.logger.info(f"{ self.cookie_path} DOES NOT exist. Please Try login first.") |
| | | return |
| | | self.context = await self.browser.new_context(storage_state=f"{self.cookie_path}", user_agent=DEFAULT_USER_AGENT) |
| | | self.context = await self.browser.new_context(storage_state=f"{self.cookie_path}", user_agent=DEFAULT_USER_AGENT,viewport={"width": 1920, "height": 1080}) |
| | | if os.path.exists(PLAYWRIGHT_STEALTH_JS_PATH): |
| | | await self.context.add_init_script(path=Path(PLAYWRIGHT_STEALTH_JS_PATH)) |
| | | await self.context.grant_permissions(['geolocation']) |
| | |
| | | await self._init_broswer_context() |
| | | for key, value in task_info.items(): |
| | | setattr(self, key, value) |
| | | # 尝试转换 publish_datetime 为 datetime 对象 |
| | | if hasattr(self, 'publish_datetime') and isinstance(self.publish_datetime, str): |
| | | # 尝试转换 scheduled_time 为 datetime 对象 |
| | | if hasattr(self, 'scheduled_time') and isinstance(self.scheduled_time, str): |
| | | try: |
| | | self.publish_datetime = datetime.strptime(self.publish_datetime, "%Y-%m-%d %H:%M") |
| | | self.scheduled_time = datetime.strptime(self.scheduled_time, "%Y-%m-%d %H:%M:%S") |
| | | except Exception as e: |
| | | self.logger.error(f"{self.user},{self.platform}发生错误,日期转换 {self.publish_datetime},{e}") |
| | | self.logger.error(f"{self.user},{self.platform}发生错误,日期转换 {self.scheduled_time},{e}") |
| | | try: |
| | | return await self._upload_core() |
| | | except Exception as e: |