public void DownloadVideo() { string sTmpDir = BasePath + '\\' + PathHelper.ReplaceLimitChar(TidalVideo.Title, "-") + "TMP" + RandHelper.GetIntRandom(5, 9, 0); try { if (Directory.Exists(sTmpDir)) { Directory.Delete(sTmpDir, true); } PathHelper.Mkdirs(sTmpDir); long lCount = TidalVideoUrls.Count(); for (int i = 0; i < lCount; i++) { string sUrl = TidalVideoUrls[i]; string sName = sTmpDir + '\\' + (100000 + i + 1).ToString() + ".ts"; bool bFlag = (bool)DownloadFileHepler.Start(sUrl, sName, Timeout: 9999 * 1000); if (bFlag == false) { Progress.Errlabel = "Download failed!"; goto ERR_POINT; } Progress.Update(i + 1, lCount); if (Progress.IsCanceled) { goto CANCEL_POINT; } } if (!MergerTsFiles(sTmpDir + '\\', FilePath)) { Progress.Errlabel = "FFmpeg merger err!"; goto ERR_POINT; } Progress.Update(lCount, lCount); Progress.IsComplete = true; UpdataFunc(this); CANCEL_POINT: if (Directory.Exists(sTmpDir)) { Directory.Delete(sTmpDir, true); } return; } catch (Exception e) { Progress.Errlabel = "Err!" + e.Message; } ERR_POINT: Progress.IsErr = true; UpdataFunc(this); if (Directory.Exists(sTmpDir)) { Directory.Delete(sTmpDir, true); } }
public void DownloadVideo() { string sTmpDir = BasePath + '\\' + PathHelper.ReplaceLimitChar(TidalVideo.Title, "-") + "TMP"; if (Directory.Exists(sTmpDir)) { Directory.Delete(sTmpDir, true); } PathHelper.Mkdirs(sTmpDir); long lCount = TidalVideoUrls.Count(); for (int i = 0; i < lCount; i++) { string sUrl = TidalVideoUrls[i]; string sName = sTmpDir + '\\' + (100000 + i + 1).ToString() + ".ts"; bool bFlag = (bool)DownloadFileHepler.Start(sUrl, sName, RetryNum: 3); if (bFlag == false) { Progress.Errlabel = "Download failed!"; goto ERR_POINT; } Progress.Update(i + 1, lCount); if (Progress.IsCancle) { goto CANCLE_POINT; } } if (!MergerTsFiles(sTmpDir + '\\', FilePath)) { Progress.Errlabel = "FFmpeg merger err!"; goto ERR_POINT; } Progress.Update(lCount, lCount); Progress.IsComplete = true; UpdataFunc(this); CANCLE_POINT: Directory.Delete(sTmpDir, true); return; ERR_POINT: Progress.IsErr = true; UpdataFunc(this); Directory.Delete(sTmpDir, true); }