public static String extractDownloadUri(string episodeUri) { Console.WriteLine("Extracting Download URL for {0}", episodeUri); WebClient wc = new WebClient(); string Data = wc.DownloadString(episodeUri); buffer3 = new mshtml.HTMLDocument(); wc.Dispose(); buffer3.designMode = "off"; buffer4 = (mshtml.IHTMLDocument2)buffer3; buffer4.write(Data); // beware the hang. Expressions.vidStreamRegex = new Regex(Expressions.videoIDRegex); IHTMLElementCollection col = buffer3.getElementsByTagName("IFRAME"); Match match; string id = null; foreach (IHTMLElement elem in col) { match = Expressions.vidStreamRegex.Match(elem.getAttribute("src")); if (match.Success) { id = match.Groups[0].Value; break; } else { return(null); } } col = null; buffer3.clear(); buffer4.clear(); Task <String> response = Storage.client.GetStringAsync($"https://vidstreaming.io/ajax.php?id={id}"); Expressions.vidStreamRegex = new Regex(Expressions.downloadLinkRegex); match = Expressions.vidStreamRegex.Match(response.Result); if (match.Success) { string ursTruly = match.Groups[0].Value.Replace("\\", string.Empty); int ids = Extensions.indexOfEquals(ursTruly) + 1; if (ursTruly.Contains("goto.php")) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ursTruly); request.AutomaticDecompression = DecompressionMethods.GZip; WebResponse res = request.GetResponse(); string s = res.ResponseUri.ToString(); return(s); } else { return(ursTruly); } } return(null); }
private void File_Print(object sender, RoutedEventArgs e) { string printContents; printContents = ViewModel.GetPrintContents(); mshtml.IHTMLDocument2 doc = webBrowser1.Document as mshtml.IHTMLDocument2; doc.clear(); doc.write(printContents); doc.execCommand("Print", true, 0); doc.close(); }
private void File_PrintPreview(object sender, RoutedEventArgs e) { string printContents; printContents = ViewModel.GetPrintContents(); mshtml.IHTMLDocument2 doc = webBrowser1.Document as mshtml.IHTMLDocument2; doc.clear(); doc.write(printContents); doc.close(); ViewModel.SetPrintControlsVisibility(true); }
private async Task <bool> ParseHTML(HttpContent content) { UpdateStatus(">> Trying to parse a HTML document..."); //Stream st = content.ReadAsStreamAsync().Result; string s = await content.ReadAsStringAsync(); UpdateStatus(">> Loading a HTML document..."); mshtml.HTMLDocument hd = new mshtml.HTMLDocument(); mshtml.IHTMLDocument2 hdoc = (mshtml.IHTMLDocument2)hd; IPersistStreamInit ips = (IPersistStreamInit)hdoc; ips.InitNew(); hdoc.designMode = "On"; hdoc.clear(); hdoc.write(s); hdoc.close(); // In Delphi, it's just // hdoc:= CreateComObject(Class_HTMLDocument) as IHTMLDocument2; // (hdoc as IPersistStreamInit).Load(TStreamAdapter.Create(Response.Stream)); int i = 0; while (hdoc.readyState != "complete") { await Task.Delay(100); if (i > 500) { throw new Exception(string.Format("The document {0} timed out while loading", "IHTMLDocument2")); } i++; } if (hdoc.readyState == "complete") { UpdateStatus(">> Checking HTML link tags..."); IHTMLElementCollection ElementCollection = hdoc.all; foreach (var e in ElementCollection) { if ((e as IHTMLElement).tagName == "LINK") { string re = (e as IHTMLElement).getAttribute("rel", 0); if (!string.IsNullOrEmpty(re)) { if (re.ToUpper() == "EDITURI") { string hf = (e as IHTMLElement).getAttribute("href", 0); if (!string.IsNullOrEmpty(hf)) { _serviceDocKind = _serviceDocumentKind.RSD; _serviceDocUrl = hf; Debug.WriteLine("ServiceDocumentKind is: RSD " + _serviceDocUrl); UpdateStatus("Found a link to a RSD documnet."); } } else if (re.ToUpper() == "SERVICE") { string ty = (e as IHTMLElement).getAttribute("type", 0); if (!string.IsNullOrEmpty(ty)) { if (ty == "application/atomsvc+xml") { string hf = (e as IHTMLElement).getAttribute("href", 0); if (!string.IsNullOrEmpty(hf)) { _serviceDocKind = _serviceDocumentKind.AtomSrv; _serviceDocUrl = hf; Debug.WriteLine("ServiceDocumentKind is: AtomSrv " + _serviceDocUrl); UpdateStatus("Found a link to an Atom service documnet."); } } } } else if (re.ToUpper() == "ALTERNATE") { string ty = (e as IHTMLElement).getAttribute("type", 0); if (!string.IsNullOrEmpty(ty)) { if (ty == "application/atom+xml") { string hf = (e as IHTMLElement).getAttribute("href", 0); if (!string.IsNullOrEmpty(hf)) { Debug.WriteLine("Atom feed found."); try { _atomFeedUrl = new Uri(hf); } catch { } UpdateStatus("Found a link to an Atom feed."); } } } } } } } } return(true); }