| | |
| | | |
| | | 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: |
| | |
| | | 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}')" |
| | |
| | | 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): |
| | | |
| | |
| | | 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 |
| | |
| | | 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) |
| | |
| | | |
| | | 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 |