using System; using System.Collections.Generic; using System.IO; using System.Linq; namespace DownKyi.Core.Danmaku2Ass { /// /// 字幕工程类 /// public class Studio { public Config Config; public List Danmakus; public Creater Creater; public int KeepedCount; public int DropedCount; public Studio(Config config, List danmakus) { Config = config; Danmakus = danmakus; } public void StartHandle() { Creater = SetCreater(); KeepedCount = SetKeepedCount(); DropedCount = SetDropedCount(); } /// /// ass 创建器 /// /// protected Creater SetCreater() { return new Creater(Config, Danmakus); } /// /// 保留条数 /// /// protected int SetKeepedCount() { return Creater.Subtitles.Count(); } /// /// 丢弃条数 /// /// protected int SetDropedCount() { return Danmakus.Count - KeepedCount; } /// /// 创建 ass 字幕 /// /// public void CreateAssFile(string fileName) { CreateFile(fileName, Creater.Text); } public void CreateFile(string fileName, string text) { try { File.WriteAllText(fileName, text); } catch (Exception) { } } public Dictionary Report() { return new Dictionary() { {"total", Danmakus.Count}, {"droped", DropedCount}, {"keeped", KeepedCount}, }; } } }