28 lines
910 B
Python
28 lines
910 B
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
|
|
from m3u_tools import trim_m3u8_directory
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description="递归删除 m3u8 前置分片")
|
|
parser.add_argument("directory", nargs="?", default="delLine", help="目标目录")
|
|
parser.add_argument("--remove", type=int, default=40, help="删除前多少个分片")
|
|
parser.add_argument("--min-segments", type=int, default=120, help="最少分片阈值")
|
|
args = parser.parse_args()
|
|
|
|
results = trim_m3u8_directory(
|
|
args.directory,
|
|
remove_segments=max(1, args.remove),
|
|
min_segments=max(1, args.min_segments),
|
|
recursive=True,
|
|
)
|
|
processed = sum(1 for success, _, _ in results if success)
|
|
print(f"处理完成:成功 {processed} 个,跳过 {len(results) - processed} 个")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|