private void startRecording(string lvid, bool isPlayOnlyMode) { util.setProxy(cfg, form); isRecording = true; form.formAction(() => { form.urlText.Text = "https://live2.nicovideo.jp/watch/" + lvid; setRecModeForm(true); form.resetDisplay(); recordingUrl = form.urlText.Text; }, false); rfu = new RecordFromUrl(this, isPlayOnlyMode); Task.Run(() => { try { var _rfu = rfu; util.debugWriteLine("rm rec 録画開始" + rfu); util.debugWriteLine(form.urlText.Text); var rfuCode = rfu.GetHashCode(); recordRunningList.Add(rfuCode); //endcode 0-その他の理由 1-stop 2-最初に終了 3-始まった後に番組終了 var endCode = rfu.rec(form.urlText.Text, lvid); util.debugWriteLine("endcode " + endCode); recordRunningList.Remove(rfuCode); endProcess(endCode, rfu == _rfu); } catch (Exception e) { util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite); rfu = null; setRecModeForm(false); } }); }
/* * async Task<int> test(int a) { * //util.debugWriteLine(a); * //c += a; * return a; * } */ async public void rec() { util.debugWriteLine("rm"); var lv = util.getRegGroup(form.urlText.Text, "(lv\\d+(,\\d+)*)"); var wssUrl = util.getRegGroup(form.urlText.Text, "^(wss://[^,\\s]+)"); util.setLog(cfg, lv); util.debugWriteLine(util.versionStr + " " + util.versionDayStr); if (rfu == null) { var arr = form.urlText.Text.Split('|'); // var arr = "C:\\Users\\zack\\Desktop\\c#project\\nicoNewStreamRecorderKakkoKariRepo2 9.26 tuujou a\\nicoNewStreamRecorderKakkoKari\\namaichi\\bin\\Debug\\rec\\株式会社ジャパンミュージックエージェンシー\\株式会社ジャパンミュージックエージェンシー_0.ts".Split('|'); var lvid = lv; //util.getRegGroup(form.urlText.Text, "(lv\\d+(,\\d+)*)", 1); if (lvid != null || wssUrl != null) { var url = lvid != null ? ("http://live2.nicovideo.jp/watch/" + lvid) : wssUrl; if (isPlayOnlyMode) { form.Invoke((MethodInvoker) delegate() { form.urlText.Text = url; }); } else { form.urlText.Text = url; } // if (lvid != null) form.urlText.Text = "https://cas.nicovideo.jp/user/77252622/lv313508832"; } else { if (isPlayOnlyMode) { form.Invoke((MethodInvoker) delegate() { MessageBox.Show("not found lvid"); }); } else { MessageBox.Show("not found lvid"); } return; } form.setQualityList(new string[] {}, ""); var q = form.qualityBox.Items; isRecording = true; if (isPlayOnlyMode) { form.Invoke((MethodInvoker) delegate() { form.recBtn.Text = "中断"; form.urlText.Enabled = false; form.optionMenuItem.Enabled = false; //form.resetDisplay(); recordingUrl = form.urlText.Text; }); } else { form.recBtn.Text = "中断"; form.urlText.Enabled = false; form.optionMenuItem.Enabled = false; //form.resetDisplay(); recordingUrl = form.urlText.Text; } rfu = new RecordFromUrl(this); Task.Run(() => { try { var _rfu = rfu; util.debugWriteLine("rm rec 録画開始" + rfu); util.debugWriteLine(form); util.debugWriteLine(form.urlText); util.debugWriteLine(form.urlText.Text); var rfuCode = rfu.GetHashCode(); recordRunningList.Add(rfuCode); //endcode 0-その他の理由 1-stop 2-最初に終了 3-始まった後に番組終了 var endCode = rfu.rec(form.urlText.Text, lvid, wssUrl); util.debugWriteLine("endcode " + endCode); recordRunningList.Remove(rfuCode); if (rfu == _rfu) { isRecording = false; rfu = null; if (!form.IsDisposed && util.isShowWindow) { try { form.Invoke((MethodInvoker) delegate() { try { form.recBtn.Text = "録画開始"; form.urlText.Enabled = true; form.optionMenuItem.Enabled = true; } catch (Exception e) { util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite); } }); } catch (Exception e) { util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite); } } util.debugWriteLine("end rec " + rfu); if (!isClickedRecBtn && endCode == 3) { Environment.ExitCode = 5; if (util.isShowWindow) { try { form.Invoke((MethodInvoker) delegate() { try { form.Close(); } catch (Exception e) { util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite); } }); } catch (Exception e) { util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite); } } } hlsUrl = null; recordingUrl = null; } if (bool.Parse(cfg.get("IscloseExit")) && endCode == 3) { rfu = null; Environment.ExitCode = 5; if (util.isShowWindow) { try { form.Invoke((MethodInvoker) delegate() { try { form.Close(); form.addLogText("終了しました。"); } catch (Exception e) { util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite); } }); } catch (Exception e) { util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite); } } } if (util.isStdIO && (endCode == 0 || endCode == 2 || endCode == 3)) { form.Invoke((MethodInvoker) delegate() { try { form.Close(); } catch (Exception e) { util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite); } }); } } catch (Exception e) { util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite); rfu = null; form.Invoke((MethodInvoker) delegate() { try { form.recBtn.Text = "録画開始"; form.urlText.Enabled = true; form.optionMenuItem.Enabled = true; } catch (Exception ee) { util.debugWriteLine(ee.Message + " " + ee.StackTrace + " " + ee.Source + " " + ee.TargetSite); } }); } }); } else { stopRecording(); } }