Пример #1
0
        public URLData GetHTTPURL(Subfile_List item, string info_hash)
        {
            URLData   res = new URLData();
            WebClient web = new WebClient();

            #region 获取File_hash

            string postString = "m=jx?hash=" + info_hash + "&index=" + item.index;
            byte[] postData   = Encoding.UTF8.GetBytes(postString);                                                          //编码,尤其是汉字,事先要看下抓取网页的编码方式
            //string url = "http://1.jxbt.applinzi.com/jxcode.php?hash=" + info_hash + "&index=" + item.index;//地址
            string url = "http://mt520.xyz:8080/CPServer/cloudplayer/geturlopen?hash=" + info_hash + "&index=" + item.index; //地址
            web.Headers.Add("Accept", "*/*");
            web.Headers.Add("Referer", url);
            web.Headers.Add("Accept-Language", "zh-cn");
            web.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            web.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1)");
            web.Headers.Add("Host", "mt520.xyz:8080");
            web.Headers.Add("Cache-Control", "no-cache");
            string srcString = web.DownloadString(url);
            for (int i = 0; i < 2; ++i)
            {
                if (srcString.Length <= 0)
                {
                    srcString = web.DownloadString(url);
                }
                else
                {
                    break;
                }
            }

            Regex           reg = new Regex("Success#(.+?)#(.+?)");
            MatchCollection mc  = reg.Matches(srcString);
            if (mc.Count == 0)
            {
                return(res);
            }

            res.url    = mc[0].Groups[1].Value;
            res.cookie = mc[0].Groups[2].Value;
            return(res);

            if (string.IsNullOrEmpty(srcString) || srcString.Contains("\"ret\" : 2"))
            {
                return(res);
            }
            QQFenXiang qqfx = JSONParser.FromJson <QQFenXiang>(srcString);
            if (qqfx.data[0].file_hash.Equals("0000000000000000000000000000000000000000"))
            {
                return(res);
            }

            string File_hash = qqfx.data[0].file_hash;

            #endregion

            #region 第三步:连线QQ取播放地址
            byte[] responseData;
            postString = string.Format("hash={0}&filename=movie", File_hash);
            postData   = Encoding.UTF8.GetBytes(postString);                     //编码,尤其是汉字,事先要看下抓取网页的编码方式
            url        = "http://lixian.qq.com/handler/lixian/get_http_url.php"; //地址
            web.Headers.Clear();
            web.Headers.Add("Referer", "http://lixian.qq.com/handler/lixian/get_http_url.php");
            web.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
            web.Headers.Add("Accept-Language", "zh-cn");
            web.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            web.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1; 125LA; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)");
            responseData = web.UploadData(url, "POST", postData);//得到返回字符流
            //解码
            byte[] buffer2 = Encoding.Convert(Encoding.UTF8, Encoding.Default, responseData, 0, responseData.Length);
            srcString = Encoding.Default.GetString(buffer2, 0, buffer2.Length).TrimStart('?');
            if (string.IsNullOrEmpty(srcString) || srcString.Contains("\"ret\":-1"))
            {
                return(res);
            }
            XFPlay xf = JSONParser.FromJson <XFPlay>(srcString);
            #endregion

            string com_url = xf.data.com_url;

            #region 分析真实地址调用播放
            string comkey   = com_url.Substring(com_url.IndexOf("ftn_handler/"), com_url.IndexOf("/movie") - com_url.IndexOf("ftn_handler/")).Replace("ftn_handler/", "");
            string urlstart = "cd";
            try
            {
                urlstart = com_url.Substring(com_url.IndexOf("http://"), com_url.IndexOf(".qq.com") - com_url.IndexOf("http://")).Replace("http://", "").Replace("xflx", "").Replace("store", "").Replace("ctfs", "").Replace("btfs", "").Replace("ftn", "").Replace(".", "").Replace("src", "xa");
            }
            catch { }
            string com_cookie = xf.data.com_cookie;
            com_url = GetPlayUrl(comkey, urlstart, com_cookie);
            if (string.IsNullOrEmpty(com_url))
            {
                return(res);
            }
            string VideoName = HttpUtility.UrlDecode(item.name).Replace("【失效链接】", "").Replace("【无效链接】", "").Replace("【处理中,请等待】", "");
            res.url    = com_url;
            res.cookie = com_cookie;
            return(res);

            #endregion
        }
Пример #2
0
        public URLData GetHTTPURL_V1(Subfile_List item, string info_hash)
        {
            URLData   res = new URLData();
            WebClient web = new WebClient();

            #region 旧版接口

            /*
             #region QQ接口取File_hash
             * string postString = "torrent_para={\"uin\":\"985189148\",\"hash\":\"" + info_hash + "\",\"taskname\":\"M\",\"data\":[{\"index\":\"" + item.index + "\",\"filesize\":\"1\",\"filename\":\"M.mkv\"}]}";
             * byte[] postData = Encoding.UTF8.GetBytes(postString);//编码,尤其是汉字,事先要看下抓取网页的编码方式
             * string url = "http://fenxiang.qq.com/upload/index.php/upload_c/checkExist";//地址
             * web.Headers.Add("Referer", "http://fenxiang.qq.com/upload/index.php/upload_c/checkExist");
             * web.Headers.Add("Accept", "*//*");//此行删除一个/
             * web.Headers.Add("Accept-Language", "zh-cn");
             * web.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
             * web.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1; 125LA; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)");
             * byte[] responseData = web.UploadData(url, "POST", postData);//得到返回字符流
             * for (int i = 0; i < 10; ++i)
             * {
             *  if (responseData.Length <= 0)
             *      responseData = web.UploadData(url, "POST", postData);//得到返回字符流
             *  else
             *      break;
             * }
             * string srcString = Encoding.UTF8.GetString(responseData);//解码
             * if (string.IsNullOrEmpty(srcString) || srcString.Contains("\"ret\" : 2"))
             *  return res;
             * QQFenXiang qqfx = JSONParser.FromJson<QQFenXiang>(srcString);
             * if (qqfx.data[0].file_hash.Equals("0000000000000000000000000000000000000000"))
             *  return res;
             #endregion
             *
             * string File_hash = qqfx.data[0].file_hash;
             *
             * string File_hash = "e88137ca28580665330a2287b3c4f3288f946ffa";
             * string postString;
             * byte[] postData;
             * string url;
             * byte[] responseData;
             * string srcString;
             */
            #endregion

            #region 获取File_hash

            string postString = "m=jx?hash=" + info_hash + "&index=" + item.index;
            byte[] postData   = Encoding.UTF8.GetBytes(postString);                                                           //编码,尤其是汉字,事先要看下抓取网页的编码方式
            //string url = "http://1.jxbt.applinzi.com/jx.php?hash=" + info_hash + "&index=" + item.index;//地址
            string url = "http://mt520.xyz:8080/CPServer/cloudplayer/getlistopen?hash=" + info_hash + "&index=" + item.index; //地址
            web.Headers.Add("Accept", "*/*");
            web.Headers.Add("Referer", url);
            web.Headers.Add("Accept-Language", "zh-cn");
            web.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            web.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1)");
            web.Headers.Add("Host", "1.jxbt.applinzi.com");
            web.Headers.Add("Cache-Control", "no-cache");
            string srcString = web.DownloadString(url);
            for (int i = 0; i < 5; ++i)
            {
                if (srcString.Length <= 0)
                {
                    srcString = web.DownloadString(url);
                }
                else
                {
                    break;
                }
            }
            if (string.IsNullOrEmpty(srcString) || srcString.Contains("\"ret\" : 2"))
            {
                return(res);
            }
            QQFenXiang qqfx = JSONParser.FromJson <QQFenXiang>(srcString);
            if (qqfx.data[0].file_hash.Equals("0000000000000000000000000000000000000000"))
            {
                return(res);
            }

            string File_hash = qqfx.data[0].file_hash;

            #endregion

            #region 第三步:连线QQ取播放地址
            byte[] responseData;
            postString = string.Format("hash={0}&filename=movie", File_hash);
            postData   = Encoding.UTF8.GetBytes(postString);                     //编码,尤其是汉字,事先要看下抓取网页的编码方式
            url        = "http://lixian.qq.com/handler/lixian/get_http_url.php"; //地址
            web.Headers.Clear();
            web.Headers.Add("Referer", "http://lixian.qq.com/handler/lixian/get_http_url.php");
            web.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
            web.Headers.Add("Accept-Language", "zh-cn");
            web.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            web.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1; 125LA; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)");
            responseData = web.UploadData(url, "POST", postData);//得到返回字符流
            //解码
            byte[] buffer2 = Encoding.Convert(Encoding.UTF8, Encoding.Default, responseData, 0, responseData.Length);
            srcString = Encoding.Default.GetString(buffer2, 0, buffer2.Length).TrimStart('?');
            if (string.IsNullOrEmpty(srcString) || srcString.Contains("\"ret\":-1"))
            {
                return(res);
            }
            XFPlay xf = JSONParser.FromJson <XFPlay>(srcString);
            #endregion

            string com_url = xf.data.com_url;

            #region 分析真实地址调用播放
            string comkey   = com_url.Substring(com_url.IndexOf("ftn_handler/"), com_url.IndexOf("/movie") - com_url.IndexOf("ftn_handler/")).Replace("ftn_handler/", "");
            string urlstart = "cd";
            try
            {
                urlstart = com_url.Substring(com_url.IndexOf("http://"), com_url.IndexOf(".qq.com") - com_url.IndexOf("http://")).Replace("http://", "").Replace("xflx", "").Replace("store", "").Replace("ctfs", "").Replace("btfs", "").Replace("ftn", "").Replace(".", "").Replace("src", "xa");
            }
            catch { }
            string com_cookie = xf.data.com_cookie;
            com_url = GetPlayUrl(comkey, urlstart, com_cookie);
            if (string.IsNullOrEmpty(com_url))
            {
                return(res);
            }
            string VideoName = HttpUtility.UrlDecode(item.name).Replace("【失效链接】", "").Replace("【无效链接】", "").Replace("【处理中,请等待】", "");
            res.url    = com_url;
            res.cookie = com_cookie;
            return(res);

            #endregion
        }