Beispiel #1
0
        /// <summary>
        /// 加载内容
        /// </summary>
        public override void LookupTorrentContents(IResourceInfo torrent)
        {
            var url         = GetDetailUrl(torrent);
            var htmlContext = NetworkClient.Create <string>(HttpMethod.Get, url, _referUrl).Send();

            if (!htmlContext.IsValid())
            {
                return;
            }

            var html = htmlContext.Result.SearchStringTag("<th>文件名</th></tr>", "</table>");

            if (string.IsNullOrEmpty(html))
            {
                return;
            }

            var charPos = 0;
            var row     = "";

            while (!string.IsNullOrEmpty((row = html.SearchStringTag("<tr", "</tr>", ref charPos))))
            {
                var m = Regex.Match(row, @"<td>([\.\d]+(\s|&nbsp;)+\w+)</td>.*?<td>(.*?)</td>", RegexOptions.IgnoreCase);
                if (!m.Success)
                {
                    continue;
                }

                var path = m.GetGroupValue(3);
                var size = m.GetGroupValue(1);

                AddFileNode(torrent, BrtUtility.ClearString(path), null, BrtUtility.ClearString(size));
            }
        }
        /// <summary>
        /// 加载相信信息
        /// </summary>
        protected override void LoadFullDetailCore(IResourceInfo info)
        {
            if (info.IsHashLoaded)
            {
                return;
            }

            var ctx = NetworkClient.Create <string>(HttpMethod.Get, GetDetailUrl(info), ReferUrlPage).Send();

            if (!ctx.IsValid())
            {
                return;
            }

            var doc   = new HtmlDocument();
            var tinfo = (ResourceInfo)info;

            doc.LoadHtml(ctx.Result);

            //hash
            tinfo.Hash = doc.DocumentNode.SelectSingleNode("//div[@class='info-table']//dl[5]/dd").InnerText;
            ParseDocumentFiles(tinfo, doc);

            base.LoadFullDetailCore(info);
        }
        /// <summary>
        /// 加载相信信息
        /// </summary>
        protected override void LoadFullDetailCore(IResourceInfo info)
        {
            var url   = GetDetailUrl(info);
            var html  = NetworkClient.Create <string>(HttpMethod.Get, url, ReferUrlPage).Send();
            var sinfo = (ResourceInfo)info;

            if (html.IsValid())
            {
                if (IsHostChanged(html))
                {
                    base.LoadFullDetail(info);
                    return;
                }
                if (IsBotCheckNeeded(html))
                {
                    if (RequireBotCheck())
                    {
                        base.LoadFullDetail(info);
                    }

                    return;
                }

                sinfo.Hash = Regex.Match(html.Result, @"btih:([a-z\d]{40})", RegexOptions.IgnoreCase).GetGroupValue(1);

                LookupTorrentContentsCore(url, info, html.Result);
            }

            base.LoadFullDetailCore(info);
        }
Beispiel #4
0
        /// <summary>
        /// 加载相信信息
        /// </summary>
        protected override void LoadFullDetailCore(IResourceInfo info)
        {
            if (info.IsHashLoaded && (info.SiteData == null || (info.SiteData as SiteInfo).ProvideSiteDownload != null))
            {
                return;
            }

            //load detail page
            var data = GetExtraData(info);
            var page = GetDetailUrl(info);

            var ctx = NetworkClient.Create <string>(HttpMethod.Get, page, ReferUrlPage).Send();

            if (!ctx.IsValid())
            {
                return;
            }

            ((ResourceInfo)info).Hash = Regex.Match(ctx.Result, @"Hash:</span>([a-z\d]{40})", RegexOptions.Singleline | RegexOptions.IgnoreCase).GetGroupValue(1) ?? "";
            //有直接下载链接?
            var downloadLink = Regex.Match(ctx.Result, "href=\"([^\"]+?/torrent/download/[^\"]+)\"", RegexOptions.IgnoreCase | RegexOptions.Singleline);

            if (downloadLink.Success)
            {
                data.ProvideSiteDownload = true;
                data.SiteDownloadLink    = $"https:{downloadLink.Groups[1].Value}";
            }
            else
            {
                data.ProvideSiteDownload = false;
            }

            base.LoadFullDetailCore(info);
        }
Beispiel #5
0
        /// <summary>
        /// 加载相信信息
        /// </summary>
        protected override void LoadFullDetailCore(IResourceInfo info)
        {
            if (info.IsHashLoaded && (info.SiteData == null || (info.SiteData as SiteInfo).ProvideSiteDownload != null))
            {
                return;
            }

            var detailurl = GetDetailUrl(info);
            var ctx       = NetworkClient.Create <string>(HttpMethod.Get, detailurl, ReferUrlPage, allowAutoRedirect: true).Send();

            if (!ctx.IsValid())
            {
                return;
            }

            //Hash
            ((ResourceInfo)info).Hash = (Regex.Match(ctx.Result, @"Hash=([a-z\d]{40})", RegexOptions.IgnoreCase | RegexOptions.Singleline).GetGroupValue(1) ?? "").ToUpper();
            //download url
            var downloadLink = Regex.Match(ctx.Result, @"""([^""]*?isohunt[^""]*?/download\.php\?id[^""]*?)""", RegexOptions.Singleline | RegexOptions.IgnoreCase);
            var data         = GetExtraData(info);

            if (downloadLink.Success)
            {
                data.SiteDownloadLink    = downloadLink.Groups[1].Value;
                data.ProvideSiteDownload = true;
            }
            else
            {
                data.ProvideSiteDownload = false;
            }

            base.LoadFullDetailCore(info);
        }
Beispiel #6
0
        /// <summary>
        /// 加载内容
        /// </summary>
        public override void LookupTorrentContents(IResourceInfo torrent)
        {
            var url         = GetDetailUrl(torrent);
            var htmlContext = NetworkClient.Create <string>(HttpMethod.Get, url, ReferUrlPage).Send();

            if (!htmlContext.IsValid())
            {
                return;
            }

            var html = htmlContext.Result.SearchStringTag("id=\"filelist\">", "</ul>");

            if (string.IsNullOrEmpty(html))
            {
                return;
            }

            var charPos = 0;
            var row     = "";

            while (!string.IsNullOrEmpty((row = html.SearchStringTag("<li", "</li>", ref charPos))))
            {
                var m = Regex.Match(row, "<span.*?>([^<]+)</span><span.*?>([^<]+)</span>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
                if (!m.Success)
                {
                    continue;
                }

                var path = m.GetGroupValue(1);
                var size = m.GetGroupValue(2);

                AddFileNode(torrent, BrtUtility.ClearString(path), null, BrtUtility.ClearString(size));
            }
        }
        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="key"></param>
        /// <param name="pagesize"></param>
        /// <param name="pageindex"></param>
        /// <returns></returns>
        public virtual IResourceSearchInfo Load(string key, SortType sortType, int sortDirection, int pagesize, int pageindex = 1, int loadStack = 0)
        {
            var result = new ResourceSearchInfo(this)
            {
                Key       = key,
                PageIndex = pageindex,
                PageSize  = null
            };

            var url  = GetSearchUrl(key, sortType, sortDirection, pagesize, pageindex);
            var html = NetworkClient.Create <string>(HttpMethod.Get, url, ReferUrlPage, allowAutoRedirect: EnableAutoRedirect).Send();

            if (!html.IsValid())
            {
                return(null);
            }

            if (html.IsRedirection && !DefaultHost.IsNullOrEmpty() && html.Redirection.Current.Host != Host && loadStack < 5)
            {
                Host = html.Redirection.Current.Host;
                return(Load(key, sortType, sortDirection, pagesize, pageindex, loadStack + 1));
            }

            if (!LoadCore(html, url, html.Result, result))
            {
                if (result.RequestResearch && loadStack < 5)
                {
                    return(Load(key, sortType, sortDirection, pagesize, pageindex, loadStack + 1));
                }

                return(null);
            }
            return(result);
        }
Beispiel #8
0
        protected virtual string PrepareSearchKey(string key)
        {
            var ek = _keyMap.GetValue(key);

            if (!ek.IsNullOrEmpty())
            {
                return(ek);
            }

            var task = NetworkClient.Create <string>(HttpMethod.Post, ReferUrlPage, ReferUrlPage, new { s = key }).Send();

            if (!task.IsRedirection)
            {
                return(null);
            }

            if (task.Redirection.Current.Host != Host)
            {
                Host = task.Redirection.Current.Host;
                return(PrepareSearchKey(key));
            }



            //http://diggbt.com/search/Ky5JzEtRSKpUyE0FAA.html
            ek = Regex.Match(task.Redirection.Current.PathAndQuery, @"/search/(.*?)\.html", RegexOptions.IgnoreCase).GetGroupValue(1);
            if (!ek.IsNullOrEmpty())
            {
                _keyMap.AddOrUpdate(key, ek);
            }

            return(ek);
        }
        /// <summary>
        /// 加载内容
        /// </summary>
        public override void LookupTorrentContents(IResourceInfo torrent)
        {
            var detailPage = GetDetailUrl(torrent);
            var html       = NetworkClient.Create <string>(HttpMethod.Get, detailPage, ReferUrlPage).Send();

            if (!html.IsValid())
            {
                return;
            }

            var bodycontent = html.Result.SearchStringTag("<div class=\"files\">", "</div>");

            if (string.IsNullOrEmpty(bodycontent))
            {
                return;
            }

            var pos = 0;
            var row = "";

            while (!string.IsNullOrEmpty((row = bodycontent.SearchStringTag("<li>", "</li>", ref pos))))
            {
                var mcs = Regex.Match(row, @"<li>(.*)\s([\d\.]+\s+\w+)</li>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
                if (!mcs.Success)
                {
                    continue;
                }

                var path = HttpUtility.HtmlDecode(mcs.Groups[1].Value);
                AddFileNode(torrent, path, null, mcs.Groups[2].Value);
            }
        }
        protected override void LoadFullDetailCore(IResourceInfo info)
        {
            var ctx = NetworkClient.Create <HtmlDocument>(HttpMethod.Get, GetDetailUrl(info), ReferUrlPage).Send();

            if (!ctx.IsValid())
            {
                return;
            }

            //hash
            var mlink = ctx.Result.DocumentNode.SelectSingleNode("//h3[contains(text(), 'Hash')]/following::p");

            if (mlink == null)
            {
                return;
            }

            var hash = Regex.Match(mlink.InnerText, @"[a-f\d]{40}").Value;

            info.Hash = hash;

            //files
            var fileContainer = ctx.Result.DocumentNode.SelectSingleNode("//h3[contains(text(), 'Files')]/following::div/following::div");

            ProcessFileList(fileContainer, info);

            base.LoadFullDetailCore(info);
        }
        protected override void LoadFullDetailCore(IResourceInfo info)
        {
            var url = GetDetailUrl(info);
            var ctx = NetworkClient.Create <string>(HttpMethod.Get, url, ReferUrlPage).Send();

            if (!ctx.IsValid())
            {
                return;
            }

            var html = DecodePage(ctx.Result);

            //btih:16429c32f383d5e49b9ca2084c8e57473646a62d
            var hash = Regex.Match(html, @"btih:([a-z\d]{40})", RegexOptions.IgnoreCase).GetGroupValue(1);

            if (hash.IsNullOrEmpty())
            {
                //找不到hash,可能是之前被清理了。所以先直接下载种子看看
                FetchOriginalTorrent(info);
            }
            else
            {
                info.Hash = hash;
                LookupTorrentContentsCore(url, info, html);
            }

            base.LoadFullDetailCore(info);
        }
        protected virtual string PrepareSearchKey(string key)
        {
            var ek = _keyMap.GetValue(key);

            if (!ek.IsNullOrEmpty())
            {
                return(ek);
            }

            var task = NetworkClient.Create <string>(HttpMethod.Post, ReferUrlPage, ReferUrlPage, new { keyword = key }).Send();

            if (!task.IsRedirection)
            {
                return(null);
            }

            //http://diggbt.com/search/Ky5JzEtRSKpUyE0FAA.html
            var path = task.Redirection.Current.PathAndQuery;

            var result = Regex.Match(path, "/([^/]+)/([^/]+)[/\\.].*?html", RegexOptions.IgnoreCase);

            ek = result.GetGroupValue(2);
            if (!ek.IsNullOrEmpty())
            {
                _keyMap.AddOrUpdate(key, ek);
            }

            return(ek);
        }
Beispiel #13
0
 /// <summary>
 /// 加载数据
 /// </summary>
 /// <param name="key"></param>
 /// <param name="pagesize"></param>
 /// <param name="pageindex"></param>
 /// <returns></returns>
 public override IResourceSearchInfo Load(string key, SortType sortType, int sortDirection, int pagesize, int pageindex = 1, int loadStack = 0)
 {
     if (!_loaded)
     {
         NetworkClient.Create <string>(HttpMethod.Get, ReferUrlPage).Send();
         _loaded = true;
     }
     return(base.Load(key, sortType, sortDirection, pagesize, pageindex, loadStack));
 }
Beispiel #14
0
        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="key"></param>
        /// <param name="pagesize"></param>
        /// <param name="pageindex"></param>
        /// <returns></returns>
        public override IResourceSearchInfo Load(string key, SortType sortType, int sortDirection, int pagesize, int pageindex = 1)
        {
            var result = new ResourceSearchInfo(this)
            {
                Key       = key,
                PageIndex = pageindex,
                PageSize  = null
            };

            if (sortType == SortType.PubDate || sortType == SortType.FileSize)
            {
                result.SortType = sortType;
            }

            var url  = GetSearchUrl(key, sortType, sortDirection, pagesize, pageindex);
            var html = NetworkClient.Create <string>(HttpMethod.Get, url, _referUrl).Send();

            if (!html.IsValid())
            {
                return(null);
            }

            //分析
            var    strpos = 0;
            string row;

            while (!string.IsNullOrEmpty((row = html.Result.SearchStringTag("td class=\"idx\"", "</pre>", ref strpos))))
            {
                row = System.Web.HttpUtility.HtmlDecode(row);

                var hash = Regex.Match(row, @"info_hash=([a-f\d]{40})", RegexOptions.IgnoreCase).GetGroupValue(1).ToUpper();
                if (string.IsNullOrEmpty(hash))
                {
                    continue;
                }

                var item = new ResourceInfo();
                item.Hash     = hash;
                item.Provider = this;

                //标题
                item.Title        = Regex.Match(row, "torrent_name\".*?><.*?>(.*?)</a>", RegexOptions.IgnoreCase).GetGroupValue(1).DefaultForEmpty(".....");
                item.DownloadSize = Regex.Match(row, @"大小:</span>.*?attr_val"">([\d\.]+(&nbsp;|\s)+(\w+))", RegexOptions.IgnoreCase).GetGroupValue(1);
                //</span><span class="attr_val">179</span>
                item.FileCount      = Regex.Match(row, @"文件数:</span>.*?attr_val"">([\d\.,\s]+)", RegexOptions.IgnoreCase).GetGroupValue(1).ToInt32();
                item.UpdateTimeDesc = Regex.Match(row, @"添加时间:</span>.*?attr_val"">([\d\.]+(&nbsp;|\s)+(\w+))", RegexOptions.IgnoreCase).GetGroupValue(1);

                result.Add(item);
            }

            result.HasPrevious = html.Result.IndexOf("\">← 上一个", StringComparison.OrdinalIgnoreCase) != -1;
            result.HasMore     = html.Result.IndexOf("\">下一个", StringComparison.OrdinalIgnoreCase) != -1;



            return(result);
        }
Beispiel #15
0
 public void Awake()
 {
     if (Instance != null)
     {
         Destroy(this.gameObject);
     }
     DontDestroyOnLoad(this.gameObject);
     Instance = this;
     network  = NetworkClient.Create();
     Debug.Log("GameManagerInit");
     // network.Connect("127.0.0.1", 4242);
 }
Beispiel #16
0
    public void BecomeServer()
    {
        SetStatus("Server");

        GameObject network = new GameObject("Network");

        network.AddComponent <NetworkServer>();
        NetworkClient.Create(network, "127.0.0.1");
        mode = Mode.server;

        HideCanvas();
    }
Beispiel #17
0
    public void BecomeClient()
    {
        SetStatus("Clinet");

        string ip = gameObject.transform.Find("ipbox").Find("Text").GetComponent <UnityEngine.UI.Text>().text;

        GameObject network = new GameObject("Network");

        NetworkClient.Create(network, ip);
        mode = Mode.client;

        HideCanvas();
    }
        /// <summary>
        /// 执行下载
        /// </summary>
        /// <param name="torrent"></param>
        /// <returns></returns>
        public byte[] Download(IResourceInfo torrent)
        {
            var url   = string.Format("http://torrage.net/torrent/{0}.torrent", torrent.Hash);
            var refer = "http://torrage.net/";

            var ctx = NetworkClient.Create <byte[]>(HttpMethod.Get, url, refer).Send();

            if (!ctx.IsValid())
            {
                return(null);
            }

            return(ValidateTorrentContent(ctx));
        }
        /// <summary>
        /// 更新预览
        /// </summary>
        /// <param name="resource"></param>
        /// <param name="bounds">显示区域</param>
        public void UpdatePreview(IResourceInfo resource, Rectangle bounds)
        {
            if (resource == null || resource == _info)
            {
                return;
            }

            var isCallback = _info == resource;

            _info   = resource;
            _bounds = bounds;

            Image    = Properties.Resources._32px_loading_1;
            SizeMode = PictureBoxSizeMode.AutoSize;

            if (resource.PreviewInfo.ImageUrl.IsNullOrEmpty())
            {
                return;
            }

            //Image
            if (_info.PreviewInfo.PreviewImage == null)
            {
                _network.Create <Image>(HttpMethod.Get, resource.PreviewInfo.ImageUrl, resource.PreviewInfo.ImageUrl)
                .SendAsPromise().Done((s, e) =>
                {
                    var img = e.Result?.Result;
                    if (img != null)
                    {
                        resource.PreviewInfo.PreviewImage = img;
                    }
                    if (_info == resource)
                    {
                        SetImage(img);
                    }
                }).Fail((s, e) =>
                {
                    if (_info == resource)
                    {
                        Image = Properties.Resources.preview_load_failed;
                    }
                });
            }
            else
            {
                SetImage(_info.PreviewInfo.PreviewImage);
            }
            Visible = true;
            BringToFront();
        }
Beispiel #20
0
        /// <summary>
        /// 执行下载
        /// </summary>
        /// <param name="torrent"></param>
        /// <returns></returns>
        public byte[] Download(IResourceInfo torrent)
        {
            var url   = string.Format("http://d1.torrentkittycn.com/?infohash={0}", torrent.Hash);
            var refer = "http://d1.torrentkittycn.com/";

            var ctx = NetworkClient.Create <byte[]>(HttpMethod.Get, url, refer).Send();

            if (!ctx.IsValid() || ctx.Response.ContentType.IndexOf("html") != -1)
            {
                return(null);
            }

            return(ValidateTorrentContent(ctx));
        }
        /// <summary>
        /// 测试核心
        /// </summary>
        /// <param name="uri"></param>
        /// <param name="keyword"></param>
        /// <returns></returns>
        protected virtual TestStatus TestCore(string uri, string keyword)
        {
            var ctx = NetworkClient.Create <string>(HttpMethod.Get, uri, uri).Send();

            if (!ctx.IsValid())
            {
                return(TestStatus.Failed);
            }

            if (!string.IsNullOrEmpty(keyword) && ctx.Result.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) == -1)
            {
                return(TestStatus.Failed);
            }

            return(TestStatus.Ok);
        }
        void FetchOriginalTorrent(IResourceInfo info)
        {
            var data = info.SiteData as SiteInfo;

            if (data == null || data.SiteDownloadLink.IsNullOrEmpty())
            {
                return;
            }

            var torrent = NetworkClient.Create <byte[]>(HttpMethod.Get, data.SiteDownloadLink, ReferUrlPage).Send();

            if (!torrent.IsValid())
            {
                return;
            }

            try
            {
                //update hash
                var contentStream = new MemoryStream(torrent.Result);
                var tf            = new TorrentFile();
                try
                {
                    tf.Load(contentStream, LoadFlag.ComputeMetaInfoHash);
                }
                catch (Exception)
                {
                    return;
                }

                //总下载大小
                var totalsize = tf.Files.Sum(s => s.Length);
                if (tf.Files.Count == 0)
                {
                    totalsize = tf.MetaInfo.Length;
                }
                ((ResourceInfo)info).DownloadSizeValue = totalsize;
                ((ResourceInfo)info).Hash = tf.MetaInfoHashString;
                ((ResourceInfo)info).Data = torrent.Result;

                //report
                //AppContext.Instance.CloudService.ReportDownload(info.Hash, info.Title, GetDetailUrl(info), Info.Name, info.DownloadSize, torrent.Result);
            }
            catch (Exception)
            {
            }
        }
Beispiel #23
0
        /// <summary>
        /// 执行下载
        /// </summary>
        /// <param name="torrent"></param>
        /// <returns></returns>
        public byte[] Download(IResourceInfo torrent)
        {
            var url = $"http://itorrents.org/torrent/{torrent.Hash}.torrent";
            var ctx = NetworkClient.Create <byte[]>(HttpMethod.Get, url, ReferUrlPage).Send();

            if (!ctx.IsValid())
            {
                return(null);
            }

            if (ctx.IsRedirection || ctx.Response.ContentType.IndexOf("application/x-bittorrent") == -1)
            {
                return(null);
            }

            return(ValidateTorrentContent(ctx));
        }
Beispiel #24
0
        /// <summary>
        /// 加载内容
        /// </summary>
        public override void LookupTorrentContents(IResourceInfo torrent)
        {
            var detailPage = GetDetailUrl(torrent);
            var html       = NetworkClient.Create <string>(HttpMethod.Get, detailPage, _referUrl).Send();

            if (!html.IsValid())
            {
                return;
            }

            var mcs = Regex.Matches(html.Result, "<div.*?file\">(?:.*?<span.*?</span>)?(.*?)</div><div.*?size(.*?)</div>", RegexOptions.IgnoreCase);

            foreach (Match match in mcs)
            {
                AddFileNode(torrent, HttpUtility.HtmlDecode(match.Groups[1].Value), null, match.Groups[1].Value);
            }
        }
Beispiel #25
0
        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="key"></param>
        /// <param name="pagesize"></param>
        /// <param name="pageindex"></param>
        /// <returns></returns>
        public override IResourceSearchInfo Load(string key, SortType sortType, int sortDirection, int pagesize, int pageindex = 1)
        {
            var url   = $"http://api.xhub.cn/api.php?op=search_list&callback=jQuery{DateTime.Now.Ticks}&key={UE(key)}&page={pageindex}&_={DateTime.Now.ToJsTicks()}";
            var refer = GetSearchUrl(key, sortType, sortDirection, pagesize, pageindex);

            var result = CollectionUtility.CreateAnymousDictionary("", new { day = DateTime.Now, hits = 0, size = "", title = "" });
            var ctx    = NetworkClient.Create(HttpMethod.Get, url, refer, result: new
            {
                data   = result,
                total  = 0,
                status = 0
            }).Send();

            if (!ctx.IsValid())
            {
                return(null);
            }

            var items = new ResourceSearchInfo(this)
            {
                PageIndex  = pageindex,
                PageSize   = 30,
                TotalPages = (int)Math.Ceiling(ctx.Result.total / 30.0)
            };

            items.HasMore = pageindex < (items.TotalPages ?? 1);
            if (ctx.Result.data != null)
            {
                foreach (var item in ctx.Result.data)
                {
                    var res = CreateResourceInfo(item.Key, item.Value.title);
                    res.UpdateTime   = item.Value.day;
                    res.DownloadSize = item.Value.size;

                    items.Add(res);
                }
            }

            if (base.LoadCore(null, url, null, items))
            {
                return(items);
            }

            return(null);
        }
Beispiel #26
0
        /// <summary>
        /// 执行下载
        /// </summary>
        /// <param name="torrent"></param>
        /// <returns></returns>
        public byte[] Download(IResourceInfo torrent)
        {
            var url   = "http://www.torrent.org.cn/download.php";
            var refer = "http://www.torrent.org.cn/";

            var ctx = NetworkClient.Create <byte[]>(HttpMethod.Post, url, refer, new { hash = torrent.Hash }).Send();

            if (!ctx.IsValid())
            {
                return(null);
            }

            if (ctx.Response.ContentType.IndexOf("html") != -1)
            {
                return(null);
            }

            return(ValidateTorrentContent(ctx));
        }
Beispiel #27
0
        /// <summary>
        /// 加载相信信息
        /// </summary>
        protected override void LoadFullDetailCore(IResourceInfo info)
        {
            if (info.IsHashLoaded)
            {
                return;
            }

            var url = GetDetailUrl(info);
            var ctx = NetworkClient.Create <string>(HttpMethod.Get, url, ReferUrlPage).Send();

            if (!ctx.IsValid())
            {
                return;
            }

            ((ResourceInfo)info).Hash = Regex.Match(ctx.Result, @"btih:([\da-z]{40})", RegexOptions.Singleline | RegexOptions.IgnoreCase).GetGroupValue(1);

            base.LoadFullDetailCore(info);
        }
Beispiel #28
0
        /// <summary>
        /// 加载内容
        /// </summary>
        public override void LookupTorrentContents(IResourceInfo torrent)
        {
            base.LookupTorrentContents(torrent);

            var data = GetExtraData(torrent);
            var url  = $"https://{Host}.monova.org/torrent/files/{data.SiteID}/{HttpUtility.UrlEncode(data.PageName)}.html";

            var ctx = NetworkClient.Create <string>(HttpMethod.Get, url, ReferUrlPage).Send();

            if (!ctx.IsValid())
            {
                return;
            }

            var doc = new HtmlDocument();

            doc.LoadHtml(ctx.Result);

            var filesTable = doc.GetElementbyId($"i_files{data.SiteID}");

            if (filesTable == null)
            {
                return;
            }

            //是否有文件记录?
            if (filesTable.SelectSingleNode(".//tr[1][count(td)=1]") != null)
            {
                return;
            }

            var files = filesTable.SelectNodes(".//tr");

            foreach (HtmlNode htmlNode in files)
            {
                var file = new FileNode()
                {
                    Name       = htmlNode.ChildNodes[0].InnerText,
                    SizeString = htmlNode.ChildNodes[1].InnerText
                };
                torrent.Add(file);
            }
        }
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.U))
        {
            var networkGameObject = new GameObject("Network");
            var server            = networkGameObject.AddComponent <NetworkServer>();
            var client            = NetworkClient.Create(networkGameObject, "127.0.0.1");
        }

        if (Input.GetKeyDown(KeyCode.I))
        {
            var networkGameObject = new GameObject("Network");
            var client            = NetworkClient.Create(networkGameObject, "127.0.0.1");
        }

        if (Input.GetKeyDown(KeyCode.K))
        {
            GameObject.CreatePrimitive(PrimitiveType.Sphere).AddNetComponent <SpawnTestBehaviour>();
        }
    }
Beispiel #30
0
        protected override void LoadFullDetailCore(IResourceInfo info)
        {
            var url    = GetDetailUrl(info);
            var docCtx = NetworkClient.Create <string>(HttpMethod.Get, url, ReferUrlPage).Send();

            if (docCtx.IsValid())
            {
                var html = docCtx.Result;

                //hash
                var hash = Regex.Match(html, @"torrent/([a-f\d]{40})", RegexOptions.IgnoreCase).GetGroupValue(1);
                if (!hash.IsNullOrEmpty())
                {
                    info.Hash = hash;

                    LookupTorrentContentsCore(url, info, html);
                }
            }

            base.LoadFullDetailCore(info);
        }