Esempio n. 1
0
        /// <summary>
        /// 解析新浪视频视频文件源地址
        /// </summary>
        public ParseResult Parse(ParseRequest request)
        {
            ParseResult pr = new ParseResult();

            /*
             * 参数   解释
             * vid   和以前的vid一样
             * ran   生成的一个随机数
             * p     值为i,意义不明
             * k     16+N长度的hash值
             *
             * 把这个算法拿出去用的都要打PP!
             */
            //var ran = new Random(Environment.TickCount).Next(0, 1000);
            //var key = WhereIsTheKey(request.Id, "0", ran);
            var key = GenerateKey(request.Id + "footstone");
            //合并完整url
            //string url = @"http://v.iask.com/v_play.php?vid=" + request.Id + "&ran=" + ran + "&p=i&k=" + key;
            string url =
                @"http://2dland.vipsinaapp.com/video.php?action=xml&type=xina&vid=" + request.Id + "&key=" + key;
            string source = Network.GetHtmlSource(url, Encoding.UTF8, request.Proxy);
            //视频总长度
            string totallength = Regex.Match(source, @"<timelength>(?<timelength>\d+)</timelength>").Groups["timelength"].Value;
            //Framecount
            string framecount = Regex.Match(source, @"<framecount>(?<framecount>\d+)</framecount>").Groups["framecount"].Value;
            //src
            string src = Regex.Match(source, @"<src>(?<src>\d+)</src>").Groups["src"].Value;

            pr.SpecificResult.Add("totallength", totallength);
            pr.SpecificResult.Add("framecount", framecount);
            pr.SpecificResult.Add("src", src);

            //vstr
            string vstr = Regex.Match(source, @"(?<=<vstr><!\[CDATA\[)\w+").Value;

            //视频信息
            Regex           r       = new Regex(@"<durl>.+?<order>(?<order>\d+)</order>.+?<length>(?<length>\d+)</length>.+?<url><!\[CDATA\[(?<url>.+?)\]\]></url>.+?</durl>", RegexOptions.Singleline);
            MatchCollection matches = r.Matches(source);

            foreach (Match item in matches)
            {
                var pri = new ParseResultItem();
                pri.RealAddress = item.Groups["url"].Value;
                pri.Information.Add("order", item.Groups["order"].Value);
                pri.Information.Add("length", item.Groups["length"].Value);
                pr.Items.Add(pri);
            }
            //返回结果
            return(pr);
        }
Esempio n. 2
0
		/// <summary>
		/// 通过Bilibili接口解析视频文件源地址
		/// </summary>
		public ParseResult Parse(ParseRequest request)
		{
			ParseResult pr = new ParseResult();

			//合并完整url
			//这里使用标准方法调用Bilibili API
			var ts = Convert.ToInt64((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds);
			string url = string.Format(@"http://interface.bilibili.com/playurl?appkey={0}&cid={1}&ts={2}&sign={3}",
							BilibiliPlugin.AppKey,
							request.Id,
							ts,
							Tools.GetStringHash("appkey=" + BilibiliPlugin.AppKey +
												"&cid=" + request.Id +
												"&ts=" + ts +
												BilibiliPlugin.AppSecret));
			var httpRequest = (HttpWebRequest)WebRequest.Create(url);
			httpRequest.Proxy = request.Proxy;
			httpRequest.CookieContainer = request.CookieContainer;

			string source = Network.GetHtmlSource(httpRequest, Encoding.UTF8);

			Video videoInfo;
			var serializer = new XmlSerializer(typeof(Video));
			using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(source)))
			{
				videoInfo = (Video) serializer.Deserialize(ms);
			}

			//视频总长度
			var totallength = videoInfo.Timelength;
			if (totallength != null) pr.SpecificResult.Add("totallength", totallength);
			//src
			var src = videoInfo.Src;
			if (src != null) pr.SpecificResult.Add("src", src);

			//视频信息
			foreach (var durl in videoInfo.Durl)
			{
				var pri = new ParseResultItem()
				{
					RealAddress = durl.Url
				};
				pri.Information.Add("order", durl.Order);
				pri.Information.Add("length", durl.Length);
				pr.Items.Add(pri);
			}
			//返回结果
			return pr;
		}
Esempio n. 3
0
		/// <summary>
		/// 解析新浪视频视频文件源地址
		/// </summary>
		public ParseResult Parse(ParseRequest request)
		{
			ParseResult pr = new ParseResult();

			/*
			 * 参数   解释
			 * vid   和以前的vid一样
			 * ran   生成的一个随机数
			 * p     值为i,意义不明
			 * k     16+N长度的hash值
			 * 
			 * 把这个算法拿出去用的都要打PP!
			 */
			//var ran = new Random(Environment.TickCount).Next(0, 1000);
			//var key = WhereIsTheKey(request.Id, "0", ran);
			var key = GenerateKey(request.Id + "footstone");
			//合并完整url
			//string url = @"http://v.iask.com/v_play.php?vid=" + request.Id + "&ran=" + ran + "&p=i&k=" + key;
			string url =
				@"http://2dland.vipsinaapp.com/video.php?action=xml&type=xina&vid="+request.Id+"&key=" + key;
			string source = Network.GetHtmlSource(url, Encoding.UTF8, request.Proxy);
			//视频总长度
			string totallength = Regex.Match(source, @"<timelength>(?<timelength>\d+)</timelength>").Groups["timelength"].Value;
			//Framecount
			string framecount = Regex.Match(source, @"<framecount>(?<framecount>\d+)</framecount>").Groups["framecount"].Value;
			//src
			string src = Regex.Match(source, @"<src>(?<src>\d+)</src>").Groups["src"].Value;
			
			pr.SpecificResult.Add("totallength", totallength);
			pr.SpecificResult.Add("framecount", framecount);
			pr.SpecificResult.Add("src", src);

			//vstr
			string vstr = Regex.Match(source, @"(?<=<vstr><!\[CDATA\[)\w+").Value;

			//视频信息
			Regex r = new Regex(@"<durl>.+?<order>(?<order>\d+)</order>.+?<length>(?<length>\d+)</length>.+?<url><!\[CDATA\[(?<url>.+?)\]\]></url>.+?</durl>", RegexOptions.Singleline);
			MatchCollection matches = r.Matches(source);
			foreach (Match item in matches)
			{
				var pri = new ParseResultItem();
				pri.RealAddress = item.Groups["url"].Value;
				pri.Information.Add("order", item.Groups["order"].Value);
				pri.Information.Add("length", item.Groups["length"].Value);
				pr.Items.Add(pri);
			}
			//返回结果
			return pr;
		}
Esempio n. 4
0
        /// <summary>
        /// 解析新浪视频视频文件源地址
        /// </summary>
        public ParseResult Parse(ParseRequest request)
        {
            ParseResult pr = new ParseResult();
            //合并完整url
            string url    = @"http://v.iask.com/v_play.php?vid=" + request.Id;
            string source = Network.GetHtmlSource(url, Encoding.UTF8, request.Proxy);
            //视频总长度
            string totallength = Regex.Match(source, @"<timelength>(?<timelength>\d+)</timelength>").Groups["timelength"].Value;
            //Framecount
            string framecount = Regex.Match(source, @"<framecount>(?<framecount>\d+)</framecount>").Groups["framecount"].Value;
            //src
            string src = Regex.Match(source, @"<src>(?<src>\d+)</src>").Groups["src"].Value;

            pr.SpecificResult.Add("totallength", totallength);
            pr.SpecificResult.Add("framecount", framecount);
            pr.SpecificResult.Add("src", src);

            //vstr
            string vstr = Regex.Match(source, @"(?<=<vstr><!\[CDATA\[)\w+").Value;

            //视频信息
            Regex           r       = new Regex(@"<durl>.+?<order>(?<order>\d+)</order>.+?<length>(?<length>\d+)</length>.+?<url><!\[CDATA\[(?<url>.+?)\]\]></url>.+?</durl>", RegexOptions.Singleline);
            MatchCollection matches = r.Matches(source);

            foreach (Match item in matches)
            {
                var    pri  = new ParseResultItem();
                string real = item.Groups["url"].Value;
                if (real.EndsWith(".flv", StringComparison.CurrentCultureIgnoreCase) ||
                    real.EndsWith(".hlv", StringComparison.CurrentCultureIgnoreCase) ||
                    real.EndsWith(".mp4", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (!string.IsNullOrEmpty(vstr))
                    {
                        //real = real +"?vstr=" + vstr;
                    }
                }
                pri.RealAddress = real;
                pri.Information.Add("order", item.Groups["order"].Value);
                pri.Information.Add("length", item.Groups["length"].Value);
                pr.Items.Add(pri);
            }
            //返回结果
            return(pr);
        }
Esempio n. 5
0
        /// <summary>
        /// 解析新浪视频视频文件源地址
        /// </summary>
        public ParseResult Parse(ParseRequest request)
        {
            ParseResult pr = new ParseResult();
            //合并完整url
            string url = @"http://v.iask.com/v_play.php?vid=" + request.Id;
            string source = Network.GetHtmlSource(url, Encoding.UTF8, request.Proxy);
            //视频总长度
            string totallength = Regex.Match(source, @"<timelength>(?<timelength>\d+)</timelength>").Groups["timelength"].Value;
            //Framecount
            string framecount = Regex.Match(source, @"<framecount>(?<framecount>\d+)</framecount>").Groups["framecount"].Value;
            //src
            string src = Regex.Match(source, @"<src>(?<src>\d+)</src>").Groups["src"].Value;

            pr.SpecificResult.Add("totallength", totallength);
            pr.SpecificResult.Add("framecount", framecount);
            pr.SpecificResult.Add("src", src);

            //vstr
            string vstr = Regex.Match(source, @"(?<=<vstr><!\[CDATA\[)\w+").Value;

            //视频信息
            Regex r = new Regex(@"<durl>.+?<order>(?<order>\d+)</order>.+?<length>(?<length>\d+)</length>.+?<url><!\[CDATA\[(?<url>.+?)\]\]></url>.+?</durl>", RegexOptions.Singleline);
            MatchCollection matches = r.Matches(source);
            foreach (Match item in matches)
            {
                var pri = new ParseResultItem();
                string real = item.Groups["url"].Value;
                if (real.EndsWith(".flv", StringComparison.CurrentCultureIgnoreCase) ||
                    real.EndsWith(".hlv", StringComparison.CurrentCultureIgnoreCase) ||
                    real.EndsWith(".mp4", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (!string.IsNullOrEmpty(vstr))
                    {
                        //real = real +"?vstr=" + vstr;
                    }
                }
                pri.RealAddress = real;
                pri.Information.Add("order", item.Groups["order"].Value);
                pri.Information.Add("length", item.Groups["length"].Value);
                pr.Items.Add(pri);
            }
            //返回结果
            return pr;
        }
Esempio n. 6
0
		public ParseResult Parse(string type, string vid, WebProxy proxy)
		{
			ParseResult pr = new ParseResult();

			//合并完整url
			string url = string.Format(@"http://www.tucao.cc/api/videourl.php?type={0}&vid={1}", type, vid);

			string source = Network.GetHtmlSource(url, Encoding.UTF8, proxy).Trim();

			VideoDetails videoInfo;
			var serializer = new XmlSerializer(typeof(VideoDetails));
			using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(source)))
			{
				videoInfo = (VideoDetails)serializer.Deserialize(ms);
			}

			//视频总长度
			var totallength = videoInfo.Timelength;
			if (totallength != null) pr.SpecificResult.Add("totallength", totallength);
			//src
			var src = videoInfo.Src;
			if (src != null) pr.SpecificResult.Add("src", src);

			//视频信息
			foreach (var durl in videoInfo.Durl)
			{
				var pri = new ParseResultItem()
				{
					RealAddress = durl.Url
				};
				pri.Information.Add("order", durl.Order);
				pri.Information.Add("length", durl.Length);
				pr.Items.Add(pri);
			}
			pr.Items.Sort((p1, p2) => int.Parse(p1.Information["order"]) - int.Parse(p2.Information["order"]));
			//返回结果
			return pr;
		}