Skip to content

Commit

Permalink
修复视频号发布bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wayne committed Jul 22, 2024
1 parent e054b3f commit d72ea2b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 21 deletions.
1 change: 1 addition & 0 deletions config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ publisher:
collection: 集合名称
shipinhao:
enable: True
original: False
title_prefix: 标题前缀
collection: 集合名称

1 change: 1 addition & 0 deletions locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"Douyin Config": "抖音配置",
"Kuaishou Config": "快手配置",
"shipinhao Config": "视频号配置",
"Enable original": "是否开启原创",
"Xiaohongshu Config": "小红书配置",
"Enable douyin": "是否开启抖音",
"Enable kuaishou": "是否开启快手",
Expand Down
24 changes: 23 additions & 1 deletion pages/03_auto_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,23 @@ def set_enable(my_type, state_key):
my_config['publisher'][my_type]['enable'] = use_common
save_config()

def get_original(my_type):
test_config(my_config, "publisher", my_type)
if 'original' not in my_config['publisher'][my_type]:
# 默认False
my_config['publisher'][my_type]['original'] = False
save_config()
return False
else:
return my_config['publisher'][my_type]['original']


def set_original(my_type, state_key):
use_common = st.session_state.get(state_key)
test_config(my_config, "publisher", my_type)
my_config['publisher'][my_type]['original'] = use_common
save_config()


def get_enable_kuaishou(my_type):
test_config(my_config, "publisher", "kuaishou", my_type)
Expand Down Expand Up @@ -299,8 +316,11 @@ def start_publish_video():
st.checkbox(label=tr("Enable shipinhao"), key="video_publish_enable_shipinhao",
value=get_enable('shipinhao'), on_change=set_enable,
args=('shipinhao', 'video_publish_enable_shipinhao'))
st.checkbox(label=tr("Enable original"), key="video_publish_shipinhao_enable_original",
value=get_original('shipinhao'), on_change=set_original,
args=('shipinhao', 'video_publish_shipinhao_enable_original'))
if not st.session_state.get("video_publish_use_common_config"):
st_columns = st.columns(3)
st_columns = st.columns(4)
with st_columns[0]:
st.text_input(label=tr("Title Prefix"), key="video_publish_shipinhao_title_prefix",
value=get_title_prefix('shipinhao'), on_change=set_title_prefix,
Expand All @@ -313,6 +333,8 @@ def start_publish_video():
st.text_input(label=tr("Tags"), key="video_publish_shipinhao_tags",
value=get_tags('shipinhao'), on_change=set_tags,
args=('shipinhao', 'video_publish_shipinhao_tags'))


st.subheader(tr("Xiaohongshu Config"))
st.checkbox(label=tr("Enable xiaohongshu"), key="video_publish_enable_xiaohongshu",
value=get_enable('xiaohongshu'), on_change=set_enable,
Expand Down
40 changes: 20 additions & 20 deletions services/publisher/shipinhao_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,26 +103,26 @@ def shipinhao_publisher(driver, video_file, text_file):
actions.move_to_element(collection_to_select).click().perform()
time.sleep(1)

is_firefox = st.session_state.get("video_publish_driver_type") == 'firefox'
# firefox没有原创按钮?
# if not is_firefox:
# 原创
original_tag = driver.find_element(By.XPATH, '//div[@class="declare-original-checkbox"]//input[@type="checkbox"]')
original_tag.click()
time.sleep(1)
original_tag_click = driver.find_element(By.XPATH, '//div[@class="original-type-form"]//dt[contains(text(),"请选择")]')
actions.move_to_element(original_tag_click).click().perform()
time.sleep(1)
original_tag_item = driver.find_element(By.XPATH,
'//div[@class="original-type-form"]//span[text()="知识"]')
actions.move_to_element(original_tag_item).click().perform()
time.sleep(1)
agree_button = driver.find_element(By.XPATH, '//div[@class="original-proto-wrapper"]//input[@type="checkbox"]')
agree_button.click()
time.sleep(1)
agree_button_click = driver.find_element(By.XPATH,'//button[@type="button" and text()="声明原创"]')
agree_button_click.click()
time.sleep(1)
is_original = st.session_state.get("video_publish_shipinhao_enable_original")

if is_original:
# 原创
original_tag = driver.find_element(By.XPATH, '//div[@class="declare-original-checkbox"]//input[@type="checkbox"]')
original_tag.click()
time.sleep(1)
# original_tag_click = driver.find_element(By.XPATH, '//div[@class="original-type-form"]//dt[contains(text(),"请选择")]')
# actions.move_to_element(original_tag_click).click().perform()
# time.sleep(1)
# original_tag_item = driver.find_element(By.XPATH,
# '//div[@class="original-type-form"]//span[text()="知识"]')
# actions.move_to_element(original_tag_item).click().perform()
# time.sleep(1)
agree_button = driver.find_element(By.XPATH, '//div[@class="original-proto-wrapper"]//input[@type="checkbox"]')
agree_button.click()
time.sleep(1)
agree_button_click = driver.find_element(By.XPATH,'//button[@type="button" and text()="声明原创"]')
agree_button_click.click()
time.sleep(1)

# 发布
publish_button = driver.find_element(By.XPATH, '//button[text()="发表"]')
Expand Down

0 comments on commit d72ea2b

Please sign in to comment.