Ejemplo n.º 1
20
        public static MagnetLink Resolve(String magnetLink)
        {
            IEnumerable<KeyValuePair<String, String>> values = null;

            if (IsMagnetLink(magnetLink))
            {
                values = SplitURLIntoParts(magnetLink.Substring(8));
            }

            if (values == null) return null;

            MagnetLink magnet = new MagnetLink();

            foreach (KeyValuePair<string, string> pair in values)
            {
                if (pair.Key == "xt")
                {
                    if (!IsXTValidHash(pair.Value))
                    {
                        continue;
                    }

                    magnet.HashString = pair.Value.Substring(9);
                }

                if (pair.Key == "dn")
                {
                    magnet.Name = pair.Value;
                }

                if (pair.Key == "tr")
                {
                    magnet.Trackers.Add(pair.Value);
                }
            }

            return magnet;
        }
Ejemplo n.º 2
0
        public static MagnetLink Resolve(String magnetLink)
        {
            IEnumerable <KeyValuePair <String, String> > values = null;

            if (IsMagnetLink(magnetLink))
            {
                values = SplitURLIntoParts(magnetLink.Substring(8));
            }

            if (values == null)
            {
                return(null);
            }

            MagnetLink magnet = new MagnetLink();

            foreach (KeyValuePair <string, string> pair in values)
            {
                if (pair.Key == "xt")
                {
                    if (!IsXTValidHash(pair.Value))
                    {
                        continue;
                    }

                    magnet.HashString = pair.Value.Substring(9);
                }

                if (pair.Key == "dn")
                {
                    magnet.Name = pair.Value;
                }

                if (pair.Key == "tr")
                {
                    magnet.Trackers.Add(pair.Value);
                }
            }

            return(magnet);
        }
Ejemplo n.º 3
0
        public static MagnetLink Resolve(string magnetLink)
        {
            var values = IsMagnetLink(magnetLink)
                ? SplitURLIntoParts(magnetLink.Substring(8))
                : null;

            if (values == null)
            {
                return(null);
            }

            var magnet = new MagnetLink();

            foreach (var pair in values)
            {
                if (pair.Key == "xt")
                {
                    if (!IsXTValidHash(pair.Value))
                    {
                        continue;
                    }

                    magnet.HashString = pair.Value.Substring(9);
                }

                if (pair.Key == "dn")
                {
                    magnet.Name = pair.Value;
                }

                if (pair.Key == "tr")
                {
                    magnet.Trackers.Add(pair.Value);
                }
            }

            return(magnet);
        }
Ejemplo n.º 4
0
        public bool Load(MagnetLink magnetLink)
        {
            if (magnetLink == null)
            {
                return(false);
            }
            if (magnetLink.Hash == null)
            {
                return(false);
            }

            HashString = magnetLink.HashString;

            if (magnetLink.Trackers != null)
            {
                foreach (string tracker in magnetLink.Trackers)
                {
                    AnnounceList.Add(tracker);
                }
            }

            return(true);
        }
Ejemplo n.º 5
0
        public Metadata(MagnetLink magnetLink)
        {
            Init();

            Load(magnetLink);
        }
Ejemplo n.º 6
0
        public bool Load(MagnetLink magnetLink)
        {
            if (magnetLink == null) return false;
            if (magnetLink.Hash == null) return false;

            HashString = magnetLink.HashString;

            if (magnetLink.Trackers != null)
            {
                foreach (string tracker in magnetLink.Trackers)
                {
                    AnnounceList.Add(tracker);
                }
            }

            return true;
        }
Ejemplo n.º 7
0
        public Metadata(MagnetLink magnetLink)
        {
            Init();

            Load(magnetLink);
        }