private static List<Episode> ScanForEpisodes(string html, string siteLinkNameExtension)
        {
            List<Episode> episodes = new List<Episode>();
            html = html.GetSubstringBetween(0, "<div style=\"font-size:14px;\">", "</div>");
                
            List<string> linkList = new List<string>(html.Split('"'));
            for (int i = 0; i < linkList.Count; i++)
            {
                if (!linkList[i].Contains("http")) linkList.RemoveAt(i--);
            }
            for (int i = (linkList.Count - 1); i >= 0; i--)
            {
                Episode e = new Episode();
                string link = linkList[i];

                e.AddLink(DubbedanimehdTvStreamingSite.NAME, link);
                e.Number = episodes.Count + 1;
                e.Name = "Episode " + e.Number.ToString();
                e.Season = 0;

                episodes.Add(e);
                FormMain.SeriesOpenCallback(e);
            }
            
            return episodes;
        }
        private async static Task<List<Episode>> ScanForEpisodes(string html, string seriesName)
        {
            List<Episode> episodes = new List<Episode>();

            string list = await Util.RequestSimplifiedHtmlSiteAsync(html.GetSubstringBetween(0, "$(\"#load\").load('", "')"));

            int startIndex = list.IndexOf("<table id=\"episode-list-entry-tbl\">");
            if (startIndex == -1) return episodes;
            int endIndex = list.IndexOf("</table>");
            if (endIndex == -1) return episodes;

            string linkStart = "<a href=\"";
            string linkEnd = "\" title=\"";
            string nameStart = "<h2>";
            string nameEnd = "</h2>";

            int currentIndex = startIndex;
            while (currentIndex != -1 && currentIndex < endIndex)
            {
                string link = list.GetSubstringBetween(currentIndex, linkStart, linkEnd, out currentIndex);
                if (currentIndex == -1) continue; 
                string name = list.GetSubstringBetween(currentIndex, nameStart, nameEnd, out currentIndex)
                    .Replace(seriesName + " ", "")
                    .Replace(" English Dubbed", "");
                name = name.Trim();
                if (currentIndex == -1) continue;

                Episode e = new Episode();
                e.Season = 1;
                e.Name = name;
                e.AddLink(CartooncrazyStreamingSite.NAME, "http://www.cartooncrazy.net" + link);
                episodes.Add(e);
            }

            var orderedList = new List<Episode>(episodes.Count);
            for (int i = (episodes.Count - 1); i >= 0; i--)
            {
                episodes[i].Number = episodes.Count - i;
                orderedList.Add(episodes[i]);
            }

            return orderedList;
        }
        private static List<Episode> ExtractEpisodesFromHtml(int seasonNumber, string html, string siteLinkNameExtension, Control threadAnchor)
        {
            var episodes = new List<Episode>();
            int episodeNumber = 0;
            int episodeIndex = 0;
            var episodeIndices = new List<int>();
            Application.DoEvents();
            //Scan for all episode indices.
            do
            {
                string searchString = "<td>" + ++episodeNumber + "</td><td><a href=\"serie/" + siteLinkNameExtension + "/" + seasonNumber;
                episodeIndex = html.IndexOf(searchString, episodeIndex);
                if (episodeIndex != -1)
                {
                    episodeIndices.Add(episodeIndex);
                }
            } while (episodeIndex != -1);

            //Scan for episodes
            for (int i = 0; i < episodeIndices.Count; i++)
            {
                episodeIndex = episodeIndices[i];
                Episode e = null;
                int index = episodeIndex;
                string name = html.GetSubstringBetween(index, "<strong>", "</strong>", out index);
                if (name == "" || (i != episodeIndices.Count - 1 && index > episodeIndices[i + 1]))
                {
                    index = episodeIndex;
                    name = "";
                }
                string nameExt = html.GetSubstringBetween(index, "<span lang=\"en\">", "</span>", out index);
                if (nameExt == "" || (i != episodeIndices.Count - 1 && index > episodeIndices[i + 1]))
                {
                    index = episodeIndex;
                    nameExt = "";
                }
                else
                {
                    name += " (" + nameExt + ")";
                }
                e = new Episode(seasonNumber, i + 1, name);

                /*
                int indexVivo = html.IndexOf(VIVO_SEARCH, index);
                if (indexVivo != -1)    //check if a vivo link is found
                {
                    if (!(i + 1 < episodeIndices.Count) || ((i + 1 < episodeIndices.Count) && (indexVivo < episodeIndices[i + 1])))  //check if the streamcloud link is before the next episode.
                    {
                        string vivoSite = "http://bs.to/" + html.GetSubstringBetween(indexVivo, VIVO_SEARCH, "\"");
                        e.AddLink(BsToVivoStreamingSite.NAME, vivoSite);
                    }
                }

                int indexStreamcloud = html.IndexOf(STREAMCLOUD_SEARCH, index);
                if (indexStreamcloud != -1)    //check if a streamcloud link is found
                {
                    if (!(i + 1 < episodeIndices.Count) || ((i + 1 < episodeIndices.Count) && (indexStreamcloud < episodeIndices[i + 1])))  //check if the streamcloud link is before the next episode.
                    {
                        string streamcloudSite = "http://bs.to/" + html.GetSubstringBetween(indexStreamcloud, STREAMCLOUD_SEARCH, "\"");
                        e.AddLink(BsToStreamcloudStreamingSite.NAME, streamcloudSite);
                    }
                }
                */

                int indexOpenload = html.IndexOf(OPENLOAD_SEARCH, index);
                if (indexOpenload != -1)    //check if a streamcloud link is found
                {
                    if (!(i + 1 < episodeIndices.Count) || ((i + 1 < episodeIndices.Count) && (indexOpenload < episodeIndices[i + 1])))  //check if the streamcloud link is before the next episode.
                    {
                        string openloadSite = "http://bs.to/" + html.GetSubstringBetween(indexOpenload, OPENLOAD_SEARCH, "\"");
                        e.AddLink(BsToOpenLoadSite.NAME, openloadSite);
                    }
                }

                int indexOpenloadHD = html.IndexOf(OPENLOAD_HD_SEARCH, index);
                if (indexOpenloadHD != -1)    //check if a streamcloud link is found
                {
                    if (!(i + 1 < episodeIndices.Count) || ((i + 1 < episodeIndices.Count) && (indexOpenloadHD < episodeIndices[i + 1])))  //check if the streamcloud link is before the next episode.
                    {
                        string openloadHDSite = "http://bs.to/" + html.GetSubstringBetween(indexOpenloadHD, OPENLOAD_HD_SEARCH, "\"");
                        e.AddLink(BsToOpenLoadHDSite.NAME, openloadHDSite);
                    }
                }

                threadAnchor.Invoke((MethodInvoker)(() => FormMain.SeriesOpenCallback(e)));
                episodes.Add(e);
            }
            return episodes;
        }