#!/usr/bin/env python3
"""
逐行列出adid=8096的所有字幕句（时间格式：分:秒）
"""
import sqlite3

db_path = "\\\\ll\\D\\xtrssvjj\\dpd.db"

def ms_to_time(ms):
    """将毫秒转换为分:秒格式"""
    total_seconds = ms / 1000
    minutes = int(total_seconds // 60)
    seconds = int(total_seconds % 60)
    return f"{minutes}:{seconds:02d}"

try:
    conn = sqlite3.connect(db_path)
    cursor = conn.cursor()

    # 查询adid=8096的所有字幕句，按idx排序
    cursor.execute("SELECT idx, start, end, cn FROM srts WHERE adid = 8096 ORDER BY idx ASC")
    subtitles = cursor.fetchall()

    print(f"adid=8096 共 {len(subtitles)} 句字幕:")
    print("=" * 100)
    print(f"{'idx':>4} | {'start':>8} | {'end':>8} | {'中文':<70}")
    print("=" * 100)

    for idx, start, end, cn in subtitles:
        start_time = ms_to_time(start)
        end_time = ms_to_time(end)
        print(f"{idx:>4} | {start_time:>8} | {end_time:>8} | {cn:<70}")

    print("=" * 100)
    conn.close()

except Exception as e:
    print(f"错误: {e}")
