Ejemplo n.º 1
0
        /// <summary>
        /// Loads the anchors for a specified html file
        /// </summary>
        /// <param name="fileName">The file name in which anchors are to be retrieved from</param>
        private void LoadAnchors(string fileName)
        {
            WebClient client = new WebClient();

            byte[] data = client.DownloadData(fileName);
            mshtml.HTMLDocumentClass ms = new mshtml.HTMLDocumentClass();
            string strHTML = Encoding.ASCII.GetString(data);

            mshtml.IHTMLDocument2 mydoc = (mshtml.IHTMLDocument2)ms;
            //mydoc.write(!--saved from url=(0014)about:internet -->);
            mydoc.write(strHTML);

            mshtml.IHTMLElementCollection ec = (mshtml.IHTMLElementCollection)mydoc.all.tags("a");
            if (ec != null)
            {
                for (int i = 0; i < ec.length - 1; i++)
                {
                    mshtml.HTMLAnchorElementClass anchor;
                    anchor = (mshtml.HTMLAnchorElementClass)ec.item(i, 0);

                    if (!string.IsNullOrEmpty(anchor.name))
                    {
                        cmbAnchor.Items.Add(anchor.name);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static String Search(string name)
        {
            buffer1 = new mshtml.HTMLDocument();
            buffer2 = (mshtml.IHTMLDocument2)buffer1;
            Console.WriteLine("Downloading search page for: {0}", name);
            string Data = Storage.wc.DownloadString($"https://vidstreaming.io/search.html?keyword={name}");

            buffer2.write(Data); // Write all the data to buffer1 so that we can enumerate it.
            mshtml.IHTMLElementCollection collection;
            Console.WriteLine("Searching for video-block");
            collection = buffer1.getElementsByTagName("li"); //Get all collections with the <li> tag.
            foreach (mshtml.IHTMLElement obj in collection)
            {
                if (obj.className == "video-block " || obj.className == "video-block click-hover") //if the element has a classname of "video-block " then we are dealing with a show.
                {
                    Console.WriteLine("Found video-block!");
                    node = obj; // set node to object.
                    break;      // escape the foreach loop.
                }
            }
            Expressions.vidStreamRegex = new Regex(Expressions.searchVideoRegex); // Don't say anything about parsing html with REGEX. This is a better than importing another library for this case.
            if (node == null)
            {
                return("E");
            }
            Match m = Expressions.vidStreamRegex.Match(node.innerHTML);

            return(m.Groups.Count >= 1 ? "https://vidstreaming.io" + m.Groups[1].Value : "E");
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        public static String FindAllVideos(string link, Boolean dwnld, [Optional] String fileDestDirectory)
        {
            Console.WriteLine($"Found link: {link}\nDownloading Page...");
            string Data = Storage.wc.DownloadString(link);

            buffer1 = new mshtml.HTMLDocument();
            buffer2 = (mshtml.IHTMLDocument2)buffer1;
            buffer2.write(Data); //(Again) write data to buffer1 so we can enumerate.
            mshtml.IHTMLElementCollection collection;
            Console.WriteLine("Searching for Videos");
            collection = buffer1.getElementsByTagName("li");            // split by the tag <li>
            string mainVidUri = link.Split('/').Last().TrimIntegrals(); // Trim trailing numbers.

            Expressions.vidStreamRegex = new Regex(String.Format("(?<=<A href=\"/videos/{0}).*?(?=\">)", mainVidUri));

            List <String> videoUrls = new List <string>();
            string        val       = null;
            Match         regMax;
            int           id = 0;

            Console.WriteLine(collection.length);
            foreach (mshtml.IHTMLElement obj in collection) // Search for all elements containing "video-block " as a class name and matches them to our trimmed url.
            {
                if (obj.className == "video-block " || obj.className == "video-block click_hover")
                {
                    regMax = Expressions.vidStreamRegex.Match(obj.innerHTML);
                    if (regMax.Success)
                    {
                        val = "https://vidstreaming.io/videos/" + mainVidUri + regMax.Groups[0].Value;
                        Console.WriteLine("Found a video-block! Adding to list, {0} |", val);
                        videoUrls.Add(val);
                        switch (dwnld)
                        {
                        case true:    //case 0:
                        {
                            Download.FileDest = fileDestDirectory + $"\\{id + 1}_{Storage.Aniname}.mp4";
                            if (Program.multTthread)
                            {
                                if (!Download.dwS && Download.downloadLinks.Length >= 1)
                                {
                                    Download.QueueDownload(val);
                                    Download.StartDownload();
                                }
                                else
                                {
                                    Download.QueueDownload(val);
                                }
                            }
                            else
                            {
                                Download.GetM3u8Link(val);
                            }
                            id++;
                            continue;
                            //break;
                        }

                        case false:
                        {
                            System.IO.File.AppendAllText($"{fileDestDirectory}_VDLI_temp.txt", $"\n{val}");
                            continue;
                        }

                        default:
                            continue;
                            //break;
                        }
                    }
                }
            }
            return(dwnld ? null : $"{fileDestDirectory}_VDLI_temp.txt");
        }