Ejemplo n.º 1
0
        public byte[] Fetch(MonoTorrent.MagnetLink magnet)
        {
            string url = string.Format("http://torrage.com/torrent/{0}.torrent", magnet.InfoHash.ToHex());

            using (WebClient nc = new WebClient())
            {
                nc.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/18.0 (compatible; MSIE 10.0; Windows NT 5.2; .NET CLR 3.5.3705;)");

                byte[] gzip_data = null;

                try
                {
                    gzip_data = nc.DownloadData(url);
                }
                catch (WebException wex)
                {
                    if (wex.Message.Contains("404"))
                    {
                        return(null);
                    }
                }
                catch (Exception) { return(null); }

                if (gzip_data == null || gzip_data.Length == 0)
                {
                    return(null);
                }

                byte[] data = Utility.DecompressGzip(gzip_data);

                return(data);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            string torrentPath = AppDomain.CurrentDomain.BaseDirectory + "a.torrent";

            #region BencodeNET

            // Parse torrent by specifying the file path
            var parser = new BencodeParser(); // Default encoding is Encoding.UT8F, but you can specify another if you need to

            //非BT种子文件 会解析异常
            var torrent = parser.Parse <Torrent>(torrentPath);

            string MagnetLink = torrent.GetMagnetLink(MagnetLinkOptions.None);

            Console.WriteLine(MagnetLink);

            Console.WriteLine(torrent.CreationDate);

            #endregion

            MonoTorrent.Common.Torrent mtorrent = MonoTorrent.Common.Torrent.Load(torrentPath);

            string link1 = "magnet:?xt=urn:btih:5623641b93b175e9b2c8fb0466427ca59de25d32&dn=SAMA-327r-avi";

            string magnetLink = "magnet:?xt=urn:btih:" + BitConverter.ToString(mtorrent.InfoHash.ToArray()).Replace("-", "");

            Console.WriteLine(magnetLink);


            MonoTorrent.MagnetLink link = new MonoTorrent.MagnetLink(link1);

            Console.WriteLine(link.Name);
        }
Ejemplo n.º 3
0
        protected virtual string GetInfoHash(XElement item)
        {
            var magnetUrl = GetMagnetUrl(item);
            if (magnetUrl.IsNotNullOrWhiteSpace())
            {
                try
                {
                    var magnetLink = new MonoTorrent.MagnetLink(magnetUrl);
                    return magnetLink.InfoHash.ToHex();
                }
                catch
                {
                }
            }

            return null;
        }
Ejemplo n.º 4
0
        protected virtual string GetInfoHash(XElement item)
        {
            var magnetUrl = GetMagnetUrl(item);

            if (magnetUrl.IsNotNullOrWhiteSpace())
            {
                try
                {
                    var magnetLink = new MonoTorrent.MagnetLink(magnetUrl);
                    return(magnetLink.InfoHash.ToHex());
                }
                catch
                {
                }
            }

            return(null);
        }
Ejemplo n.º 5
0
 public MagnetLinkNotification(EventType type, MonoTorrent.MagnetLink m)
     : this(type, m.Name, m.InfoHash.ToHex())
 {
 }