diff --git a/myUtils/postVideo.py b/myUtils/postVideo.py
index e33f3d0..bd94e0b 100644
--- a/myUtils/postVideo.py
+++ b/myUtils/postVideo.py
@@ -10,7 +10,7 @@ from utils.constant import TencentZoneTypes
from utils.files_times import generate_schedule_time_next_day
-def post_video_tencent(title,files,tags,account_file,category=TencentZoneTypes.LIFESTYLE.value,enableTimer=False,videos_per_day = 1, daily_times=None,start_days = 0):
+def post_video_tencent(title,files,tags,account_file,category=TencentZoneTypes.LIFESTYLE.value,enableTimer=False,videos_per_day = 1, daily_times=None,start_days = 0, is_draft=False):
# 生成文件的完整路径
account_file = [Path(BASE_DIR / "cookiesFile" / file) for file in account_file]
files = [Path(BASE_DIR / "videoFile" / file) for file in files]
@@ -25,7 +25,7 @@ def post_video_tencent(title,files,tags,account_file,category=TencentZoneTypes.L
print(f"视频文件名:{file}")
print(f"标题:{title}")
print(f"Hashtag:{tags}")
- app = TencentVideo(title, str(file), tags, publish_datetimes[index], cookie, category)
+ app = TencentVideo(title, str(file), tags, publish_datetimes[index], cookie, category, is_draft)
asyncio.run(app.main(), debug=False)
diff --git a/sau_backend.py b/sau_backend.py
index ad82425..480bbfc 100644
--- a/sau_backend.py
+++ b/sau_backend.py
@@ -363,6 +363,7 @@ def postVideo():
productLink = data.get('productLink', '')
productTitle = data.get('productTitle', '')
thumbnail_path = data.get('thumbnail', '')
+ is_draft = data.get('isDraft', False) # 新增参数:是否保存为草稿
videos_per_day = data.get('videosPerDay')
daily_times = data.get('dailyTimes')
@@ -376,7 +377,7 @@ def postVideo():
start_days)
case 2:
post_video_tencent(title, file_list, tags, account_list, category, enableTimer, videos_per_day, daily_times,
- start_days)
+ start_days, is_draft)
case 3:
post_video_DouYin(title, file_list, tags, account_list, category, enableTimer, videos_per_day, daily_times,
start_days, thumbnail_path, productLink, productTitle)
diff --git a/sau_frontend/src/views/PublishCenter.vue b/sau_frontend/src/views/PublishCenter.vue
index 61d5cd1..f7824ca 100644
--- a/sau_frontend/src/views/PublishCenter.vue
+++ b/sau_frontend/src/views/PublishCenter.vue
@@ -402,6 +402,15 @@
/>
+
+
+
+
+
定时发布
@@ -534,7 +543,8 @@ const defaultTabInit = {
dailyTimes: ['10:00'], // 每天发布时间点列表
startDays: 0, // 从今天开始计算的发布天数,0表示明天,1表示后天
publishStatus: null, // 发布状态,包含message和type
- publishing: false // 发布状态,用于控制按钮loading效果
+ publishing: false, // 发布状态,用于控制按钮loading效果
+ isDraft: false // 是否保存为草稿,仅视频号平台可见
}
// helper to create a fresh deep-copied tab from defaultTabInit
@@ -791,7 +801,8 @@ const confirmPublish = async (tab) => {
startDays: tab.scheduleEnabled ? tab.startDays || 0 : 0, // 从今天开始计算的发布天数,0表示明天,1表示后天
category: 0, //表示非原创
productLink: tab.productLink.trim() || '', // 商品链接
- productTitle: tab.productTitle.trim() || '' // 商品名称
+ productTitle: tab.productTitle.trim() || '', // 商品名称
+ isDraft: tab.isDraft // 是否保存为草稿,仅视频号平台使用
}
// 调用后端发布API
diff --git a/uploader/tencent_uploader/main.py b/uploader/tencent_uploader/main.py
index e3ddfd8..eb09ae6 100644
--- a/uploader/tencent_uploader/main.py
+++ b/uploader/tencent_uploader/main.py
@@ -82,13 +82,14 @@ async def weixin_setup(account_file, handle=False):
class TencentVideo(object):
- def __init__(self, title, file_path, tags, publish_date: datetime, account_file, category=None):
+ def __init__(self, title, file_path, tags, publish_date: datetime, account_file, category=None, is_draft=False):
self.title = title # 视频标题
self.file_path = file_path
self.tags = tags
self.publish_date = publish_date
self.account_file = account_file
self.category = category
+ self.is_draft = is_draft # 是否保存为草稿
self.local_executable_path = LOCAL_CHROME_PATH or None
async def set_schedule_time_tencent(self, page, publish_date):
@@ -185,21 +186,37 @@ class TencentVideo(object):
async def click_publish(self, page):
while True:
try:
- publish_buttion = page.locator('div.form-btns button:has-text("发表")')
- if await publish_buttion.count():
- await publish_buttion.click()
- await page.wait_for_url("https://channels.weixin.qq.com/platform/post/list", timeout=5000)
- tencent_logger.success(" [-]视频发布成功")
+ if self.is_draft:
+ # 点击"保存草稿"按钮
+ draft_button = page.locator('div.form-btns button:has-text("保存草稿")')
+ if await draft_button.count():
+ await draft_button.click()
+ # 等待跳转到草稿箱页面或确认保存成功
+ await page.wait_for_url("**/post/list**", timeout=5000) # 使用通配符匹配包含post/list的URL
+ tencent_logger.success(" [-]视频草稿保存成功")
+ else:
+ # 点击"发表"按钮
+ publish_button = page.locator('div.form-btns button:has-text("发表")')
+ if await publish_button.count():
+ await publish_button.click()
+ await page.wait_for_url("https://channels.weixin.qq.com/platform/post/list", timeout=5000)
+ tencent_logger.success(" [-]视频发布成功")
break
except Exception as e:
current_url = page.url
- if "https://channels.weixin.qq.com/platform/post/list" in current_url:
- tencent_logger.success(" [-]视频发布成功")
- break
+ if self.is_draft:
+ # 检查是否在草稿相关的页面
+ if "post/list" in current_url or "draft" in current_url:
+ tencent_logger.success(" [-]视频草稿保存成功")
+ break
else:
- tencent_logger.exception(f" [-] Exception: {e}")
- tencent_logger.info(" [-] 视频正在发布中...")
- await asyncio.sleep(0.5)
+ # 检查是否在发布列表页面
+ if "https://channels.weixin.qq.com/platform/post/list" in current_url:
+ tencent_logger.success(" [-]视频发布成功")
+ break
+ tencent_logger.exception(f" [-] Exception: {e}")
+ tencent_logger.info(" [-] 视频正在发布中...")
+ await asyncio.sleep(0.5)
async def detect_upload_status(self, page):
while True: