diff --git a/Sirrene/Form1.Designer.cs b/Sirrene/Form1.Designer.cs index fea6262..dcb94dc 100644 --- a/Sirrene/Form1.Designer.cs +++ b/Sirrene/Form1.Designer.cs @@ -33,13 +33,13 @@ private void InitializeComponent() this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.ファイルFToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.録画フォルダーを開くOToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.終了XToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ツールTToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.オプションOToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.button1 = new System.Windows.Forms.Button(); this.listBox1 = new System.Windows.Forms.ListBox(); this.label1 = new System.Windows.Forms.Label(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // @@ -77,6 +77,12 @@ private void InitializeComponent() this.録画フォルダーを開くOToolStripMenuItem.Name = "録画フォルダーを開くOToolStripMenuItem"; this.録画フォルダーを開くOToolStripMenuItem.Size = new System.Drawing.Size(186, 22); this.録画フォルダーを開くOToolStripMenuItem.Text = "録画フォルダーを開く(&O)"; + this.録画フォルダーを開くOToolStripMenuItem.Click += new System.EventHandler(this.録画フォルダーを開くOToolStripMenuItem_Click); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(183, 6); // // 終了XToolStripMenuItem // @@ -96,7 +102,7 @@ private void InitializeComponent() // オプションOToolStripMenuItem // this.オプションOToolStripMenuItem.Name = "オプションOToolStripMenuItem"; - this.オプションOToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.オプションOToolStripMenuItem.Size = new System.Drawing.Size(144, 22); this.オプションOToolStripMenuItem.Text = "オプション(&O)..."; this.オプションOToolStripMenuItem.Click += new System.EventHandler(this.オプションOToolStripMenuItem_Click); // @@ -131,13 +137,9 @@ private void InitializeComponent() this.label1.TabIndex = 4; this.label1.Text = "URL/ID"; // - // toolStripSeparator1 - // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(183, 6); - // // Form1 // + this.AllowDrop = true; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(468, 414); @@ -150,6 +152,8 @@ private void InitializeComponent() this.Name = "Form1"; this.Text = "Form1"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); + this.DragDrop += new System.Windows.Forms.DragEventHandler(this.Form1_DragDrop); + this.DragEnter += new System.Windows.Forms.DragEventHandler(this.Form1_DragEnter); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.ResumeLayout(false); diff --git a/Sirrene/Form1.cs b/Sirrene/Form1.cs index 40efee3..6b5a9f8 100644 --- a/Sirrene/Form1.cs +++ b/Sirrene/Form1.cs @@ -23,19 +23,16 @@ public partial class Form1 : Form private static bool IsBatchMode { get; set; } //引数指定で実行か? //0処理待ち 1録画準備 2録画中 3再接続 4中断 5変換処理中 9終了 private static int ProgramStatus { get; set; } //プログラム状態 - private volatile bool start_flg = false; + private volatile bool IsStart_flg = false; + private volatile bool IsBreak_flg = false; //dispose するもの private ExecProcess _eProcess = null; //Process private RecHtml _rHtml = null; //RecHtml private NicoDb _ndb = null; //NicoDb - //private DataApiDataInfo dadi = null; //動画情報 - private JObject dataJson = null; //動画情報(JObject) - private JObject sessionJson = null; //セッション情報(JObject) - private ExecPsInfo epi = null; //実行/保存ファイル情報 - private RetryInfo rti = null; //リトライ情報 private CookieContainer cookiecontainer = new CookieContainer(); + private ExecPsInfo epi = null; //実行/保存ファイル情報 private string videoId = null; @@ -81,7 +78,7 @@ private void Button1_Click(object sender, EventArgs e) //中断処理 if (button1.Text == "ABORT") { - End_DL(1); + IsBreak_flg = true; return; } @@ -160,6 +157,11 @@ private void Button1_Click(object sender, EventArgs e) public async void Start_DL() { cookiecontainer = null; + + JObject dataJson = null; //動画情報(JObject) + JObject sessionJson = null; //セッション情報(JObject) + RetryInfo rti = null; //リトライ情報 + try { if (props.IsLogin == IsLogin.always) @@ -249,7 +251,7 @@ public async void Start_DL() _nvn.SetCookieContainer(cookiecontainer); (dataJson, err, neterr) = await _nvn.GetNicoPageAsync(videoId); } - if (err != null) + if (!string.IsNullOrEmpty(err)) { AddLog("この動画は存在しないか、削除された可能性があります。 (" + err + ")", 1); return; @@ -289,7 +291,7 @@ public async void Start_DL() epi.Sfolder = djs.SetRecFolderFormat(props.SaveFolder); epi.Protocol = "hls"; epi.Seq = 0; - //ExecPsInfo.MakeRecDir(epi); + ExecPsInfo.MakeRecDir(epi); if (props.UseExternal == UseExternal.native) { @@ -297,11 +299,11 @@ public async void Start_DL() file += ".sqlite3"; epi.SaveFile = file; _ndb = new NicoDb(this, epi.SaveFile); - //_ndb.CreateDbAll(); + _ndb.CreateDbAll(); //_ndb.WriteDbKvsProps(djs.Data_Props); } - AddLog("File: "+epi.SaveFile, 1); + AddLog("File: "+epi.SaveFile, 9); EnableButton(false); /* @@ -331,9 +333,9 @@ public async void Start_DL() (session, err) = djs.MakeSession(dataJson); if (!string.IsNullOrEmpty(session)) { - if (err != "") + if (!string.IsNullOrEmpty(err)) { - AddLog("Error: MakeSession. (" + err + ")", 1); + AddLog("MakeSession Error: " + err , 1); return; } AddSession(JObject.Parse(session).ToString()); @@ -346,7 +348,7 @@ public async void Start_DL() //(_, err, neterr) = await _nvn.GetNicoCrossDomainAsync(djs.Session_Url); (sessionJson, err, neterr) = await _nvn.PostNicoSessionAsync(djs.Session_Uri + "?_format=json", session); } - if (err != null) + if (!string.IsNullOrEmpty(err)) { AddLog("Send PostSession Error: " + err + "(" + neterr + ")", 1); } @@ -356,53 +358,33 @@ public async void Start_DL() { var msg = (string)sessionJson["meta"]["message"] + "(" + sessionJson["meta"]["status"].ToString() + ")"; - AddLog("Send PostSession " + msg, 1); + AddLog("Send PostSession " + msg, 9); } } AddSession("\r\nResponse:\r\n" + sessionJson.ToString()); (flg, err) = djs.GetContentUri(sessionJson); if (flg) { - AddLog("Content_Uri: " + djs.Content_Uri, 1); - AddLog("Heartbeat_Uri: " + djs.Heartbeat_Uri, 1); + AddLog("Content_Uri: " + djs.Content_Uri, 9); + AddLog("Heartbeat_Uri: " + djs.Heartbeat_Uri, 9); //AddSession("\r\nHeartbeat:\r\n" + djs.Heartbeat_Data); } else { - AddLog("Content_Uri: " + err, 1); + AddLog("Content_Uri Error: " + err, 1); } var ri = new RetryInfo(); rti = ri; rti.Count = 3; - //ハートビートテスト - JObject dummy = null; - await Task.Delay(10000); - using (var _nvn = new NicoVideoNet()) - { - _nvn.SetCookieContainer(cookiecontainer); - (dummy, err, neterr) = await _nvn.PostNicoSessionAsync(djs.Heartbeat_Uri, djs.Heartbeat_Data); - } - if (err != null) - { - AddLog("Send Heartbeat Error: " + err + "(" + neterr + ")", 1); - } - else - { - if (dummy["meta"] != null) - { - var msg = (string)dummy["meta"]["message"] + - "(" + dummy["meta"]["status"].ToString() + ")"; - AddLog("Send Heartbeat " + msg, 1); - } - } - - + //動画ダウンロード + IsStart_flg = true; + IsBreak_flg = false; if (props.UseExternal == UseExternal.native) { _rHtml = new RecHtml(this, djs, cookiecontainer, _ndb, rti); - _rHtml.ExecPs(djs.Content_Uri, ""); + _rHtml.ExecPs(djs.Content_Uri, epi.SaveFile); } else { @@ -412,18 +394,54 @@ public async void Start_DL() _eProcess.ExecPs(epi.Exec, argument); } - //放送情報を表示 - //DispHosoData(bci); - - //1秒おきに状態を調べて処理する - start_flg = true; - while (start_flg == true) + //5秒おきに状態を調べて処理する + JObject dummy = null; + int interval = 0; + while (IsStart_flg == true && IsBreak_flg == false) { - //await CheckStatus(); await Task.Delay(5000); - start_flg = false; + if (_rHtml != null && _rHtml.PsStatus > 0 || + _eProcess != null && _eProcess.PsStatus > 0) + { + IsStart_flg = false; + break; + } + interval += 5; + if (interval < 40) + continue; + + //ハートビート + interval = 0; + using (var _nvn = new NicoVideoNet()) + { + _nvn.SetCookieContainer(cookiecontainer); + (dummy, err, neterr) = await _nvn.PostNicoSessionAsync(djs.Heartbeat_Uri, djs.Heartbeat_Data); + } + if (!string.IsNullOrEmpty(err)) + { + AddLog("Send Heartbeat Error: " + err + "(" + neterr + ")", 1); + } + else + { + if (dummy["meta"] != null) + { + var msg = (string)dummy["meta"]["message"] + + "(" + dummy["meta"]["status"].ToString() + ")"; + AddLog("Send Heartbeat " + msg, 9); + } + } + } + + //sqlite3 -> .mp4 に変換 + if (IsBreak_flg) + { + End_DL(1); + } + else + { + End_DL(0); + await Task.Run(() => StartExtract(epi.SaveFile)); } - End_DL(0); return; } // try @@ -454,7 +472,8 @@ public void End_DL(int flag) else AddLog("ダウンロード終了しました。", 1); EnableButton(true); - start_flg = false; + IsStart_flg = false; + IsBreak_flg = false; return; } // try @@ -490,6 +509,8 @@ private void オプションOToolStripMenuItem_Click(object sender, EventArgs e) { LogFile = null; LogFile2 = null; + LogFile3 = null; + LogFile4 = null; using (var fo2 = new Form2(this, accountdbfile)) { @@ -501,6 +522,75 @@ private void オプションOToolStripMenuItem_Click(object sender, EventArgs e) AddLog("オプションメニューが開けませんでした。\r\n" + Ex.Message, 2); } } + + private void 録画フォルダーを開くOToolStripMenuItem_Click(object sender, EventArgs e) + { + if (!String.IsNullOrEmpty(props.SaveDir)) + { + Process.Start(props.SaveDir); + } + else + { + Process.Start(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); + } + } + + private async void Form1_DragDrop(object sender, DragEventArgs e) + { + string[] files = (string[])e.Data.GetData(DataFormats.FileDrop, false); + + try + { + ClearHosoData(); + ClearLog(); + + var exec_file = props.ExecFile[0]; + exec_file = GetExecFile(exec_file); + if (!File.Exists(exec_file)) + { + AddLog("実行ファイルがありません。", 2); + return; + } + + var save_dir = String.IsNullOrEmpty(props.SaveDir) ? System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) : props.SaveDir; + if (!Directory.Exists(save_dir)) + { + AddLog("保存フォルダーが存在しません。", 2); + return; + } + + LogFile = Props.GetLogfile(save_dir, "conv"); + LogFile2 = Props.GetExecLogfile(save_dir, "conv"); + LogFile3 = null; + LogFile4 = null; + + for (int i = 0; i < files.Length; i++) + { + AddLog("出力開始します。", 1); + await Task.Run(() => StartExtract(files[i])); + } + } + catch (Exception Ex) + { + if (_ndb != null) + { + _ndb.Dispose(); + } + AddLog("ドラッグ&ドロップできません。\r\n" + Ex.Message, 2); + } + } + + private void Form1_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.FileDrop)) + { + e.Effect = DragDropEffects.All; + } + else + { + e.Effect = DragDropEffects.None; + } + } } } \ No newline at end of file diff --git a/Sirrene/Form1_Sub.cs b/Sirrene/Form1_Sub.cs index e8a38fe..f09fbd8 100644 --- a/Sirrene/Form1_Sub.cs +++ b/Sirrene/Form1_Sub.cs @@ -170,6 +170,83 @@ public void EnableButton(bool flag) })); } + private void StartExtract(string filename) + { + if (filename.IndexOf(".sqlite3") < 0) return; + + try + { + //保存ファイル名作成 + epi = new ExecPsInfo(); + epi.Sqlite3File = filename; + epi.Protocol = "hls"; + epi.Seq = 0; + epi.Exec = GetExecFile(props.ExecFile[0]); + epi.Arg = "-i - -c copy -y \"%FILE%\""; + epi.Ext2 = ".mp4"; + + //Kvsデーター読み込み + _ndb = new NicoDb(this, filename); + //var kvs = _ndb.ReadDbKvs(); +/* + bci = new BroadCastInfo(null, null, null, null); + bci.Provider_Type = kvs["providerType"]; + bci.OnAirStatus = kvs["status"]; + bci.Server_Time = Props.GetLongParse(kvs["serverTime"]); + + //コメント情報 + cmi = new CommentInfo("NaN"); + cmi.OpenTime = Props.GetLongParse(kvs["openTime"]); + cmi.BeginTime = Props.GetLongParse(kvs["beginTime"]); + cmi.EndTime = Props.GetLongParse(kvs["endTime"]); + cmi.Offset = 0L; + cctl = null; + _nNetComment = new NicoNetComment(this, bci, cmi, _nLiveNet, _ndb, cctl); +*/ + + //映像ファイル出力処理 + if (_ndb.CountDbMedia() > 0) + { + if (_ndb.ReadDbMedia2(epi)) + AddLog("映像出力終了しました。", 1); + else + AddLog("映像出力失敗しました。", 1); + } + else + { + AddLog("映像データーはありません。", 1); + epi.SaveFile = ExecPsInfo.GetSaveFileSqlite3Num(epi); + //cmi.SaveFile = epi.SaveFile + epi.Xml; + } + //if (_ndb.CountDbComment() > 0) + //{ + // if (_ndb.ReadDbComment(cmi, bci, _nNetComment)) + // AddLog("コメント出力終了しました。", 1); + // else + // AddLog("コメント出力失敗しました。", 1); + //} + //else + //{ + // AddLog("コメントデーターはありません。", 1); + //} + + //終了処理 + if (_ndb != null) + _ndb.Dispose(); + //if (_nNetComment != null) + // _nNetComment.Dispose(); + } + catch (Exception Ex) + { + if (_ndb != null) + _ndb.Dispose(); + //if (_nNetComment != null) + // _nNetComment.Dispose(); + AddLog("出力処理エラー。\r\n" + Ex.Message, 2); + } + } + + //実行ファイルと同じフォルダにある指定ファイルのフルパスをGet private string GetExecFile(string file) { diff --git a/Sirrene/Prop/Version.cs b/Sirrene/Prop/Version.cs index 88b01a0..b69b342 100644 --- a/Sirrene/Prop/Version.cs +++ b/Sirrene/Prop/Version.cs @@ -4,8 +4,8 @@ namespace Sirrene.Prop { public class Ver { - public static readonly string Version = "0.1.0.03"; - public static readonly string VerDate = "2023/06/26"; + public static readonly string Version = "0.1.0.04"; + public static readonly string VerDate = "2023/07/03"; public static string GetFullVersion() { diff --git a/Sirrene/Record/NicoDb.cs b/Sirrene/Record/NicoDb.cs index ec122be..84d30d6 100644 --- a/Sirrene/Record/NicoDb.cs +++ b/Sirrene/Record/NicoDb.cs @@ -66,8 +66,8 @@ public void Close() public void CreateDbAll() { CreateDbMedia(); - //CreateDbComment(); - //CreateDbKvs(); + CreateDbComment(); + CreateDbKvs(); } public void CreateDbMedia() @@ -134,8 +134,7 @@ public bool WriteDbMedia(Segment seg, PlayListInfo pli, SegmentInfo sgi, byte[] return true; } -/* - public bool ReadDbMedia(ExecPsInfo epi, CommentInfo cmi, BroadCastInfo bci) + public bool ReadDbMedia(ExecPsInfo epi) { FileStream fs = null; var result = false; @@ -149,7 +148,6 @@ public bool ReadDbMedia(ExecPsInfo epi, CommentInfo cmi, BroadCastInfo bci) int prevbw = -1; int size; byte[] data; - bool off_flg = true; command.CommandText = "SELECT seqno, bandwidth, size, data FROM media\n" + "WHERE IFNULL(notfound, 0) == 0 AND data IS NOT NULL\n" @@ -158,17 +156,11 @@ public bool ReadDbMedia(ExecPsInfo epi, CommentInfo cmi, BroadCastInfo bci) using (SQLiteDataReader reader = command.ExecuteReader()) { epi.SaveFile = ExecPsInfo.GetSaveFileSqlite3Num(epi); - cmi.SaveFile = epi.SaveFile + epi.Xml; fs = new FileStream(epi.SaveFile + epi.Ext, FileMode.Create); while (reader.Read()) { seqno = (long )reader["seqno"]; - if (off_flg) - { - cmi.Offset = bci.IsTimeShift() ? seqno * 500L : bci.Server_Time / 10L - cmi.OpenTime * 100L; - off_flg = false; - } bw = (int )(long )reader["bandwidth"]; // チャンクが飛んでいる場合はファイルを分ける // BANDWIDTHが変わる場合はファイルを分ける @@ -203,7 +195,7 @@ public bool ReadDbMedia(ExecPsInfo epi, CommentInfo cmi, BroadCastInfo bci) return result; } - public bool ReadDbMedia2(ExecPsInfo epi, CommentInfo cmi, BroadCastInfo bci) + public bool ReadDbMedia2(ExecPsInfo epi) { //FileStream fs = null; var ecv = new List(); @@ -218,7 +210,6 @@ public bool ReadDbMedia2(ExecPsInfo epi, CommentInfo cmi, BroadCastInfo bci) int prevbw = -1; int size; byte[] data; - bool off_flg = true; string arg; command.CommandText = "SELECT seqno, bandwidth, size, data FROM media\n" @@ -228,7 +219,6 @@ public bool ReadDbMedia2(ExecPsInfo epi, CommentInfo cmi, BroadCastInfo bci) using (SQLiteDataReader reader = command.ExecuteReader()) { epi.SaveFile = ExecPsInfo.GetSaveFileSqlite3Num(epi, epi.Ext2); - cmi.SaveFile = epi.SaveFile + epi.Xml; //fs = new FileStream(epi.SaveFile + epi.Ext, FileMode.Create); ecv.Add(new ExecConvert(_form)); arg = ExecPsInfo.SetConvOption(epi, null); @@ -237,11 +227,6 @@ public bool ReadDbMedia2(ExecPsInfo epi, CommentInfo cmi, BroadCastInfo bci) while (reader.Read()) { seqno = (long)reader["seqno"]; - if (off_flg) - { - cmi.Offset = bci.IsTimeShift() ? seqno * 500L : bci.Server_Time / 10L - cmi.OpenTime * 100L; - off_flg = false; - } bw = (int)(long)reader["bandwidth"]; // チャンクが飛んでいる場合はファイルを分ける // BANDWIDTHが変わる場合はファイルを分ける @@ -379,6 +364,7 @@ public bool WriteDbComment(string command_text, string mail, string user_id, str return true; } +/* public bool ReadDbComment(CommentInfo cmi, BroadCastInfo bci, NicoNetComment nNetComment) { var enc = new System.Text.UTF8Encoding(false); diff --git a/Sirrene/Record/RecHtml.cs b/Sirrene/Record/RecHtml.cs index 3ce59a5..bdedfd7 100644 --- a/Sirrene/Record/RecHtml.cs +++ b/Sirrene/Record/RecHtml.cs @@ -173,22 +173,20 @@ public override void ExecPs(string masterfile, string outfile) private async Task HtmlRecord(string masterfile, string outfile) { - long waittime = 1300; - int delaytime = 800; + long waittime = 3000; + int delaytime = 1000; try { var stime = string.Empty; -/* - stime = "&start=0.0"; if (_ndb.CountDbMedia() > 0) { var lp = _ndb.GetDbMediaLastPos(); if (lp > 0.0) stime = "&start=" + lp.ToString(); } -*/ - _form.AddExecLog("MasterFile: " + masterfile + stime + "\r\n"); + + _form.AddLog("MasterFile: " + masterfile + stime + "\r\n", 9); // masterファイルをGet var sw = new Stopwatch(); @@ -197,7 +195,7 @@ private async Task HtmlRecord(string masterfile, string outfile) sw.Stop(); if (pli.Status != "Ok" || pli.Player.Count() <= 0) { - _form.AddExecLog("GetMasterM3u8 Error: " + pli.Error + "\r\n"); + _form.AddLog("GetMasterM3u8 Error: " + pli.Error + "", 1); EndPs(2); //Retry } var seqno = _ndb.GetDbMediaLastSeqNo(); @@ -218,7 +216,7 @@ private async Task HtmlRecord(string masterfile, string outfile) var sgi = await GetPlayerM3u8Async(pli.Player.FirstOrDefault().pUrl); if (sgi.Status != "Ok" || sgi.Seg.Count() <= 0) { - _form.AddExecLog("GetPlayerM3u8 Error: " + sgi.Error + "\r\n"); + _form.AddLog("GetPlayerM3u8 Error: " + sgi.Error + "", 1); EndPs(2); //Retry break; } @@ -240,14 +238,14 @@ private async Task HtmlRecord(string masterfile, string outfile) if (!await GetSegmentAsync(item, pli, sgi)) EndPs(2); //Retry sw.Stop(); - _form.AddExecLog("SeqNo=" + sgi.SeqNo.ToString() + " " + sw.ElapsedMilliseconds.ToString() + "mSec\r\n"); + _form.AddLog("SeqNo=" + sgi.SeqNo.ToString() + " " + sw.ElapsedMilliseconds.ToString() + "mSec", 1); sgi.SeqNo++; sc++; sgi.Position += item.ExtInfo; if (PsStatus > 0) break; if (sw.ElapsedMilliseconds > waittime) { - await Task.Delay(100); + await Task.Delay(200); } else { @@ -264,7 +262,7 @@ private async Task HtmlRecord(string masterfile, string outfile) if (PsStatus > 0) break; if (sc <= 1) { - _form.AddExecLog("Wait " + delaytime.ToString() + "mSec\r\n"); + _form.AddLog("Wait " + delaytime.ToString() + "mSec", 1); await Task.Delay(delaytime); } pli.SeqNo = sgi.SeqNo; @@ -300,7 +298,7 @@ public override void BreakProcess(string breakkey) //master.m3u8からplayer.m3u8のURLを取得 public async Task GetMasterM3u8Async(string url) { - _form.AddExecLog("GetMasterFile\r\n"); + _form.AddLog("GetMasterFile", 9); var pli = new PlayListInfo(); pli.Status = "Error"; pli.Error = "PARAMERROR"; @@ -319,14 +317,14 @@ public async Task GetMasterM3u8Async(string url) int bw; while ((line = sr.ReadLine()) != null) // 1行ずつ読み出し。 { - _form.AddExecLog(line + "\r\n"); + _form.AddLog(line + "", 9); if (line.Contains("#EXT-X-STREAM-INF")) { var pi = new PlayerInfo(); if (int.TryParse(Regex.Match(line, @"[:,]BANDWIDTH=(\d+)").Groups[1].Value, out bw)) pi.Bandwidth = bw; line = sr.ReadLine(); - _form.AddExecLog(line + "\r\n"); + _form.AddLog(line + "", 9); if (!string.IsNullOrEmpty(line)) { pi.pUrl = pli.BaseUrl + line; @@ -363,7 +361,7 @@ public async Task GetMasterM3u8Async(string url) //player.m3u8からsegment情報を取得 public async Task GetPlayerM3u8Async(string url) { - _form.AddExecLog("GetPlayerFile\r\n"); + _form.AddLog("GetPlayerFile", 9); var sgi = new SegmentInfo(); sgi.Status = "Error"; sgi.Error = "PARAMERROR"; @@ -382,7 +380,7 @@ public async Task GetPlayerM3u8Async(string url) string line; while ((line = sr.ReadLine()) != null) // 1行ずつ読み出し。 { - _form.AddExecLog(line + "\r\n"); + _form.AddLog(line + "", 9); var ttt = line.Split(':'); switch (ttt[0]) { @@ -406,7 +404,7 @@ public async Task GetPlayerM3u8Async(string url) if (double.TryParse(ttt[1].Split(',')[0], out ei)) sg.ExtInfo = ei; line = sr.ReadLine(); - _form.AddExecLog(line + "\r\n"); + _form.AddLog(line + "", 9); if (!string.IsNullOrEmpty(line)) { sg.sFile = line.Split('?')[0]; @@ -447,7 +445,7 @@ public async Task GetPlayerM3u8Async(string url) //segmentファイルを取得 public async Task GetSegmentAsync(Segment seg, PlayListInfo pli, SegmentInfo sgi) { - //_form.AddExecLog("GetSegmentFile\r\n"); + //_form.AddLog("GetSegmentFile", 9); byte[] data = null; int ll; if (string.IsNullOrEmpty(seg.sUrl)) return false; @@ -458,11 +456,11 @@ public async Task GetSegmentAsync(Segment seg, PlayListInfo pli, SegmentIn if (int.TryParse(_wc.ResponseHeaders.Get("Content-Length"), out ll)) { if (ll != data.Length) - _form.AddLog("Seg " + sgi.SeqNo.ToString() + ": Size Error \r\n", 1); + _form.AddLog("Seg " + sgi.SeqNo.ToString() + ": Size Error ", 1); } ll = data.Length; - //_form.AddExecLog("Input: " + seg.sUrl + "\r\n"); - _form.AddExecLog("SeqNo=" + sgi.SeqNo.ToString() + " Size: " + data.Length.ToString() + " Content-Length: " + ll.ToString() + "\r\n"); + //_form.AddLog("Input: " + seg.sUrl + "", 9); + //_form.AddLog("SeqNo=" + sgi.SeqNo.ToString() + " Size: " + data.Length.ToString() + " Content-Length: " + ll.ToString() + "", 9); //データーをSqlite3に書き込み _ndb.WriteDbMedia(seg, pli, sgi, data, ll, 0); @@ -478,7 +476,7 @@ public async Task GetSegmentAsync(Segment seg, PlayListInfo pli, SegmentIn if (errres != null) errno = (int)errres.StatusCode; } - _form.AddExecLog("GetSegment Error: " + Ex.Status.ToString() + " (" + errno + ")\r\n"); + _form.AddLog("GetSegment Error: " + Ex.Status.ToString() + " (" + errno + ")", 1); return false; } catch (Exception Ex) //その他のエラー @@ -494,19 +492,19 @@ public async Task GetSegmentAsync(Segment seg, PlayListInfo pli, SegmentIn public async Task SetPlayControlAsync(string speed, PlayListInfo pli) { var result = false; - _form.AddExecLog("SetPlayControlAsync\r\n"); + _form.AddLog("SetPlayControlAsync", 9); try { var ttt = pli.MasterUrl.Split('?')[1].Split('&').FirstOrDefault(s => s.StartsWith("ht2_nicolive=")); var url = pli.BaseUrl + "play_control.json?" + ttt + "&play_speed="+speed; - _form.AddExecLog(url + "\r\n"); + _form.AddLog(url + "", 9); var str = await _wc.DownloadStringTaskAsync(url).Timeout(_wc.timeout); var res = JObject.Parse(str); if (res["meta"]["status"].ToString() == "200") result = true; //{ "meta":{ "status":200,"message":"ok"},"data":{ "play_control":{ "play_speed":0.25} } } - _form.AddExecLog(str + "\r\n"); + _form.AddLog(str + "", 9); } catch (WebException Ex) { @@ -518,7 +516,7 @@ public async Task SetPlayControlAsync(string speed, PlayListInfo pli) if (errres != null) errno = (int)errres.StatusCode; } - _form.AddExecLog("SetPlayControlAsync Error: " + Ex.Status.ToString() + " (" + errno + ")\r\n"); + _form.AddLog("SetPlayControlAsync Error: " + Ex.Status.ToString() + " (" + errno + ")", 1); return result; } catch (Exception Ex) //その他のエラー