wangzhibo
2025-07-30 25087cbe79c8c4992551477d55d9db8bbea2202e
auto_media_publisher/uploaders/uploader_xiaohongshu.py
@@ -12,13 +12,13 @@
    async def set_schedule_time(self, page):
        try:
            
            publish_date_hour = self.publish_datetime.strftime("%Y-%m-%d %H:%M")
            scheduled_date_hour = self.scheduled_time.strftime("%Y-%m-%d %H:%M")
            await page.locator("label").filter(has_text="定时发布").locator("span").nth(1).click()
            await asyncio.sleep(1)
            await page.get_by_placeholder("选择日期和时间").click()
            await asyncio.sleep(1)
            await page.keyboard.press("Control+KeyA")
            await page.keyboard.type(str(publish_date_hour))
            await page.keyboard.type(str(scheduled_date_hour))
            await page.keyboard.press("Enter")
            await asyncio.sleep(1)
        except Exception as e:
@@ -64,7 +64,7 @@
            async with page.expect_file_chooser() as fc_info:
                await upload_button.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)
            # wait for video upload finish
@@ -107,7 +107,7 @@
                await self.set_cover_image(page)          
        
            # 定时任务
            if self.publish_datetime != 0:
            if self.scheduled_time != 0:
                self.logger.info("正在设置 定时发布 时间...")
                await self.set_schedule_time(page)
@@ -136,5 +136,5 @@
            await asyncio.sleep(3)
            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