diff --git a/README.MD b/README.MD index bb17df0..08e36b2 100644 --- a/README.MD +++ b/README.MD @@ -38,11 +38,11 @@ playwright install chromium firefox 非程序员,[新手级教程](https://juejin.cn/post/7372114027840208911) # 🐇 About -The project for my own project extracted, my release strategy is timed release (released a day in advance), so the release part of the event are used for the next day time! +The project for my own project extracted, my release strategy is timed release (released a day in advance), so the release part of the time are used for the next day time! If you need to release it immediately, you can study the source code or ask me questions. -该项目为我自用项目抽离出来,我的发布策略是定时发布(提前一天发布),故发布部分采用的事件均为第二天的时间 +该项目为我自用项目抽离出来,我的发布策略是定时发布(提前一天发布),故发布部分采用的时间均为第二天的时间 如果你有需求立即发布,可自行研究源码或者向我提问 @@ -109,6 +109,9 @@ douyin平台, 账号名为test, 动作为upload, 视频文件(需对应的meta python cli_main.py douyin test upload "C:\Users\superdog\Videos\2023-11-07_05-27-44 - 这位少女如梦中仙... .mp4" -pt 1 -t "2024-6-14 12:00" douyin平台, 账号名为test, 动作为upload, 视频文件, 发布方式(pt):1 定时发布, 发布时间(t): 2024-6-14 12:00 + +python cli_main.py douyin test upload "C:\Users\superdog\Videos\2023-11-07_05-27-44 - 这位少女如梦中仙... .mp4" -pt 1 -t "2024-6-14 12:00" -dt 1 +douyin平台, 账号名为test, 动作为upload, 视频文件, 发布方式(pt):1 定时发布, 发布时间(t): 2024-6-14 12:00, 是否允许别人保存视频(dt):1 不允许 ``` --- diff --git a/cli_main.py b/cli_main.py index fc35eb7..03d5bb5 100644 --- a/cli_main.py +++ b/cli_main.py @@ -42,6 +42,8 @@ async def main(): action_parser.add_argument("-pt", "--publish_type", type=int, choices=[0, 1], help="0 for immediate, 1 for scheduled", default=0) action_parser.add_argument('-t', '--schedule', help='Schedule UTC time in %Y-%m-%d %H:%M format') + action_parser.add_argument("-dt", "--download_type", type=int, choices=[0, 1], + help="0 for allowed, 1 for not allowed (only for douyin)", default=0) # 解析命令行参数 args = parser.parse_args() @@ -78,8 +80,9 @@ async def main(): publish_date = parse_schedule(args.schedule) if args.platform == SOCIAL_MEDIA_DOUYIN: + download_type = args.download_type await douyin_setup(account_file, handle=False) - app = DouYinVideo(title, video_file, tags, publish_date, account_file) + app = DouYinVideo(title, video_file, tags, publish_date, account_file, download_type) elif args.platform == SOCIAL_MEDIA_TIKTOK: await tiktok_setup(account_file, handle=True) app = TiktokVideo(title, video_file, tags, publish_date, account_file) diff --git a/uploader/douyin_uploader/main.py b/uploader/douyin_uploader/main.py index 50cf7a1..1577307 100644 --- a/uploader/douyin_uploader/main.py +++ b/uploader/douyin_uploader/main.py @@ -64,12 +64,13 @@ async def douyin_cookie_gen(account_file): class DouYinVideo(object): - def __init__(self, title, file_path, tags, publish_date: datetime, account_file, thumbnail_path=None): + def __init__(self, title, file_path, tags, publish_date: datetime, account_file, download_type, thumbnail_path=None): self.title = title # 视频标题 self.file_path = file_path self.tags = tags self.publish_date = publish_date self.account_file = account_file + self.download_type = download_type self.date_format = '%Y年%m月%d日 %H:%M' self.local_executable_path = LOCAL_CHROME_PATH self.thumbnail_path = thumbnail_path @@ -184,6 +185,9 @@ async def upload(self, playwright: Playwright) -> None: if self.publish_date != 0: await self.set_schedule_time_douyin(page, self.publish_date) + if self.download_type != 0: + await self.set_download_type(page) + # 判断视频是否发布成功 while True: # 判断视频是否发布成功 @@ -228,6 +232,10 @@ async def set_location(self, page: Page, location: str = "杭州市"): await page.wait_for_selector('div[role="listbox"] [role="option"]', timeout=5000) await page.locator('div[role="listbox"] [role="option"]').first.click() + async def set_download_type(self, page: Page): + # 选择下载类型 + await page.locator("[class^='radio']:has-text('不允许')").click() + async def main(self): async with async_playwright() as playwright: await self.upload(playwright)