diff --git a/config/config.example.yml b/config/config.example.yml index d42a80b..85dfad1 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -95,6 +95,7 @@ publisher: collection: 集合名称 shipinhao: enable: True + original: False title_prefix: 标题前缀 collection: 集合名称 diff --git a/locales/zh-CN.json b/locales/zh-CN.json index 43956f0..e1e0640 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -119,6 +119,7 @@ "Douyin Config": "抖音配置", "Kuaishou Config": "快手配置", "shipinhao Config": "视频号配置", + "Enable original": "是否开启原创", "Xiaohongshu Config": "小红书配置", "Enable douyin": "是否开启抖音", "Enable kuaishou": "是否开启快手", diff --git a/pages/03_auto_publish.py b/pages/03_auto_publish.py index 7a2c2f7..c39649b 100644 --- a/pages/03_auto_publish.py +++ b/pages/03_auto_publish.py @@ -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) @@ -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, @@ -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, diff --git a/services/publisher/shipinhao_publisher.py b/services/publisher/shipinhao_publisher.py index 52c8d14..435bf51 100644 --- a/services/publisher/shipinhao_publisher.py +++ b/services/publisher/shipinhao_publisher.py @@ -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()="发表"]')