Python/剪映脚本生成自动化/main.py

47 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
"""
剪映脚本生成自动化
"""
from draft import GenerateDraft
# 编导方案1
def direct():
"""生成剪映草稿"""
# 实例化
draft = GenerateDraft(
name="demo2",
) # 需要
# 根据脚本生成文本和音频字幕
draft.add_subtitle(
script="所有人今天准备狂点外卖是真的0.1元起一杯的霸王茶姬还外卖到家怎么能不来一杯呢现在淘宝闪购给大家发福利最高22元无门槛红包官方链接就在下方奶茶脑袋快冲"
)
# 为背景视频添加视频轨道并添加视频片段
draft.add_video(
track_name="background",
name="background.mp4",
clip_settings={"scale_x": 2.5, "scale_y": 2.5},
)
# 为logo添加视频轨道并添加图片片段
draft.add_video(
track_name="logo",
name="logo.png",
)
# 为免责声明添加视频轨道并添加图片片段
draft.add_text(
track_name="disclaimer",
content="支付需谨慎谨防诈骗\n仅限支付宝用户,详情以活动为准",
)
draft.add_sticker(track_name="sticker", resource_id="7026858083393588487")
# 保存草稿
draft.save()
if __name__ == "__main__":
execute_workflow()