Ejemplo n.º 1
0
        /// <summary>
        /// Formats the BEncoded string the client reports
        /// </summary>
        /// <returns></returns>
        public static string FormatUrlInfoHash()
        {
            // a temporary solution for getting the proper info_hash
            // by requesting raw url queries
            // see: http://stackoverflow.com/questions/2219647/ [..]
            var infoHashQuery   = HttpContext.Current.Request.Url.Query;
            var infoHashArray   = infoHashQuery.Split(Convert.ToChar("&"));
            var EncodedInfoHash = InfoHash.UrlDecode(
                infoHashArray[0].Replace("?info_hash=", string.Empty)
                ).ToString();

            return(EncodedInfoHash.Replace("-", string.Empty));
        }
Ejemplo n.º 2
0
        static IList <InfoHash> ParseHashes(string infoHash)
        {
            if (string.IsNullOrEmpty(infoHash))
            {
                return(Array.Empty <InfoHash> ());
            }

            var split  = infoHash.Split(HashSeparators, StringSplitOptions.RemoveEmptyEntries);
            var result = new InfoHash[split.Length];

            for (int i = 0; i < split.Length; i++)
            {
                result [i] = InfoHash.UrlDecode(split [i]);
            }
            return(result);
        }
Ejemplo n.º 3
0
        private void ParseHashes(string infoHash)
        {
            if (string.IsNullOrEmpty(infoHash))
            {
                return;
            }

            if (infoHash.IndexOf(',') > 0)
            {
                string[] stringHashs = infoHash.Split(',');
                for (int i = 0; i < stringHashs.Length; i++)
                {
                    hashs.Add(InfoHash.UrlDecode(stringHashs[i]));
                }
            }
            else
            {
                hashs.Add(InfoHash.UrlDecode(infoHash));
            }
        }
Ejemplo n.º 4
0
 private InfoHash Clone(InfoHash p)
 {
     return(InfoHash.UrlDecode(p.UrlEncode()));
 }