Skip to content

garroshub/MixCut-Skill / skills

youtube-clipper

Verified

YouTube 视频智能剪辑工具。下载视频和字幕,AI 分析生成精细章节(几分钟级别), 用户选择片段后自动剪辑、翻译字幕为中英双语、烧录字幕到视频,并生成总结文案。 使用场景:当用户需要剪辑 YouTube 视频、生成短视频片段、制作双语字幕版本时。 关键词:视频剪辑、YouTube、字幕翻译、双语字幕、视频下载、clip video

scripts/merge_bilingual_subtitles.py

View on GitHub
#!/usr/bin/env python3
"""
合并英文和中文字幕为双语 SRT 文件
"""

import sys
import re

def parse_srt_file(file_path):
    """解析 SRT 文件"""
    with open(file_path, 'r', encoding='utf-8') as f:
        content = f.read()

    # 分割字幕块
    blocks = content.strip().split('\n\n')
    subtitles = []

    for block in blocks:
        lines = block.strip().split('\n')
        if len(lines) >= 3:
            index = lines[0]
            time = lines[1]
            text = '\n'.join(lines[2:])
            subtitles.append({
                'index': index,
                'time': time,
                'text': text
            })

    return subtitles

def merge_bilingual_subtitles(english_file, chinese_file, output_file):
    """合并英文和中文字幕"""
    print(f"📝 合并双语字幕...")
    print(f"   英文字幕: {english_file}")
    print(f"   中文字幕: {chinese_file}")

    # 解析两个字幕文件
    english_subs = parse_srt_file(english_file)
    chinese_subs = parse_srt_file(chinese_file)

    if len(english_subs) != len(chinese_subs):
        print(f"⚠️  警告: 英文字幕 ({len(english_subs)} 条) 和中文字幕 ({len(chinese_subs)} 条) 数量不匹配")

    # 合并字幕
    bilingual_subs = []
    for i in range(min(len(english_subs), len(chinese_subs))):
        bilingual_subs.append({
            'index': english_subs[i]['index'],
            'time': english_subs[i]['time'],
            'text': f"{english_subs[i]['text']}\n{chinese_subs[i]['text']}"
        })

    # 写入双语字幕文件
    with open(output_file, 'w', encoding='utf-8') as f:
        for sub in bilingual_subs:
            f.write(f"{sub['index']}\n")
            f.write(f"{sub['time']}\n")
            f.write(f"{sub['text']}\n")
            f.write("\n")

    print(f"✅ 双语字幕生成完成")
    print(f"   输出文件: {output_file}")
    print(f"   字幕条数: {len(bilingual_subs)}")

if __name__ == '__main__':
    if len(sys.argv) != 4:
        print("用法: python merge_bilingual_subtitles.py <english_srt> <chinese_srt> <output_srt>")
        sys.exit(1)

    english_file = sys.argv[1]
    chinese_file = sys.argv[2]
    output_file = sys.argv[3]

    merge_bilingual_subtitles(english_file, chinese_file, output_file)
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall