public static string nav(string sUrl) { WebGet wg = new WebGet(sUrl, ""); while (wg.State != WebGet.eState.Completed && wg.State != WebGet.eState.Failed) { System.Threading.Thread.Sleep(1); } return(wg.sRBody); }
public static int[] get(string sUrl, string sFName, int iSpan) { WebGet wg = new WebGet(sUrl, "", GUI.sAppPath + sFName); while (wg.iLen == 0) { System.Threading.Thread.Sleep(1); } int iPrCnt = 0; double dPrStp = (double)wg.iLen / (double)iSpan; while (true) { if (dPrStp > 0.01) { int iPrInc = (int)Math.Round((double)wg.iRecv / dPrStp) - iPrCnt; if (iPrInc > 0) { iPrCnt += iPrInc; string sPrInc = ""; for (int a = 0; a < iPrInc; a++) { sPrInc += "*"; } PSG.inf(sPrInc); } } if (wg.State == WebGet.eState.Completed || wg.State == WebGet.eState.Failed) { break; } System.Threading.Thread.Sleep(10); } if (wg.State == WebGet.eState.Failed) { PSG.inf("error"); return(new int[] { -2, -1 }); } int iPad = iSpan - iPrCnt; if (iSpan != 0 && iPad > 0) { PSG.inf(new string(' ', iPad)); } return(new int[] { wg.iLen, wg.iRecv }); }
public static void tryGrab() { if (bGrab) { return; } bGrab = true; if (!isDowning() && isGood() && alQue.Count == 0) { bGrab = false; return; } for (int a = 0; a < Cli.Length; a++) { if (Cli[a] == null || Cli[a].State == WebGet.eState.Completed || Cli[a].State == WebGet.eState.Ready) { if (alQue.Count == 0) { break; } FileDL fDL = (FileDL)alQue[0]; if (a >= fDL.scConf.iThreads) { break; } alQue.RemoveAt(0); PSG.infln(string.Format(" {0,-40} [", sMLen((a + 1) + ": " + fDL.sFName, 40))); if (System.IO.File.Exists(fDL.sFPath + fDL.sFName)) { PSG.inf("Exists"); } else { PSG.inf("Downloading"); Cli[a] = new WebGet(fDL); } } if (Cli[a] != null && Cli[a].State == WebGet.eState.Failed) { string sOut = string.Format(" {0,-40} [", sMLen((a + 1) + ": " + Cli[a].Info.sFName, 40)); string sAbsPath = Cli[a].Info.sFPath + Cli[a].Info.sFName; if (Cli[a].Info.scConf.fcAct == ServCF.FileCut.Ignore) { sOut = "/" + sOut; iCutFile_ignore++; sOut += "DC - Ignore #" + iCutFile_ignore; Cli[a].State = WebGet.eState.Ready; PSG.infln(sOut); } if (Cli[a].Info.scConf.fcAct == ServCF.FileCut.Kill) { sOut = "X" + sOut; iCutFile_skip++; System.IO.File.Delete(sAbsPath); sOut += "DC - Delete #" + iCutFile_skip; Cli[a].State = WebGet.eState.Ready; PSG.infln(sOut); } if (Cli[a].Info.scConf.fcAct == ServCF.FileCut.RetryIgnore || Cli[a].Info.scConf.fcAct == ServCF.FileCut.RetryKill) { if (Cli[a].Info.fcReCnt < Cli[a].Info.scConf.fcReLim) { sOut = "~" + sOut; Cli[a].Info.fcReCnt++; System.IO.File.Delete(sAbsPath); sOut += "DC - Retry #" + Cli[a].Info.fcReCnt; Cli[a] = new WebGet(Cli[a].Info); PSG.infln(sOut); } else { if (Cli[a].Info.scConf.fcAct == ServCF.FileCut.RetryIgnore) { sOut = "/" + sOut; iCutFile_ignore++; sOut += "DC - Ignore #" + iCutFile_ignore; Cli[a].State = WebGet.eState.Ready; PSG.infln(sOut); } else { sOut = "X" + sOut; iCutFile_skip++; System.IO.File.Delete(sAbsPath); sOut += "DC - Delete #" + iCutFile_skip; Cli[a].State = WebGet.eState.Ready; PSG.infln(sOut); } } } } } bGrab = false; }