1. 重构快手

- 图文增加
- 封面增加
2. 快手skill,cli支持
This commit is contained in:
home-dev-pookz
2026-03-25 02:25:02 +08:00
parent 2934328888
commit b415613b38
25 changed files with 1343 additions and 227 deletions
+8 -3
View File
@@ -4,7 +4,12 @@ from pathlib import Path
from conf import BASE_DIR
from uploader.ks_uploader.main import ks_setup
if __name__ == '__main__':
account_file = Path(BASE_DIR / "cookies" / "ks_uploader" / "account.json")
def login_to_kuaishou():
account_file = Path(BASE_DIR / "cookies" / "kuaishou_creator1.json")
account_file.parent.mkdir(exist_ok=True)
cookie_setup = asyncio.run(ks_setup(str(account_file), handle=True))
asyncio.run(ks_setup(str(account_file), handle=True))
if __name__ == '__main__':
login_to_kuaishou()
-1
View File
@@ -40,7 +40,6 @@ def upload_note_to_douyin():
tags = ["图文", "示例", "抖音图文"]
video_meta_publish_time = datetime.strptime("2026-3-25 12:13", "%Y-%m-%d %H:%M")
app = DouYinNote(
image_paths=image_paths,
note=note,
+64
View File
@@ -0,0 +1,64 @@
import asyncio
from datetime import datetime
from pathlib import Path
from conf import BASE_DIR
from uploader.ks_uploader.main import (
KUAISHOU_PUBLISH_STRATEGY_IMMEDIATE,
KUAISHOU_PUBLISH_STRATEGY_SCHEDULED,
KSNote,
KSVideo,
)
def upload_video_to_kuaishou():
account_file = Path(BASE_DIR / "cookies" / "kuaishou_creator.json")
account_file.parent.mkdir(exist_ok=True)
video_file_path = Path(BASE_DIR) / "videos/demo.mp4"
thumbnail_path = video_file_path.with_suffix(".png")
video_meta_title = "快手视频上传示例"
video_meta_hashtags = ["快手", "自动上传", "示例"]
video_meta_publish_time = datetime.strptime("2026-03-27 12:13", "%Y-%m-%d %H:%M")
publish_strategy = KUAISHOU_PUBLISH_STRATEGY_SCHEDULED
app = KSVideo(
title=video_meta_title,
file_path=video_file_path,
tags=video_meta_hashtags,
publish_date=video_meta_publish_time,
account_file=account_file,
thumbnail_path=thumbnail_path if thumbnail_path.exists() else None,
publish_strategy=publish_strategy,
)
asyncio.run(app.main())
def upload_note_to_kuaishou():
account_file = Path(BASE_DIR / "cookies" / "kuaishou_creator1.json")
account_file.parent.mkdir(exist_ok=True)
image_paths = [
Path(BASE_DIR) / "videos/demo.png",
Path(BASE_DIR) / "videos/demo1.png",
Path(BASE_DIR) / "videos/demo2.png",
]
note = "快手图文内容示例"
tags = ["快手图文", "自动上传", "示例"]
note_meta_publish_time = datetime.strptime("2026-03-27 12:13", "%Y-%m-%d %H:%M")
publish_strategy = KUAISHOU_PUBLISH_STRATEGY_SCHEDULED
app = KSNote(
image_paths=image_paths,
note=note,
tags=tags,
publish_date=note_meta_publish_time,
account_file=account_file,
publish_strategy=publish_strategy,
)
asyncio.run(app.main())
if __name__ == '__main__':
upload_video_to_kuaishou()
# upload_note_to_kuaishou()
-26
View File
@@ -1,26 +0,0 @@
import asyncio
from pathlib import Path
from conf import BASE_DIR
from uploader.ks_uploader.main import ks_setup, KSVideo
from utils.files_times import generate_schedule_time_next_day, get_title_and_hashtags
if __name__ == '__main__':
filepath = Path(BASE_DIR) / "videos"
account_file = Path(BASE_DIR / "cookies" / "ks_uploader" / "account.json")
# 获取视频目录
folder_path = Path(filepath)
# 获取文件夹中的所有文件
files = list(folder_path.glob("*.mp4"))
file_num = len(files)
publish_datetimes = generate_schedule_time_next_day(file_num, 1, daily_times=[16])
cookie_setup = asyncio.run(ks_setup(account_file, handle=False))
for index, file in enumerate(files):
title, tags = get_title_and_hashtags(str(file))
# 打印视频文件名、标题和 hashtag
print(f"视频文件名:{file}")
print(f"标题:{title}")
print(f"Hashtag:{tags}")
app = KSVideo(title, file, tags, publish_datetimes[index], account_file)
asyncio.run(app.main(), debug=False)