Esempio n. 1
0
        public void PopulateTorrentLink(ref TorrentLinkVM torLink)
        {
            try
            {
                if (string.IsNullOrEmpty(UserSettingsVM.Instance.BakaBTUsername) || string.IsNullOrEmpty(UserSettingsVM.Instance.BakaBTPassword))
                {
                    return;
                }

                if (string.IsNullOrEmpty(UserSettingsVM.Instance.BakaBTCookieHeader))
                {
                    string cookie = Login(UserSettingsVM.Instance.BakaBTUsername, UserSettingsVM.Instance.BakaBTPassword);
                    UserSettingsVM.Instance.BakaBTCookieHeader = cookie;
                }

                if (string.IsNullOrEmpty(UserSettingsVM.Instance.BakaBTCookieHeader))
                {
                    return;
                }

                string url    = torLink.TorrentLinkFull;
                string output = Utils.DownloadWebPage(url, UserSettingsVM.Instance.BakaBTCookieHeader, true);

                string torDownloadLink = GetTorrentLinkFromTorrentPage(output);
                torLink.TorrentDownloadLink = string.Format("https://bakabt.me/{0}", torDownloadLink);
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
                return;
            }
        }
Esempio n. 2
0
 public void PopulateTorrentDownloadLink(ref TorrentLinkVM torLink)
 {
     if (TorrentSource == TorrentSourceType.BakaBT)
     {
         if (string.IsNullOrEmpty(torLink.TorrentDownloadLink))
         {
             TorrentsBakaBT bakbt = new TorrentsBakaBT();
             bakbt.PopulateTorrentLink(ref torLink);
         }
     }
     return;
 }
Esempio n. 3
0
		public void PopulateTorrentDownloadLink(ref TorrentLinkVM torLink)
		{
			if (TorrentSource == TorrentSourceType.BakaBT)
			{
				if (string.IsNullOrEmpty(torLink.TorrentDownloadLink))
				{
					TorrentsBakaBT bakbt = new TorrentsBakaBT();
					bakbt.PopulateTorrentLink(ref torLink);
				}
			}
			return;
		}
        private List<TorrentLinkVM> ParseSource(string output)
        {
            List<TorrentLinkVM> torLinks = new List<TorrentLinkVM>();

            char q = (char)34;
            string quote = q.ToString();

            //<td class="name">

            // remove html codes
            string rubbish1 = "<span class=" + quote + "highlight" + quote + ">";
            string rubbish2 = "</span>";

            //string startBlock = "<td class=" + quote + "name" + quote;
            string startBlock = "<td class=" + quote + "category";
            string altBlock = "class=" + quote + "alt_title" + quote;

            string catStart = "title=" + quote;
            string catEnd = quote;

            string linkStart = "href=" + quote;
            string linkEnd = quote;

            string nameStart = "title=" + quote + "Download torrent:";
            string nameStart2 = quote + ">";
            string nameEnd = "</a>";

            string sizeStart = "<td class=" + quote + "size" + quote + ">";
            string sizeEnd = "</td>";

            string seedInit = "<td class=" + quote + "peers" + quote + ">";
            string seedStart = quote + ">";
            string seedEnd = "</a>";

            string leechStart = quote + ">";
            string leechEnd = "</a>";

            int pos = output.IndexOf(startBlock, 0);
            while (pos > 0)
            {

                if (pos <= 0) break;

                int poscatStart = output.IndexOf(catStart, pos + 1);
                int poscatEnd = output.IndexOf(catEnd, poscatStart + catStart.Length + 1);

                string cat = output.Substring(poscatStart + catStart.Length, poscatEnd - poscatStart - catStart.Length);

                int poslinkStart = output.IndexOf(linkStart, poscatEnd + 1);
                int poslinkEnd = output.IndexOf(linkEnd, poslinkStart + linkStart.Length + 1);

                string link = output.Substring(poslinkStart + linkStart.Length, poslinkEnd - poslinkStart - linkStart.Length);

                int posnameStart = output.IndexOf(nameStart, poslinkEnd);
                int posnameStart2 = output.IndexOf(nameStart2, posnameStart + nameStart.Length);
                int posnameEnd = output.IndexOf(nameEnd, posnameStart2 + nameStart2.Length + 1);

                string torName = output.Substring(posnameStart2 + nameStart2.Length, posnameEnd - posnameStart2 - nameStart2.Length);

                torName = torName.Replace(rubbish1, "");
                torName = torName.Replace(rubbish2, "");

                // remove html codes
                torName = HttpUtility.HtmlDecode(torName);

                //Console.WriteLine("{0} - {1}", posNameStart, posNameEnd);

                string torSize = "";
                int posSizeStart = output.IndexOf(sizeStart, posnameEnd);
                int posSizeEnd = 0;
                if (posSizeStart > 0)
                {
                    posSizeEnd = output.IndexOf(sizeEnd, posSizeStart + sizeStart.Length + 1);

                    torSize = output.Substring(posSizeStart + sizeStart.Length, posSizeEnd - posSizeStart - sizeStart.Length);
                }

                int posSeedInit = output.IndexOf(seedInit, posSizeEnd);

                string torSeed = "";
                int posSeedStart = output.IndexOf(seedStart, posSeedInit + seedInit.Length + 1);
                int posSeedEnd = 0;
                if (posSeedStart > 0)
                {
                    posSeedEnd = output.IndexOf(seedEnd, posSeedStart + seedStart.Length + 1);

                    torSeed = output.Substring(posSeedStart + seedStart.Length, posSeedEnd - posSeedStart - seedStart.Length);
                }

                string torLeech = "";
                int posLeechStart = output.IndexOf(leechStart, posSeedStart + 3);
                int posLeechEnd = 0;
                if (posLeechStart > 0)
                {
                    posLeechEnd = output.IndexOf(leechEnd, posLeechStart + leechStart.Length + 1);

                    torLeech = output.Substring(posLeechStart + leechStart.Length, posLeechEnd - posLeechStart - leechStart.Length);
                }

                TorrentLinkVM torrentLink = new TorrentLinkVM(TorrentSourceType.BakaBT);
                torrentLink.TorrentDownloadLink = "";
                torrentLink.TorrentLink = link;
                torrentLink.AnimeType = cat;
                torrentLink.TorrentName = string.Format("[MAIN] {0}", torName.Trim());
                torrentLink.Size = torSize.Trim();

                var strSeeders = torSeed.Trim();

                double dblSeeders;
                if (double.TryParse(strSeeders, out dblSeeders))
                    torrentLink.Seeders = dblSeeders;
                else
                    torrentLink.Seeders = double.NaN;

                var strLeechers = torLeech.Trim();

                double dblLeechers;
                if (double.TryParse(strLeechers, out dblLeechers))
                    torrentLink.Leechers = dblLeechers;
                else
                    torrentLink.Leechers = double.NaN;

                torLinks.Add(torrentLink);

                // now we have the main link provided by BakaBT
                // BakaBT also provides alternative links, so lets include those as well

                int temppos = output.IndexOf(startBlock, pos + 1);
                int altpos = output.IndexOf(altBlock, pos + 1);

                while (temppos > altpos && altpos > 0)
                {
                    string linkStartAlt = "href=" + quote;
                    string linkEndAlt = quote;

                    string nameStartAlt = quote + ">";
                    string nameEndAlt = "</a>";

                    string sizeStartAlt = "<td class=" + quote + "size" + quote + ">";
                    string sizeEndAlt = "</td>";

                    string seedInitAlt = "<td class=" + quote + "peers" + quote + ">";
                    string seedStartAlt = quote + ">";
                    string seedEndAlt = "</a>";

                    string leechStartAlt = quote + ">";
                    string leechEndAlt = "</a>";

                    int poslinkStartAlt = output.IndexOf(linkStartAlt, altpos + 1);
                    int poslinkEndAlt = output.IndexOf(linkEndAlt, poslinkStartAlt + linkStartAlt.Length + 1);

                    string linkAlt = output.Substring(poslinkStartAlt + linkStartAlt.Length, poslinkEndAlt - poslinkStartAlt - linkStartAlt.Length);

                    int posnameStartAlt = output.IndexOf(nameStartAlt, poslinkEndAlt);
                    int posnameEndAlt = output.IndexOf(nameEndAlt, posnameStartAlt + nameStartAlt.Length + 1);

                    string torNameAlt = output.Substring(posnameStartAlt + nameStartAlt.Length, posnameEndAlt - posnameStartAlt - nameStartAlt.Length);

                    // remove html codes
                    torNameAlt = torNameAlt.Replace(rubbish1, "");
                    torNameAlt = torNameAlt.Replace(rubbish2, "");

                    torNameAlt = HttpUtility.HtmlDecode(torNameAlt);

                    string torSizeAlt = "";
                    int posSizeStartAlt = output.IndexOf(sizeStartAlt, posnameEndAlt);
                    int posSizeEndAlt = 0;
                    if (posSizeStartAlt > 0)
                    {
                        posSizeEndAlt = output.IndexOf(sizeEndAlt, posSizeStartAlt + sizeStartAlt.Length + 1);

                        torSizeAlt = output.Substring(posSizeStartAlt + sizeStartAlt.Length, posSizeEndAlt - posSizeStartAlt - sizeStartAlt.Length);
                    }

                    int posSeedInitAlt = output.IndexOf(seedInitAlt, posSizeEndAlt);

                    string torSeedAlt = "";
                    int posSeedStartAlt = output.IndexOf(seedStartAlt, posSeedInitAlt + seedInitAlt.Length + 1);
                    int posSeedEndAlt = 0;
                    if (posSeedStartAlt > 0)
                    {
                        posSeedEndAlt = output.IndexOf(seedEndAlt, posSeedStartAlt + seedStartAlt.Length + 1);

                        torSeedAlt = output.Substring(posSeedStartAlt + seedStartAlt.Length, posSeedEndAlt - posSeedStartAlt - seedStartAlt.Length);
                    }

                    string torLeechAlt = "";
                    int posLeechStartAlt = output.IndexOf(leechStartAlt, posSeedStartAlt + 3);
                    int posLeechEndAlt = 0;
                    if (posLeechStartAlt > 0)
                    {
                        posLeechEndAlt = output.IndexOf(leechEndAlt, posLeechStartAlt + leechStartAlt.Length + 1);

                        torLeechAlt = output.Substring(posLeechStartAlt + leechStartAlt.Length, posLeechEndAlt - posLeechStartAlt - leechStartAlt.Length);
                    }

                    TorrentLinkVM torrentLinkAlt = new TorrentLinkVM(TorrentSourceType.BakaBT);
                    torrentLinkAlt.TorrentDownloadLink = "";
                    torrentLinkAlt.TorrentLink = linkAlt;
                    torrentLinkAlt.AnimeType = cat;
                    torrentLinkAlt.TorrentName = string.Format("[ALT] {0}", torNameAlt.Trim());
                    torrentLinkAlt.Size = torSizeAlt.Trim();

                    var strSeedersAlt = torSeedAlt.Trim();

                    double dblSeedersAlt;
                    if (double.TryParse(strSeedersAlt, out dblSeedersAlt))
                        torrentLinkAlt.Seeders = dblSeedersAlt;
                    else
                        torrentLinkAlt.Seeders = double.NaN;

                    var strLeechersAlt = torLeechAlt.Trim();

                    double dblLeechersAlt;
                    if (double.TryParse(strLeechersAlt, out dblLeechersAlt))
                        torrentLinkAlt.Leechers = dblLeechersAlt;
                    else
                        torrentLinkAlt.Leechers = double.NaN;

                    torLinks.Add(torrentLinkAlt);

                    altpos = output.IndexOf(altBlock, posLeechEndAlt + 1);
                }

                pos = output.IndexOf(startBlock, pos + 1);

                //Console.WriteLine("{0} - {1}", torName, torLink);
            }
            //Console.ReadLine();

            count = torLinks.Count;
            return torLinks;
        }
        public void PopulateTorrentLink(ref TorrentLinkVM torLink)
        {
            try
            {
                if (string.IsNullOrEmpty(UserSettingsVM.Instance.BakaBTUsername) || string.IsNullOrEmpty(UserSettingsVM.Instance.BakaBTPassword))
                    return;

                if (string.IsNullOrEmpty(UserSettingsVM.Instance.BakaBTCookieHeader))
                {
                    string cookie = Login(UserSettingsVM.Instance.BakaBTUsername, UserSettingsVM.Instance.BakaBTPassword);
                    UserSettingsVM.Instance.BakaBTCookieHeader = cookie;
                }

                if (string.IsNullOrEmpty(UserSettingsVM.Instance.BakaBTCookieHeader))
                    return;

                string url = torLink.TorrentLinkFull;
                string output = Utils.DownloadWebPage(url, UserSettingsVM.Instance.BakaBTCookieHeader, true);

                string torDownloadLink = GetTorrentLinkFromTorrentPage(output);
                torLink.TorrentDownloadLink = string.Format("https://bakabt.me/{0}", torDownloadLink);
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
                return;
            }
        }
Esempio n. 6
0
		private List<TorrentLinkVM> ParseSource(string output)
		{
			List<TorrentLinkVM> torLinks = new List<TorrentLinkVM>();

			char q = (char)34;
			string quote = q.ToString();

			string startBlock = "<a rel=" + quote + "nofollow" + quote + " type=" + quote + "application/x-bittorrent" + quote;

			string torStart = "href=" + quote;
			string torEnd = quote;

			string nameStart = ">";
			string nameEnd = "</a>";

			string sizeStart = "Size:";
			string sizeEnd = "|";

			int pos = output.IndexOf(startBlock, 0);
			while (pos > 0)
			{

				if (pos <= 0) break;

				int posTorStart = output.IndexOf(torStart, pos + 1);
				int posTorEnd = output.IndexOf(torEnd, posTorStart + torStart.Length + 1);

				//Console.WriteLine("{0} - {1}", posTorStart, posTorEnd);

				string torLink = output.Substring(posTorStart + torStart.Length, posTorEnd - posTorStart - torStart.Length);
				torLink = DownloadHelper.FixNyaaTorrentLink(torLink);

				// remove html codes
				//torLink = torLink.Replace("amp;", "");
				torLink = HttpUtility.HtmlDecode(torLink);

				int posNameStart = output.IndexOf(nameStart, posTorEnd);
				int posNameEnd = output.IndexOf(nameEnd, posNameStart + nameStart.Length + 1);


				string torName = output.Substring(posNameStart + nameStart.Length, posNameEnd - posNameStart - nameStart.Length);

				string torSize = "";
				int posSizeStart = output.IndexOf(sizeStart, posNameEnd);
				if (posSizeStart > 0)
				{
					int posSizeEnd = output.IndexOf(sizeEnd, posSizeStart + sizeStart.Length + 1);

					torSize = output.Substring(posSizeStart + sizeStart.Length, posSizeEnd - posSizeStart - sizeStart.Length);
				}

				TorrentLinkVM torrentLink = new TorrentLinkVM(SourceType);
				torrentLink.TorrentDownloadLink = torLink;
				torrentLink.TorrentName = torName;
				torrentLink.Size = torSize.Trim();
				torLinks.Add(torrentLink);

				pos = output.IndexOf(startBlock, pos + 1);

			}

			return torLinks;
		}
        private List<TorrentLinkVM> ParseSource(string output)
        {
            List<TorrentLinkVM> torLinks = new List<TorrentLinkVM>();

            char q = (char)34;
            string quote = q.ToString();

            string nameStart = "<a href=" + quote + "/series.php?id=";
            string nameStart2 = quote + ">";
            string nameEnd = "</a>";

            // title="View Torrent">
            string typeStart = "title=" + quote + "View Torrent" + quote + ">";
            string typeEnd = "</a>";

            // <tr class="edition_info"><td class=" " colspan="5"><strong>
            //string torrentSectionStart = "<tr class=" + quote + "edition_info";
            // <table class="torrent_group">
            string torrentSectionStart = "<table class=" + quote + "torrent_group";
            // </table>
            string torrentSectionEnd = "</table>";

            // <a href="torrents.php?action=download
            string torDownloadStart = "<a href=" + quote + "torrents.php?action=download";
            string torDownloadEnd = quote;

            // <a href="torrents.php?id=
            string torInfoPreStart = "<a href=" + quote + "torrents.php?id=";
            string torInfoStart = ">";
            string torInfoEnd = "</a>";

            // <td class="torrent_size"><span>
            string torSizeStart = "<td class=" + quote + "torrent_size" + quote + "><span>";
            string torSizeEnd = "</span>";

            // <td class="torrent_seeders" title="Seeders"><span>
            string torSeedStart = "<td class=" + quote + "torrent_seeders" + quote + " title=" + quote + "Seeders" + quote + "><span>";
            string torSeedEnd = "</span>";

            // <td class="torrent_leechers" title="Leechers"><span>
            string torLeechStart = "<td class=" + quote + "torrent_leechers" + quote + " title=" + quote + "Leechers" + quote + "><span>";
            string torLeechEnd = "</span>";

            // <img src="static/common/hentaic.png" alt="Hentai" title="This torrent is of censored hentai (18+) material!" />
            // <img src="static/common/flicon.png" alt="Freeleech!" title="This torrent is freeleech. Remember to seed!" />
            string hentaiTag = "alt=" + quote + "Hentai";
            string leechTag = "alt=" + quote + "Freeleech";

            int pos = output.IndexOf(nameStart, 0);
            while (pos > 0)
            {

                if (pos <= 0) break;

                //int posnameStart = output.IndexOf(nameStart, pos + 1);
                int posnameStart2 = output.IndexOf(nameStart2, pos + nameStart.Length);
                int posnameEnd = output.IndexOf(nameEnd, posnameStart2 + nameStart2.Length + 1);

                string torName = output.Substring(posnameStart2 + nameStart2.Length, posnameEnd - posnameStart2 - nameStart2.Length);

                // remove html codes
                torName = HttpUtility.HtmlDecode(torName);

                int posTypeStart = output.IndexOf(typeStart, posnameEnd + 1);
                int posTypeEnd = output.IndexOf(typeEnd, posTypeStart + 1);

                string torType = output.Substring(posTypeStart + typeStart.Length, posTypeEnd - posTypeStart - typeStart.Length);

                // get all the torrents

                // find the section start and end
                int posTorSectionStart = output.IndexOf(torrentSectionStart, posTypeEnd + 1);
                int posTorSectionEnd = output.IndexOf(torrentSectionEnd, posTorSectionStart + 1);

                // find all the torrents
                int posTorDownloadStart = output.IndexOf(torDownloadStart, posTorSectionStart + 1);

                while (posTorDownloadStart < posTorSectionEnd && posTorDownloadStart > 0)
                {
                    int posTorDownloadEnd = output.IndexOf(torDownloadEnd, posTorDownloadStart + 9);

                    string torDownloadLink = output.Substring(posTorDownloadStart + 9, posTorDownloadEnd - posTorDownloadStart - 9);
                    torDownloadLink = HttpUtility.HtmlDecode(torDownloadLink);

                    int posTorInfoPreStart = output.IndexOf(torInfoPreStart, posTorDownloadEnd + 1);
                    int posTorInfoStart = output.IndexOf(torInfoStart, posTorInfoPreStart + 1);
                    int posTorInfoEnd = output.IndexOf(torInfoEnd, posTorInfoStart + 1);

                    string torInfo = output.Substring(posTorInfoStart + 1, posTorInfoEnd - posTorInfoStart - 1);

                    // TODO - extract out <img> imfomation
                    // <img src="static/common/hentaic.png" alt="Hentai" title="This torrent is of censored hentai (18+) material!" />
                    // <img src="static/common/flicon.png" alt="Freeleech!" title="This torrent is freeleech. Remember to seed!" />
                    int posImgStart = torInfo.IndexOf("<img src=", 0);
                    if (posImgStart >= 0)
                    {
                        bool hentai = torInfo.ToUpper().Contains(hentaiTag.ToUpper());
                        bool freeLeech = torInfo.ToUpper().Contains(leechTag.ToUpper());

                        // remove the img alts
                        torInfo = torInfo.Substring(0, posImgStart - 2);

                        if (hentai) torInfo = torInfo + " [hentai]";
                        if (freeLeech) torInfo = torInfo + " [FREE Leech]";
                    }

                    int posTorSizeStart = output.IndexOf(torSizeStart, posTorInfoEnd + 1);
                    int posTorSizeEnd = output.IndexOf(torSizeEnd, posTorSizeStart + 1);

                    string torSize = output.Substring(posTorSizeStart + torSizeStart.Length, posTorSizeEnd - posTorSizeStart - torSizeStart.Length);

                    int posTorSeedStart = output.IndexOf(torSeedStart, posTorSizeEnd + 1);
                    int posTorSeedEnd = output.IndexOf(torSeedEnd, posTorSeedStart + 1);

                    string torSeed = output.Substring(posTorSeedStart + torSeedStart.Length, posTorSeedEnd - posTorSeedStart - torSeedStart.Length);

                    int posTorLeechStart = output.IndexOf(torLeechStart, posTorSeedEnd + 1);
                    int posTorLeechEnd = output.IndexOf(torLeechEnd, posTorLeechStart + 1);

                    string torLeech = output.Substring(posTorLeechStart + torLeechStart.Length, posTorLeechEnd - posTorLeechStart - torLeechStart.Length);

                    TorrentLinkVM torrentLink = new TorrentLinkVM(TorrentSourceType.AnimeBytes);
                    torrentLink.TorrentDownloadLink = string.Format(@"http://animebytes.tv/{0}", torDownloadLink);
                    torrentLink.TorrentLink = "";
                    torrentLink.AnimeType = torType;
                    torrentLink.TorrentName = torName + " - " + torInfo;
                    torrentLink.Size = torSize.Trim();
                    torrentLink.Seeders = torSeed.Trim();
                    torrentLink.Leechers = torLeech.Trim();
                    torLinks.Add(torrentLink);

                    // find the next download link
                    posTorDownloadStart = output.IndexOf(torDownloadStart, posTorLeechEnd + 1);
                }

                // find the next torrent group
                pos = output.IndexOf(nameStart, pos + 3);
            }

            return torLinks;
        }
Esempio n. 8
0
        private List <TorrentLinkVM> ParseSource(string output)
        {
            List <TorrentLinkVM> torLinks = new List <TorrentLinkVM>();

            char   q     = (char)34;
            string quote = q.ToString();

            //class="tlistthone">Category
            //string startBlock = @"http://www.nyaa.eu/?page=torrentinfo";
            string startBlock = @"class=" + quote + "tlistthone" + quote + ">Category";

            //<td class="tlistname">
            string nameStart1 = @"<td class=" + quote + "tlistname" + quote + "><a href=";

            string nameStart2 = ">";
            string nameEnd2   = "</a>";

            string torStart = "href=" + quote;
            string torEnd   = quote;



            string sizeStart = "tlistsize" + quote + ">";
            string sizeEnd   = "</td>";

            string seedStart = "tlistsn" + quote + ">";
            string seedEnd   = "</td>";

            string leechStart = "tlistln" + quote + ">";
            string leechEnd   = "</td>";

            int pos = output.IndexOf(startBlock, 0);

            while (pos > 0)
            {
                if (pos <= 0)
                {
                    break;
                }

                // find the start of the torrent
                int posBegin = output.IndexOf(nameStart1, pos + 1);
                if (posBegin <= 0)
                {
                    break;
                }

                int posNameStart = output.IndexOf(nameStart2, posBegin + nameStart1.Length + 1);
                int posNameEnd   = output.IndexOf(nameEnd2, posNameStart + nameStart2.Length + 1);

                string torName = output.Substring(posNameStart + nameStart2.Length, posNameEnd - posNameStart - nameStart2.Length);

                int posTorStart = output.IndexOf(torStart, posNameEnd);
                int posTorEnd   = output.IndexOf(torEnd, posTorStart + torStart.Length + 1);

                string torLink = output.Substring(posTorStart + torStart.Length, posTorEnd - posTorStart - torStart.Length);
                torLink = DownloadHelper.FixNyaaTorrentLink(torLink);
                torLink = "http:" + torLink;

                // remove html codes
                torLink = HttpUtility.HtmlDecode(torLink);

                string torSize      = "";
                int    posSizeStart = output.IndexOf(sizeStart, posNameEnd);
                int    posSizeEnd   = 0;
                if (posSizeStart > 0)
                {
                    posSizeEnd = output.IndexOf(sizeEnd, posSizeStart + sizeStart.Length + 1);

                    torSize = output.Substring(posSizeStart + sizeStart.Length, posSizeEnd - posSizeStart - sizeStart.Length);
                }

                string torSeed      = "";
                int    posSeedStart = output.IndexOf(seedStart, posSizeEnd);
                int    posSeedEnd   = 0;
                if (posSeedStart > 0)
                {
                    posSeedEnd = output.IndexOf(seedEnd, posSeedStart + seedStart.Length + 1);

                    torSeed = output.Substring(posSeedStart + seedStart.Length, posSeedEnd - posSeedStart - seedStart.Length);
                }

                string torLeech      = "";
                int    posLeechStart = output.IndexOf(leechStart, posSeedStart + 3);
                int    posLeechEnd   = 0;
                if (posLeechStart > 0)
                {
                    posLeechEnd = output.IndexOf(leechEnd, posLeechStart + leechStart.Length + 1);

                    torLeech = output.Substring(posLeechStart + leechStart.Length, posLeechEnd - posLeechStart - leechStart.Length);
                }

                TorrentLinkVM torrentLink = new TorrentLinkVM(SourceType);
                torrentLink.TorrentDownloadLink = torLink;
                torrentLink.TorrentName         = torName;
                torrentLink.Size     = torSize.Trim();
                torrentLink.Seeders  = torSeed.Trim();
                torrentLink.Leechers = torLeech.Trim();
                torLinks.Add(torrentLink);

                pos = output.IndexOf(nameStart1, pos + 1);
            }
            //Console.ReadLine();

            return(torLinks);
        }
Esempio n. 9
0
		private List<TorrentLinkVM> ParseSource(string output)
		{
			List<TorrentLinkVM> torLinks = new List<TorrentLinkVM>();

			char q = (char)34;
			string quote = q.ToString();

			string startBlock = "<td class=" + quote + "bb_m";

			string torStart = "<a target=" + quote + "_top" + quote + " href=" + quote;
			string torEnd = quote;

			string nameStart = "rel=" + quote + "nofollow" + quote + ">";
			string nameEnd = "</a>";

			string groupStart = "<td nowrap=" + quote + "nowrap" + quote + ">";
			string groupEnd = "</a>";

			string sizeStart = "<td nowrap=" + quote + "nowrap" + quote + ">";
			string sizeEnd = "</td>";

			int pos = output.IndexOf(startBlock, 0);
			while (pos > 0)
			{

				if (pos <= 0) break;

				int posTorStart = output.IndexOf(torStart, pos + 1);
				int posTorEnd = output.IndexOf(torEnd, posTorStart + torStart.Length + 1);

				string torLink = output.Substring(posTorStart + torStart.Length, posTorEnd - posTorStart - torStart.Length);
				torLink = DownloadHelper.FixNyaaTorrentLink(torLink);

				// remove html codes
				//torLink = torLink.Replace("amp;", "");
				torLink = HttpUtility.HtmlDecode(torLink);

				int posNameStart = output.IndexOf(nameStart, posTorEnd);
				int posNameEnd = output.IndexOf(nameEnd, posNameStart + nameStart.Length + 1);

				//Console.WriteLine("{0} - {1}", posNameStart, posNameEnd);

				string torName = output.Substring(posNameStart + nameStart.Length, posNameEnd - posNameStart - nameStart.Length);
				torName = torName.Replace("<b>", "");
				torName = torName.Replace("</b>", "");

				int posGroupStart = output.IndexOf(groupStart, posNameEnd);
				posGroupStart = output.IndexOf(">", posGroupStart + groupStart.Length + 1);
				int posGroupEnd = output.IndexOf(groupEnd, posGroupStart + 1);
				string torGroup = output.Substring(posGroupStart + 1, posGroupEnd - posGroupStart - 1);

				string torSize = "";
				int posSizeStart = output.IndexOf(sizeStart, posGroupEnd);

				if (posSizeStart > 0)
				{
					int posSizeEnd = output.IndexOf(sizeEnd, posSizeStart + sizeStart.Length + 1);

					torSize = output.Substring(posSizeStart + sizeStart.Length, posSizeEnd - posSizeStart - sizeStart.Length);
					torSize = torSize.Replace("&nbsp;", "");
				}

				TorrentLinkVM torrentLink = new TorrentLinkVM(SourceType);
				torrentLink.TorrentDownloadLink = torLink;
				torrentLink.TorrentName = torName + " (" + torGroup + ")";
				torrentLink.Size = torSize.Trim();
				torLinks.Add(torrentLink);

				pos = output.IndexOf(startBlock, pos + 1);

			}
			//Console.ReadLine();

			return torLinks;
		}
Esempio n. 10
0
        private List <TorrentLinkVM> ParseSource(string output)
        {
            List <TorrentLinkVM> torLinks = new List <TorrentLinkVM>();

            char   q     = (char)34;
            string quote = q.ToString();

            string startBlock = "<a rel=" + quote + "nofollow" + quote + " type=" + quote + "application/x-bittorrent" + quote;

            string torStart = "href=" + quote;
            string torEnd   = quote;

            string nameStart = ">";
            string nameEnd   = "</a>";

            string sizeStart = "Size:";
            string sizeEnd   = "|";

            int pos = output.IndexOf(startBlock, 0);

            while (pos > 0)
            {
                if (pos <= 0)
                {
                    break;
                }

                int posTorStart = output.IndexOf(torStart, pos + 1);
                int posTorEnd   = output.IndexOf(torEnd, posTorStart + torStart.Length + 1);

                //Console.WriteLine("{0} - {1}", posTorStart, posTorEnd);

                string torLink = output.Substring(posTorStart + torStart.Length, posTorEnd - posTorStart - torStart.Length);
                torLink = DownloadHelper.FixNyaaTorrentLink(torLink);

                // remove html codes
                //torLink = torLink.Replace("amp;", "");
                torLink = HttpUtility.HtmlDecode(torLink);

                int posNameStart = output.IndexOf(nameStart, posTorEnd);
                int posNameEnd   = output.IndexOf(nameEnd, posNameStart + nameStart.Length + 1);


                string torName = output.Substring(posNameStart + nameStart.Length, posNameEnd - posNameStart - nameStart.Length);

                string torSize      = "";
                int    posSizeStart = output.IndexOf(sizeStart, posNameEnd);
                if (posSizeStart > 0)
                {
                    int posSizeEnd = output.IndexOf(sizeEnd, posSizeStart + sizeStart.Length + 1);

                    torSize = output.Substring(posSizeStart + sizeStart.Length, posSizeEnd - posSizeStart - sizeStart.Length);
                }

                TorrentLinkVM torrentLink = new TorrentLinkVM(SourceType);
                torrentLink.TorrentDownloadLink = torLink;
                torrentLink.TorrentName         = torName;
                torrentLink.Size = torSize.Trim();
                torLinks.Add(torrentLink);

                pos = output.IndexOf(startBlock, pos + 1);
            }

            return(torLinks);
        }
		private void ShowTorrentDetails(TorrentLinkVM torLink)
		{
			SetAttachedSeries(null);

			if (!torrentDetailsWorker.IsBusy)
				torrentDetailsWorker.RunWorkerAsync(torLink);
		}
Esempio n. 12
0
        private List <TorrentLinkVM> ParseSource(string output)
        {
            List <TorrentLinkVM> torLinks = new List <TorrentLinkVM>();

            char   q     = (char)34;
            string quote = q.ToString();

            string nameStart  = "<a href=" + quote + "series.php?id=";
            string nameStart2 = quote + ">";
            string nameEnd    = "</a>";

            // title="View Torrent">
            string typeStart = "title=" + quote + "View Torrent" + quote + ">";
            string typeEnd   = "</a>";

            // <tr class="edition_info"><td class=" " colspan="5"><strong>
            //string torrentSectionStart = "<tr class=" + quote + "edition_info";
            // <table class="torrent_group">
            string torrentSectionStart = "<table class=" + quote + "torrent_group";
            // </table>
            string torrentSectionEnd = "</table>";

            // <a href="torrents.php?action=download
            string torDownloadStart = "<a href=" + quote + "torrents.php?action=download";
            string torDownloadEnd   = quote;

            // <a href="torrents.php?id=
            string torInfoPreStart = "<a href=" + quote + "torrents.php?id=";
            string torInfoStart    = ">";
            string torInfoEnd      = "</a>";

            // <td class="torrent_size"><span>
            string torSizeStart = "<td class=" + quote + "torrent_size" + quote + "><span>";
            string torSizeEnd   = "</span>";

            // <td class="torrent_seeders" title="Seeders"><span>
            string torSeedStart = "<td class=" + quote + "torrent_seeders" + quote + " title=" + quote + "Seeders" + quote + "><span>";
            string torSeedEnd   = "</span>";

            // <td class="torrent_leechers" title="Leechers"><span>
            string torLeechStart = "<td class=" + quote + "torrent_leechers" + quote + " title=" + quote + "Leechers" + quote + "><span>";
            string torLeechEnd   = "</span>";

            // <img src="static/common/hentaic.png" alt="Hentai" title="This torrent is of censored hentai (18+) material!" />
            // <img src="static/common/flicon.png" alt="Freeleech!" title="This torrent is freeleech. Remember to seed!" />
            string hentaiTag = "alt=" + quote + "Hentai";
            string leechTag  = "alt=" + quote + "Freeleech";

            int pos = output.IndexOf(nameStart, 0);

            while (pos > 0)
            {
                if (pos <= 0)
                {
                    break;
                }

                //int posnameStart = output.IndexOf(nameStart, pos + 1);
                int posnameStart2 = output.IndexOf(nameStart2, pos + nameStart.Length);
                int posnameEnd    = output.IndexOf(nameEnd, posnameStart2 + nameStart2.Length + 1);

                string torName = output.Substring(posnameStart2 + nameStart2.Length, posnameEnd - posnameStart2 - nameStart2.Length);

                // remove html codes
                torName = HttpUtility.HtmlDecode(torName);

                int posTypeStart = output.IndexOf(typeStart, posnameEnd + 1);
                int posTypeEnd   = output.IndexOf(typeEnd, posTypeStart + 1);

                string torType = output.Substring(posTypeStart + typeStart.Length, posTypeEnd - posTypeStart - typeStart.Length);

                // get all the torrents

                // find the section start and end
                int posTorSectionStart = output.IndexOf(torrentSectionStart, posTypeEnd + 1);
                int posTorSectionEnd   = output.IndexOf(torrentSectionEnd, posTorSectionStart + 1);

                // find all the torrents
                int posTorDownloadStart = output.IndexOf(torDownloadStart, posTorSectionStart + 1);

                while (posTorDownloadStart < posTorSectionEnd && posTorDownloadStart > 0)
                {
                    int posTorDownloadEnd = output.IndexOf(torDownloadEnd, posTorDownloadStart + 9);

                    string torDownloadLink = output.Substring(posTorDownloadStart + 9, posTorDownloadEnd - posTorDownloadStart - 9);
                    torDownloadLink = HttpUtility.HtmlDecode(torDownloadLink);

                    int posTorInfoPreStart = output.IndexOf(torInfoPreStart, posTorDownloadEnd + 1);
                    int posTorInfoStart    = output.IndexOf(torInfoStart, posTorInfoPreStart + 1);
                    int posTorInfoEnd      = output.IndexOf(torInfoEnd, posTorInfoStart + 1);

                    string torInfo = output.Substring(posTorInfoStart + 1, posTorInfoEnd - posTorInfoStart - 1);

                    // TODO - extract out <img> imfomation
                    // <img src="static/common/hentaic.png" alt="Hentai" title="This torrent is of censored hentai (18+) material!" />
                    // <img src="static/common/flicon.png" alt="Freeleech!" title="This torrent is freeleech. Remember to seed!" />
                    int posImgStart = torInfo.IndexOf("<img src=", 0);
                    if (posImgStart >= 0)
                    {
                        bool hentai    = torInfo.ToUpper().Contains(hentaiTag.ToUpper());
                        bool freeLeech = torInfo.ToUpper().Contains(leechTag.ToUpper());

                        // remove the img alts
                        torInfo = torInfo.Substring(0, posImgStart - 2);

                        if (hentai)
                        {
                            torInfo = torInfo + " [hentai]";
                        }
                        if (freeLeech)
                        {
                            torInfo = torInfo + " [FREE Leech]";
                        }
                    }


                    int posTorSizeStart = output.IndexOf(torSizeStart, posTorInfoEnd + 1);
                    int posTorSizeEnd   = output.IndexOf(torSizeEnd, posTorSizeStart + 1);

                    string torSize = output.Substring(posTorSizeStart + torSizeStart.Length, posTorSizeEnd - posTorSizeStart - torSizeStart.Length);


                    int posTorSeedStart = output.IndexOf(torSeedStart, posTorSizeEnd + 1);
                    int posTorSeedEnd   = output.IndexOf(torSeedEnd, posTorSeedStart + 1);

                    string torSeed = output.Substring(posTorSeedStart + torSeedStart.Length, posTorSeedEnd - posTorSeedStart - torSeedStart.Length);

                    int posTorLeechStart = output.IndexOf(torLeechStart, posTorSeedEnd + 1);
                    int posTorLeechEnd   = output.IndexOf(torLeechEnd, posTorLeechStart + 1);

                    string torLeech = output.Substring(posTorLeechStart + torLeechStart.Length, posTorLeechEnd - posTorLeechStart - torLeechStart.Length);

                    TorrentLinkVM torrentLink = new TorrentLinkVM(TorrentSourceType.AnimeBytes);
                    torrentLink.TorrentDownloadLink = string.Format(@"http://animebyt.es/{0}", torDownloadLink);
                    torrentLink.TorrentLink         = "";
                    torrentLink.AnimeType           = torType;
                    torrentLink.TorrentName         = torName + " - " + torInfo;
                    torrentLink.Size     = torSize.Trim();
                    torrentLink.Seeders  = torSeed.Trim();
                    torrentLink.Leechers = torLeech.Trim();
                    torLinks.Add(torrentLink);

                    // find the next download link
                    posTorDownloadStart = output.IndexOf(torDownloadStart, posTorLeechEnd + 1);
                }

                // find the next torrent group
                pos = output.IndexOf(nameStart, pos + 3);
            }

            return(torLinks);
        }
Esempio n. 13
0
        private List <TorrentLinkVM> ParseSource(string output)
        {
            List <TorrentLinkVM> torLinks = new List <TorrentLinkVM>();

            char   q     = (char)34;
            string quote = q.ToString();

            string startBlock = "<td class=" + quote + "bb_m";

            string torStart = "<a target=" + quote + "_top" + quote + " href=" + quote;
            string torEnd   = quote;

            string nameStart = "rel=" + quote + "nofollow" + quote + ">";
            string nameEnd   = "</a>";

            string groupStart = "<td nowrap=" + quote + "nowrap" + quote + ">";
            string groupEnd   = "</a>";

            string sizeStart = "<td nowrap=" + quote + "nowrap" + quote + ">";
            string sizeEnd   = "</td>";

            int pos = output.IndexOf(startBlock, 0);

            while (pos > 0)
            {
                if (pos <= 0)
                {
                    break;
                }

                int posTorStart = output.IndexOf(torStart, pos + 1);
                int posTorEnd   = output.IndexOf(torEnd, posTorStart + torStart.Length + 1);

                string torLink = output.Substring(posTorStart + torStart.Length, posTorEnd - posTorStart - torStart.Length);
                torLink = DownloadHelper.FixNyaaTorrentLink(torLink);

                // remove html codes
                //torLink = torLink.Replace("amp;", "");
                torLink = HttpUtility.HtmlDecode(torLink);

                int posNameStart = output.IndexOf(nameStart, posTorEnd);
                int posNameEnd   = output.IndexOf(nameEnd, posNameStart + nameStart.Length + 1);

                //Console.WriteLine("{0} - {1}", posNameStart, posNameEnd);

                string torName = output.Substring(posNameStart + nameStart.Length, posNameEnd - posNameStart - nameStart.Length);
                torName = torName.Replace("<b>", "");
                torName = torName.Replace("</b>", "");

                int posGroupStart = output.IndexOf(groupStart, posNameEnd);
                posGroupStart = output.IndexOf(">", posGroupStart + groupStart.Length + 1);
                int    posGroupEnd = output.IndexOf(groupEnd, posGroupStart + 1);
                string torGroup    = output.Substring(posGroupStart + 1, posGroupEnd - posGroupStart - 1);

                string torSize      = "";
                int    posSizeStart = output.IndexOf(sizeStart, posGroupEnd);

                if (posSizeStart > 0)
                {
                    int posSizeEnd = output.IndexOf(sizeEnd, posSizeStart + sizeStart.Length + 1);

                    torSize = output.Substring(posSizeStart + sizeStart.Length, posSizeEnd - posSizeStart - sizeStart.Length);
                    torSize = torSize.Replace("&nbsp;", "");
                }

                TorrentLinkVM torrentLink = new TorrentLinkVM(SourceType);
                torrentLink.TorrentDownloadLink = torLink;
                torrentLink.TorrentName         = torName + " (" + torGroup + ")";
                torrentLink.Size = torSize.Trim();
                torLinks.Add(torrentLink);

                pos = output.IndexOf(startBlock, pos + 1);
            }
            //Console.ReadLine();

            return(torLinks);
        }
Esempio n. 14
0
        private List <TorrentLinkVM> ParseSource(string output)
        {
            List <TorrentLinkVM> torLinks = new List <TorrentLinkVM>();

            char   q     = (char)34;
            string quote = q.ToString();

            //<td class="name">

            // remove html codes
            string rubbish1 = "<span class=" + quote + "highlight" + quote + ">";
            string rubbish2 = "</span>";



            //string startBlock = "<td class=" + quote + "name" + quote;
            string startBlock = "<td class=" + quote + "category";
            string altBlock   = "class=" + quote + "alt_title" + quote;

            string catStart = "title=" + quote;
            string catEnd   = quote;

            string linkStart = "href=" + quote;
            string linkEnd   = quote;

            string nameStart  = "title=" + quote + "Download torrent:";
            string nameStart2 = quote + ">";
            string nameEnd    = "</a>";

            string sizeStart = "<td class=" + quote + "size" + quote + ">";
            string sizeEnd   = "</td>";

            string seedInit  = "<td class=" + quote + "peers" + quote + ">";
            string seedStart = quote + ">";
            string seedEnd   = "</a>";

            string leechStart = quote + ">";
            string leechEnd   = "</a>";

            int pos = output.IndexOf(startBlock, 0);

            while (pos > 0)
            {
                if (pos <= 0)
                {
                    break;
                }

                int poscatStart = output.IndexOf(catStart, pos + 1);
                int poscatEnd   = output.IndexOf(catEnd, poscatStart + catStart.Length + 1);

                string cat = output.Substring(poscatStart + catStart.Length, poscatEnd - poscatStart - catStart.Length);

                int poslinkStart = output.IndexOf(linkStart, poscatEnd + 1);
                int poslinkEnd   = output.IndexOf(linkEnd, poslinkStart + linkStart.Length + 1);

                string link = output.Substring(poslinkStart + linkStart.Length, poslinkEnd - poslinkStart - linkStart.Length);

                int posnameStart  = output.IndexOf(nameStart, poslinkEnd);
                int posnameStart2 = output.IndexOf(nameStart2, posnameStart + nameStart.Length);
                int posnameEnd    = output.IndexOf(nameEnd, posnameStart2 + nameStart2.Length + 1);

                string torName = output.Substring(posnameStart2 + nameStart2.Length, posnameEnd - posnameStart2 - nameStart2.Length);

                torName = torName.Replace(rubbish1, "");
                torName = torName.Replace(rubbish2, "");

                // remove html codes
                torName = HttpUtility.HtmlDecode(torName);

                //Console.WriteLine("{0} - {1}", posNameStart, posNameEnd);

                string torSize      = "";
                int    posSizeStart = output.IndexOf(sizeStart, posnameEnd);
                int    posSizeEnd   = 0;
                if (posSizeStart > 0)
                {
                    posSizeEnd = output.IndexOf(sizeEnd, posSizeStart + sizeStart.Length + 1);

                    torSize = output.Substring(posSizeStart + sizeStart.Length, posSizeEnd - posSizeStart - sizeStart.Length);
                }

                int posSeedInit = output.IndexOf(seedInit, posSizeEnd);

                string torSeed      = "";
                int    posSeedStart = output.IndexOf(seedStart, posSeedInit + seedInit.Length + 1);
                int    posSeedEnd   = 0;
                if (posSeedStart > 0)
                {
                    posSeedEnd = output.IndexOf(seedEnd, posSeedStart + seedStart.Length + 1);

                    torSeed = output.Substring(posSeedStart + seedStart.Length, posSeedEnd - posSeedStart - seedStart.Length);
                }

                string torLeech      = "";
                int    posLeechStart = output.IndexOf(leechStart, posSeedStart + 3);
                int    posLeechEnd   = 0;
                if (posLeechStart > 0)
                {
                    posLeechEnd = output.IndexOf(leechEnd, posLeechStart + leechStart.Length + 1);

                    torLeech = output.Substring(posLeechStart + leechStart.Length, posLeechEnd - posLeechStart - leechStart.Length);
                }

                TorrentLinkVM torrentLink = new TorrentLinkVM(TorrentSourceType.BakaBT);
                torrentLink.TorrentDownloadLink = "";
                torrentLink.TorrentLink         = link;
                torrentLink.AnimeType           = cat;
                torrentLink.TorrentName         = string.Format("[MAIN] {0}", torName.Trim());
                torrentLink.Size     = torSize.Trim();
                torrentLink.Seeders  = torSeed.Trim();
                torrentLink.Leechers = torLeech.Trim();
                torLinks.Add(torrentLink);

                // now we have the main link provided by BakaBT
                // BakaBT also provides alternative links, so lets include those as well

                int temppos = output.IndexOf(startBlock, pos + 1);
                int altpos  = output.IndexOf(altBlock, pos + 1);

                while (temppos > altpos && altpos > 0)
                {
                    string linkStartAlt = "href=" + quote;
                    string linkEndAlt   = quote;

                    string nameStartAlt = quote + ">";
                    string nameEndAlt   = "</a>";

                    string sizeStartAlt = "<td class=" + quote + "size" + quote + ">";
                    string sizeEndAlt   = "</td>";

                    string seedInitAlt  = "<td class=" + quote + "peers" + quote + ">";
                    string seedStartAlt = quote + ">";
                    string seedEndAlt   = "</a>";

                    string leechStartAlt = quote + ">";
                    string leechEndAlt   = "</a>";

                    int poslinkStartAlt = output.IndexOf(linkStartAlt, altpos + 1);
                    int poslinkEndAlt   = output.IndexOf(linkEndAlt, poslinkStartAlt + linkStartAlt.Length + 1);

                    string linkAlt = output.Substring(poslinkStartAlt + linkStartAlt.Length, poslinkEndAlt - poslinkStartAlt - linkStartAlt.Length);

                    int posnameStartAlt = output.IndexOf(nameStartAlt, poslinkEndAlt);
                    int posnameEndAlt   = output.IndexOf(nameEndAlt, posnameStartAlt + nameStartAlt.Length + 1);

                    string torNameAlt = output.Substring(posnameStartAlt + nameStartAlt.Length, posnameEndAlt - posnameStartAlt - nameStartAlt.Length);

                    // remove html codes
                    torNameAlt = torNameAlt.Replace(rubbish1, "");
                    torNameAlt = torNameAlt.Replace(rubbish2, "");

                    torNameAlt = HttpUtility.HtmlDecode(torNameAlt);

                    string torSizeAlt      = "";
                    int    posSizeStartAlt = output.IndexOf(sizeStartAlt, posnameEndAlt);
                    int    posSizeEndAlt   = 0;
                    if (posSizeStartAlt > 0)
                    {
                        posSizeEndAlt = output.IndexOf(sizeEndAlt, posSizeStartAlt + sizeStartAlt.Length + 1);

                        torSizeAlt = output.Substring(posSizeStartAlt + sizeStartAlt.Length, posSizeEndAlt - posSizeStartAlt - sizeStartAlt.Length);
                    }

                    int posSeedInitAlt = output.IndexOf(seedInitAlt, posSizeEndAlt);

                    string torSeedAlt      = "";
                    int    posSeedStartAlt = output.IndexOf(seedStartAlt, posSeedInitAlt + seedInitAlt.Length + 1);
                    int    posSeedEndAlt   = 0;
                    if (posSeedStartAlt > 0)
                    {
                        posSeedEndAlt = output.IndexOf(seedEndAlt, posSeedStartAlt + seedStartAlt.Length + 1);

                        torSeedAlt = output.Substring(posSeedStartAlt + seedStartAlt.Length, posSeedEndAlt - posSeedStartAlt - seedStartAlt.Length);
                    }

                    string torLeechAlt      = "";
                    int    posLeechStartAlt = output.IndexOf(leechStartAlt, posSeedStartAlt + 3);
                    int    posLeechEndAlt   = 0;
                    if (posLeechStartAlt > 0)
                    {
                        posLeechEndAlt = output.IndexOf(leechEndAlt, posLeechStartAlt + leechStartAlt.Length + 1);

                        torLeechAlt = output.Substring(posLeechStartAlt + leechStartAlt.Length, posLeechEndAlt - posLeechStartAlt - leechStartAlt.Length);
                    }

                    TorrentLinkVM torrentLinkAlt = new TorrentLinkVM(TorrentSourceType.BakaBT);
                    torrentLinkAlt.TorrentDownloadLink = "";
                    torrentLinkAlt.TorrentLink         = linkAlt;
                    torrentLinkAlt.AnimeType           = cat;
                    torrentLinkAlt.TorrentName         = string.Format("[ALT] {0}", torNameAlt.Trim());
                    torrentLinkAlt.Size     = torSizeAlt.Trim();
                    torrentLinkAlt.Seeders  = torSeedAlt.Trim();
                    torrentLinkAlt.Leechers = torLeechAlt.Trim();
                    torLinks.Add(torrentLinkAlt);

                    altpos = output.IndexOf(altBlock, posLeechEndAlt + 1);
                }

                pos = output.IndexOf(startBlock, pos + 1);



                //Console.WriteLine("{0} - {1}", torName, torLink);
            }
            //Console.ReadLine();

            count = torLinks.Count;
            return(torLinks);
        }
Esempio n. 15
0
        private List<TorrentLinkVM> ParseSourceSingleResult(string output)
        {
            List<TorrentLinkVM> torLinks = new List<TorrentLinkVM>();

            char q = (char)34;
            string quote = q.ToString();

            // Name:</td><td class="tinfotorrentname">
            string startBlock = @"Name:";

            // class="thead">Name:</td><td class="tinfotorrentname">[Hadena] Koi to Senkyo to Chocolate - 03 [720p] [9CD64623].mkv</td>
            string nameStart = "tinfotorrentname" + quote + ">";
            string nameEnd = "</td>";

            // Seeders:</td><td class="vtop"><span class="tinfosn">17</span>
            string seedStart = "Seeders:</td><td class=" + quote + "vtop" + quote + "><span class=" + quote + "tinfosn" + quote + ">";
            string seedEnd = "</span>";

            // Leechers:</td><td class="vtop"><span class="tinfoln">
            string leechStart = "Leechers:</td><td class=" + quote + "vtop" + quote + "><span class=" + quote + "tinfoln" + quote + ">";
            string leechEnd = "</span>";

            // File size:</td><td class="vtop">193.8 MiB</td>
            string sizeStart = "File size:</td><td class=" + quote + "vtop" + quote + ">";
            string sizeEnd = "</td>";

            // class="tinfodownloadbutton"><a href="https://sukebei.nyaa.eu/?page=download&#38;tid=334194"
            string torStart = "class=" + quote + "tinfodownloadbutton" + quote + "><a href=" + quote;
            string torEnd = quote;

            int pos = output.IndexOf(startBlock, 0);
            while (pos > 0)
            {

                if (pos <= 0) break;

                int posNameStart = output.IndexOf(nameStart, pos + 1);
                int posNameEnd = output.IndexOf(nameEnd, posNameStart + nameStart.Length + 1);

                string torName = output.Substring(posNameStart + nameStart.Length, posNameEnd - posNameStart - nameStart.Length);

                string torSeed = "";
                int posSeedStart = output.IndexOf(seedStart, posNameEnd);
                int posSeedEnd = 0;
                if (posSeedStart > 0)
                {
                    posSeedEnd = output.IndexOf(seedEnd, posSeedStart + seedStart.Length + 1);
                    torSeed = output.Substring(posSeedStart + seedStart.Length, posSeedEnd - posSeedStart - seedStart.Length);
                }

                string torLeech = "";
                int posLeechStart = output.IndexOf(leechStart, posSeedEnd + 3);
                int posLeechEnd = 0;
                if (posLeechStart > 0)
                {
                    posLeechEnd = output.IndexOf(leechEnd, posLeechStart + leechStart.Length + 1);
                    torLeech = output.Substring(posLeechStart + leechStart.Length, posLeechEnd - posLeechStart - leechStart.Length);
                }

                string torSize = "";
                int posSizeStart = output.IndexOf(sizeStart, posLeechEnd);
                int posSizeEnd = 0;
                if (posSizeStart > 0)
                {
                    posSizeEnd = output.IndexOf(sizeEnd, posSizeStart + sizeStart.Length + 1);
                    torSize = output.Substring(posSizeStart + sizeStart.Length, posSizeEnd - posSizeStart - sizeStart.Length);
                }

                int posTorStart = output.IndexOf(torStart, posSizeEnd);
                int posTorEnd = output.IndexOf(torEnd, posTorStart + torStart.Length + 1);

                string torLink = output.Substring(posTorStart + torStart.Length, posTorEnd - posTorStart - torStart.Length);
                torLink = DownloadHelper.FixNyaaTorrentLink(torLink);

                // remove html codes
                torLink = HttpUtility.HtmlDecode(torLink);

                TorrentLinkVM torrentLink = new TorrentLinkVM(SourceType);
                torrentLink.TorrentDownloadLink = torLink;
                torrentLink.TorrentName = torName;
                torrentLink.Size = torSize.Trim();
                torrentLink.Seeders = torSeed.Trim();
                torrentLink.Leechers = torLeech.Trim();
                torLinks.Add(torrentLink);

                pos = output.IndexOf(startBlock, pos + 1);

            }
            //Console.ReadLine();

            return torLinks;
        }
Esempio n. 16
0
        private List<TorrentLinkVM> ParseSource(string output)
        {
            List<TorrentLinkVM> torLinks = new List<TorrentLinkVM>();

            char q = (char)34;
            string quote = q.ToString();

            //class="tlistthone">Category
            //string startBlock = @"https://sukebei.nyaa.eu/?page=torrentinfo";
            string startBlock = @"class=" + quote + "tlistthone" + quote + ">Category";

            //<td class="tlistname">
            string nameStart1 = @"<td class=" + quote + "tlistname" + quote + "><a href=";

            string nameStart2 = ">";
            string nameEnd2 = "</a>";

            string torStart = "href=" + quote;
            string torEnd = quote;

            string sizeStart = "tlistsize" + quote + ">";
            string sizeEnd = "</td>";

            string seedStart = "tlistsn" + quote + ">";
            string seedEnd = "</td>";

            string leechStart = "tlistln" + quote + ">";
            string leechEnd = "</td>";

            int pos = output.IndexOf(startBlock, 0);
            while (pos > 0)
            {

                if (pos <= 0) break;

                // find the start of the torrent
                int posBegin = output.IndexOf(nameStart1, pos + 1);
                if (posBegin <= 0) break;

                int posNameStart = output.IndexOf(nameStart2, posBegin + nameStart1.Length + 1);
                int posNameEnd = output.IndexOf(nameEnd2, posNameStart + nameStart2.Length + 1);

                string torName = output.Substring(posNameStart + nameStart2.Length, posNameEnd - posNameStart - nameStart2.Length);

                int posTorStart = output.IndexOf(torStart, posNameEnd);
                int posTorEnd = output.IndexOf(torEnd, posTorStart + torStart.Length + 1);

                string torLink = output.Substring(posTorStart + torStart.Length, posTorEnd - posTorStart - torStart.Length);
                torLink = DownloadHelper.FixNyaaTorrentLink(torLink);

                // remove html codes
                torLink = HttpUtility.HtmlDecode(torLink);

                string torSize = "";
                int posSizeStart = output.IndexOf(sizeStart, posNameEnd);
                int posSizeEnd = 0;
                if (posSizeStart > 0)
                {
                    posSizeEnd = output.IndexOf(sizeEnd, posSizeStart + sizeStart.Length + 1);

                    torSize = output.Substring(posSizeStart + sizeStart.Length, posSizeEnd - posSizeStart - sizeStart.Length);
                }

                string torSeed = "";
                int posSeedStart = output.IndexOf(seedStart, posSizeEnd);
                int posSeedEnd = 0;
                if (posSeedStart > 0)
                {
                    posSeedEnd = output.IndexOf(seedEnd, posSeedStart + seedStart.Length + 1);

                    torSeed = output.Substring(posSeedStart + seedStart.Length, posSeedEnd - posSeedStart - seedStart.Length);
                }

                string torLeech = "";
                int posLeechStart = output.IndexOf(leechStart, posSeedStart + 3);
                int posLeechEnd = 0;
                if (posLeechStart > 0)
                {
                    posLeechEnd = output.IndexOf(leechEnd, posLeechStart + leechStart.Length + 1);

                    torLeech = output.Substring(posLeechStart + leechStart.Length, posLeechEnd - posLeechStart - leechStart.Length);
                }

                TorrentLinkVM torrentLink = new TorrentLinkVM(SourceType);
                torrentLink.TorrentDownloadLink = torLink;
                torrentLink.TorrentName = torName;
                torrentLink.Size = torSize.Trim();
                torrentLink.Seeders = torSeed.Trim();
                torrentLink.Leechers = torLeech.Trim();
                torLinks.Add(torrentLink);

                pos = output.IndexOf(nameStart1, pos + 1);

            }
            //Console.ReadLine();

            return torLinks;
        }
Esempio n. 17
0
        private List <TorrentLinkVM> ParseSourceSingleResult(string output)
        {
            List <TorrentLinkVM> torLinks = new List <TorrentLinkVM>();

            char   q     = (char)34;
            string quote = q.ToString();

            // Name:</td><td class="tinfotorrentname">
            string startBlock = @"Name:";

            // class="thead">Name:</td><td class="tinfotorrentname">[Hadena] Koi to Senkyo to Chocolate - 03 [720p] [9CD64623].mkv</td>
            string nameStart = "tinfotorrentname" + quote + ">";
            string nameEnd   = "</td>";

            // Seeders:</td><td class="vtop"><span class="tinfosn">17</span>
            string seedStart = "Seeders:</td><td class=" + quote + "vtop" + quote + "><span class=" + quote + "tinfosn" + quote + ">";
            string seedEnd   = "</span>";

            // Leechers:</td><td class="vtop"><span class="tinfoln">
            string leechStart = "Leechers:</td><td class=" + quote + "vtop" + quote + "><span class=" + quote + "tinfoln" + quote + ">";
            string leechEnd   = "</span>";

            // File size:</td><td class="vtop">193.8 MiB</td>
            string sizeStart = "File size:</td><td class=" + quote + "vtop" + quote + ">";
            string sizeEnd   = "</td>";

            // class="tinfodownloadbutton"><a href="http://www.nyaa.eu/?page=download&#38;tid=334194"
            string torStart = "class=" + quote + "tinfodownloadbutton" + quote + "><a href=" + quote;
            string torEnd   = quote;


            int pos = output.IndexOf(startBlock, 0);

            while (pos > 0)
            {
                if (pos <= 0)
                {
                    break;
                }

                int posNameStart = output.IndexOf(nameStart, pos + 1);
                int posNameEnd   = output.IndexOf(nameEnd, posNameStart + nameStart.Length + 1);

                string torName = output.Substring(posNameStart + nameStart.Length, posNameEnd - posNameStart - nameStart.Length);

                string torSeed      = "";
                int    posSeedStart = output.IndexOf(seedStart, posNameEnd);
                int    posSeedEnd   = 0;
                if (posSeedStart > 0)
                {
                    posSeedEnd = output.IndexOf(seedEnd, posSeedStart + seedStart.Length + 1);
                    torSeed    = output.Substring(posSeedStart + seedStart.Length, posSeedEnd - posSeedStart - seedStart.Length);
                }

                string torLeech      = "";
                int    posLeechStart = output.IndexOf(leechStart, posSeedEnd + 3);
                int    posLeechEnd   = 0;
                if (posLeechStart > 0)
                {
                    posLeechEnd = output.IndexOf(leechEnd, posLeechStart + leechStart.Length + 1);
                    torLeech    = output.Substring(posLeechStart + leechStart.Length, posLeechEnd - posLeechStart - leechStart.Length);
                }

                string torSize      = "";
                int    posSizeStart = output.IndexOf(sizeStart, posLeechEnd);
                int    posSizeEnd   = 0;
                if (posSizeStart > 0)
                {
                    posSizeEnd = output.IndexOf(sizeEnd, posSizeStart + sizeStart.Length + 1);
                    torSize    = output.Substring(posSizeStart + sizeStart.Length, posSizeEnd - posSizeStart - sizeStart.Length);
                }


                int posTorStart = output.IndexOf(torStart, posSizeEnd);
                int posTorEnd   = output.IndexOf(torEnd, posTorStart + torStart.Length + 1);

                string torLink = output.Substring(posTorStart + torStart.Length, posTorEnd - posTorStart - torStart.Length);
                torLink = DownloadHelper.FixNyaaTorrentLink(torLink);
                torLink = "http:" + torLink;

                // remove html codes
                torLink = HttpUtility.HtmlDecode(torLink);

                TorrentLinkVM torrentLink = new TorrentLinkVM(SourceType);
                torrentLink.TorrentDownloadLink = torLink;
                torrentLink.TorrentName         = torName;
                torrentLink.Size     = torSize.Trim();
                torrentLink.Seeders  = torSeed.Trim();
                torrentLink.Leechers = torLeech.Trim();
                torLinks.Add(torrentLink);

                pos = output.IndexOf(startBlock, pos + 1);
            }
            //Console.ReadLine();

            return(torLinks);
        }