public static void Main(string[] args) { try { AppDomain.CurrentDomain.UnhandledException += (sender, e) => FatalExceptionObject(e.ExceptionObject); redirect2prc = Check4Redirect2Process(ref args); CLI cli = new CLI(args); if (cli.chkParam("waitkey" )) waitkey = true; if (cli.chkParam("nowaitkey")) waitkey = false; if (cli.chkParam("help" )) { cli.displayHelp(); Quit(""); } F4F f4f = new F4F(); if (cli.chkParam("duration" )) Int32.TryParse(cli.getParam("duration"), out duration); if (cli.chkParam("filesize" )) Int32.TryParse(cli.getParam("filesize"), out filesize); if (cli.chkParam("threads" )) Int32.TryParse(cli.getParam("threads" ), out threads ); if (cli.chkParam("start" )) Int32.TryParse(cli.getParam("start" ), out start ); if (cli.chkParam("auth" )) f4f.auth = "?" + cli.getParam("auth"); if (cli.chkParam("urlbase" )) f4f.baseUrl = cli.getParam("urlbase" ); if (cli.chkParam("quality" )) f4f.quality = cli.getParam("quality" ); if (cli.chkParam("manifest" )) manifest = cli.getParam("manifest"); if (cli.chkParam("outdir" )) outDir = cli.getParam("outdir" ); if (cli.chkParam("outfile" )) outFile = cli.getParam("outfile" ); if (cli.chkParam("skip" )) skip = cli.getParam("skip" ); if (cli.chkParam("logfile" )) logfile = cli.getParam("logfile" ); if (cli.chkParam("debug" )) debug = true; if (cli.chkParam("play" )) play = true; if (cli.chkParam("showtime" )) showtime = true; if (cli.chkParam("showmlink")) showmlink = true; if (cli.chkParam("fproxy" )) fproxy = true; if (cli.chkParam("continue" )) fcontinue = true; if (cli.chkParam("post" )) HTTP.POST = true; if (cli.chkParam("referer" )) HTTP.Referer = cli.getParam("referer" ); if (cli.chkParam("cookies" )) HTTP.Cookies = cli.getParam("cookies" ); if (cli.chkParam("useragent")) HTTP.Useragent = cli.getParam("useragent"); if (cli.chkParam("username" )) HTTP.Username = cli.getParam("username" ); if (cli.chkParam("password" )) HTTP.Password = cli.getParam("password" ); if (cli.chkParam("proxy" )) HTTP.Proxy = cli.getParam("proxy" ); if (cli.chkParam("proxyuser")) HTTP.ProxyUsername = cli.getParam("proxyuser"); if (cli.chkParam("proxypass")) HTTP.ProxyPassword = cli.getParam("proxypass"); if (HTTP.Referer == "") RegExMatch(@"^(.*?://.*?/)", manifest, out HTTP.Referer); String strVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); ShowHeader("HDSdump by WendyH (K-S-V AdobeHDS based) v <c:White>" + strVersion); //if (showmlink) Program.Message("Manifest: <c:Green>" + manifest); if (manifest == "") Program.Quit("<c:Red>Please specify the manifest. (switch '<c:White>-h</c>' or '<c:White>--help</c>' for help message)"); if (showtime) ShowTimeElapsed("", true); if (Check4KnownLinks(manifest)) Program.Quit("Done."); if (outFile.IndexOf(@"\\.\pipe\") == 0) f4f.usePipe = true; if (skip != "") { string sH, sM, sS; if (RegExMatch3(@"(\d{2}):(\d{2}):(\d{2})", skip, out sH, out sM, out sS)) f4f.fromTimestamp = (((Int32.Parse(sH) * 60 * 60) + (Int32.Parse(sM) * 60) + Int32.Parse(sS)) * 1000); } else { if (fcontinue) f4f.CheckLastTSExistingFile(); } f4f.play = play; f4f.threads = threads; f4f.duration = duration; f4f.filesize = filesize; f4f.redir2Proc = redirect2prc; f4f.start = start; // Disable metadata if it invalidates the stream duration if ((f4f.fromTimestamp > 0) || (start > 0) || (duration > 0) || (filesize > 0)) f4f.metadata = false; cli.EchoSetsParameters(); f4f.DownloadFragments(manifest); Program.Quit("Done."); } catch (Exception huh) { FatalExceptionObject(huh); } }
public static void Main(string[] args) { System.Net.ServicePointManager.UseNagleAlgorithm = true; System.Net.ServicePointManager.CheckCertificateRevocationList = false; System.Net.ServicePointManager.DefaultConnectionLimit = 20; System.Net.ServicePointManager.Expect100Continue = false; try { AppDomain.CurrentDomain.UnhandledException += (sender, e) => FatalExceptionObject(e.ExceptionObject); try { isRedirected = Console.CursorVisible && false; } catch { isRedirected = true; } if (isRedirected) { Console.SetOut(new StreamWriter(Console.OpenStandardError()) { AutoFlush = true }); } Check4Redirect2Process(ref args); CLI cli = new CLI(args); if (cli.ChkParam("help")) { cli.DisplayHelpAndQuit(); } if (cli.ChkParam("version")) { cli.DisplayVersionAndQuit(); } if (cli.ChkParam("waitkey")) { waitkey = true; } if (cli.ChkParam("nowaitkey")) { waitkey = false; } if (cli.ChkParam("filesize")) { uint.TryParse(cli.GetParam("filesize"), out filesize); } if (cli.ChkParam("threads")) { int.TryParse(cli.GetParam("threads"), out threads); } if (cli.ChkParam("start")) { uint.TryParse(cli.GetParam("start"), out start); } if (cli.ChkParam("auth")) { auth = "?" + cli.GetParam("auth"); } if (cli.ChkParam("headers")) { headers = cli.GetParam("headers"); } if (cli.ChkParam("urlbase")) { baseUrl = cli.GetParam("urlbase"); } if (cli.ChkParam("quality")) { quality = cli.GetParam("quality"); } if (cli.ChkParam("manifest")) { manifestUrl = cli.GetParam("manifest"); } if (cli.ChkParam("outdir")) { outDir = cli.GetParam("outdir"); } if (cli.ChkParam("outfile")) { outFile = cli.GetParam("outfile"); } if (cli.ChkParam("logfile")) { logfile = cli.GetParam("logfile"); } if (cli.ChkParam("skip")) { fromTimestamp = GetTimestampFromString(cli.GetParam("skip")); } if (cli.ChkParam("duration")) { duration = GetTimestampFromString(cli.GetParam("duration")); } if (cli.ChkParam("debug")) { debug = true; } if (cli.ChkParam("play")) { play = true; } if (cli.ChkParam("showtime")) { showtime = true; } if (cli.ChkParam("fproxy")) { fproxy = true; } if (cli.ChkParam("continue")) { fcontinue = true; } if (cli.ChkParam("verbose")) { verbose = true; } if (cli.ChkParam("testalt")) { testalt = true; } if (cli.ChkParam("quiet")) { quiet = true; } if (cli.ChkParam("postdata")) { postData = cli.GetParam("postdata"); } if (cli.ChkParam("referer")) { HTTP.Referer = cli.GetParam("referer"); } if (cli.ChkParam("cookies")) { HTTP.Cookies = cli.GetParam("cookies"); } if (cli.ChkParam("useragent")) { HTTP.Useragent = cli.GetParam("useragent"); } if (cli.ChkParam("username")) { HTTP.Username = cli.GetParam("username"); } if (cli.ChkParam("password")) { HTTP.Password = cli.GetParam("password"); } if (cli.ChkParam("proxy")) { HTTP.Proxy = cli.GetParam("proxy"); } if (cli.ChkParam("proxyuser")) { HTTP.ProxyUsername = cli.GetParam("proxyuser"); } if (cli.ChkParam("proxypass")) { HTTP.ProxyPassword = cli.GetParam("proxypass"); } if (cli.ChkParam("osproxy")) { HTTP.UseSystemProxy = true; } if (cli.ChkParam("adkey")) { sessionKey = AkamaiDecryptor.Unhexlify(cli.GetParam("adkey")); } if (cli.ChkParam("lang")) { lang = cli.GetParam("lang"); } if (cli.ChkParam("alt")) { alt = cli.GetParam("alt"); } //if (HTTP.Referer == "") { // var m = Regex.Match(manifestUrl, @"^(.*?://.*?/)"); // if (m.Success) HTTP.Referer = m.Groups[1].Value; //} if (!string.IsNullOrEmpty(headers)) { foreach (string header in headers.Split(new char[] { '|', '$' })) { Match m = Regex.Match(header, "(.*?):(.*)"); if (m.Success) { string name = m.Groups[1].Value; string value = m.Groups[2].Value; switch (name.ToLower()) { case "referer": HTTP.Referer = value; break; case "useragent": case "user-agent": HTTP.Useragent = value; break; default: HTTP.Headers.Set(name, value); break; } } } } ShowHeader("HDSdump by WendyH v<c:White>" + Version); if (manifestUrl == "") { Quit("<c:Red>Please specify the manifest. (switch '<c:White>-h</c>' or '<c:White>--help</c>' for help message)"); } if (showtime) { ShowTimeElapsed("", true); } Check4KnownLinks(manifestUrl); cli.Params["manifest"] = manifestUrl; if (HTTP.Referer.Length > 0) { cli.Params["referer"] = HTTP.Referer; } bool usePipe = outFile.IndexOf(@"\\.\pipe\") == 0; cli.Params["threads"] = threads.ToString(); cli.Params["outfile"] = redir2Prog != null ? redir2Prog.ProcessName : (isRedirected && !usePipe ? "<redirected>" : outFile); cli.EchoSetsParameters(); if (!cli.ChkParam("oldmethod")) { HDSDumper HdsDumper = new HDSDumper(); HdsDumper.FLVFile.outFile = outDir + outFile; HdsDumper.FLVFile.play = play; HdsDumper.FLVFile.usePipe = usePipe; HdsDumper.Downloader.maxThreads = threads; HdsDumper.duration = duration; HdsDumper.filesize = filesize; HdsDumper.start = start; HdsDumper.auth = auth; HdsDumper.baseUrl = baseUrl; HdsDumper.quality = quality; HdsDumper.postData = postData; HdsDumper.lang = lang; HdsDumper.alt = alt; HdsDumper.testalt = testalt; HdsDumper.fromTimestamp = fromTimestamp; HdsDumper.sessionKey = sessionKey; if (fcontinue) { HdsDumper.FLVFile.GetLastTimestampFromExistingFile(); HdsDumper.fromTimestamp = HdsDumper.FLVFile.LastTimestamp; } if (ConsolePresent) { Console.CancelKeyPress += delegate { HdsDumper?.ShowMessageAtTheEnd(); HdsDumper?.FixFileMetadata(); }; } try { Message("Processing manifest info..."); HdsDumper.StartDownload(manifestUrl); } catch (Exception e) { HdsDumper.DestroyUpdateStatusTimer(); Message("\r\n<c:Red>" + e.Message); } finally { HdsDumper.ShowMessageAtTheEnd(); HdsDumper.FixFileMetadata(); } if (!string.IsNullOrEmpty(HdsDumper.Status)) { Quit(HdsDumper.Status); } else { Quit("Done."); } } // ========== OLD METHOD ========== F4FOldMethod f4f = new F4FOldMethod(); // Disable metadata if it invalidates the stream duration if ((f4f.fromTimestamp > 0) || (start > 0) || (duration > 0) || (filesize > 0)) { f4f.metadata = false; } f4f.fromTimestamp = fromTimestamp; f4f.usePipe = usePipe; f4f.play = play; f4f.threads = threads; f4f.duration = (int)duration; f4f.filesize = (int)filesize; f4f.start = (int)start; f4f.ad.sessionKey = sessionKey; f4f.auth = auth; f4f.baseUrl = baseUrl; f4f.quality = quality; f4f.PostData = postData; f4f.Lang = lang; f4f.alt = alt; if (fcontinue) { f4f.CheckLastTSExistingFile(); } f4f.DownloadFragments(manifestUrl); Quit("Done."); } catch (Exception huh) { FatalExceptionObject(huh); } }