| | |
| | | await page.locator(".switch-roll").first.click() |
| | | await asyncio.sleep(1) |
| | | |
| | | publish_date = self.publish_datetime.strftime("%Y-%m-%d") |
| | | publish_month = self.publish_datetime.strftime("%Y年%m月") |
| | | exact_day = str(self.publish_datetime.day) |
| | | scheduled_date = self.scheduled_time.strftime("%Y-%m-%d") |
| | | scheduled_month = self.scheduled_time.strftime("%Y年%m月") |
| | | exact_day = str(self.scheduled_time.day) |
| | | |
| | | await page.locator(".date-show-icon").first.click() |
| | | await asyncio.sleep(1) |
| | | if publish_month != await page.locator("p.date-picker-nav-title").text_content(): |
| | | if scheduled_month != await page.locator("p.date-picker-nav-title").text_content(): |
| | | await page.locator(".next-btn-day.icon-sprite.icon-sprite-ic_into").click() |
| | | await asyncio.sleep(1) |
| | | await page.get_by_text(exact_day, exact=True).click() |
| | | await asyncio.sleep(1) |
| | | |
| | | exact_hour = f"{self.publish_datetime.hour:02d}" |
| | | exact_min = f"{self.publish_datetime.minute:02d}" |
| | | exact_hour = f"{self.scheduled_time.hour:02d}" |
| | | exact_min = f"{self.scheduled_time.minute:02d}" |
| | | await page.locator(".date-picker-timer > .date-show-icon").click() |
| | | await asyncio.sleep(0.5) |
| | | await page.locator('div.time-picker-panel-select-wrp').nth(0).locator(f'span:nth-child({self.publish_datetime.hour + 1})').click() |
| | | minute_index = ((self.publish_datetime.minute // 5) * 5 // 5) + 1 # 序号从1开始 |
| | | await page.locator('div.time-picker-panel-select-wrp').nth(0).locator(f'span:nth-child({self.scheduled_time.hour + 1})').click() |
| | | minute_index = ((self.scheduled_time.minute // 5) * 5 // 5) + 1 # 序号从1开始 |
| | | await page.locator('div.time-picker-panel-select-wrp').nth(1).locator(f'span:nth-child({minute_index})').click() |
| | | |
| | | await asyncio.sleep(1) |
| | |
| | | async with page.expect_file_chooser() as fc_info: |
| | | await upload_div.click() |
| | | file_chooser = await fc_info.value |
| | | await file_chooser.set_files(self.path_video) |
| | | await file_chooser.set_files(self.path_media) |
| | | await asyncio.sleep(2) |
| | | |
| | | max_retries = 60 # 设置最大重试次数,最大等待时间为 2 分钟 |
| | |
| | | await page.get_by_title(self.category).click() |
| | | |
| | | # 定时发布 |
| | | if self.publish_datetime != 0: |
| | | if self.scheduled_time != 0: |
| | | await self.set_schedule_time(page) |
| | | |
| | | # 判断视频是否发布成功 |
| | |
| | | |
| | | return True |
| | | except Exception as e: |
| | | self.logger.error(f"{self.user} upload video {self.path_video} fails, error is :{e}") |
| | | self.logger.error(f"{self.user} upload video {self.path_media} fails, error is :{e}") |
| | | return False |