wangzhibo
2025-07-30 25087cbe79c8c4992551477d55d9db8bbea2202e
auto_media_publisher/uploaders/uploader_tiktok.py
@@ -31,7 +31,7 @@
        n_calendar_month = datetime.strptime(calendar_month, '%B').month
        schedule_month = self.publish_datetime.month
        schedule_month = self.scheduled_time.month
        if n_calendar_month != schedule_month:
            if n_calendar_month < schedule_month:
@@ -47,14 +47,14 @@
        for i in range(valid_days):
            day_element = valid_days_locator.nth(i)
            text = await day_element.inner_text()
            if text.strip() == str(self.publish_datetime.day):
            if text.strip() == str(self.scheduled_time.day):
                await day_element.click()
                break
        # time set
        await scheduled_picker.locator('div.TUXInputBox').nth(0).click()
        hour_str = self.publish_datetime.strftime("%H")
        correct_minute = int(self.publish_datetime.minute / 5)
        hour_str = self.scheduled_time.strftime("%H")
        correct_minute = int(self.scheduled_time.minute / 5)
        minute_str = f"{correct_minute:02d}"
        hour_selector = f"span.tiktok-timepicker-left:has-text('{hour_str}')"
@@ -77,7 +77,7 @@
        async with page.expect_file_chooser() as fc_info:
            await select_file_button.click()
        file_chooser = await fc_info.value
        await file_chooser.set_files(self.path_video)
        await file_chooser.set_files(self.path_media)
    async def add_title_tags(self, page):
@@ -196,7 +196,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 self.add_title_tags(page)
            # detect upload status
@@ -205,7 +205,7 @@
                self.logger.info(f'[+] Uploading thumbnail file {self.title}.png')
                await self.upload_thumbnails(page)
            if self.publish_datetime != 0:
            if self.scheduled_time != 0:
                await self.set_schedule_time(page)
            await self.click_publish(page)
@@ -216,5 +216,5 @@
          
            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