Exemple #1
0
        static string youKuSwf = "http://player.youku.com/player.php/"; //-----一般优酷视频播放地址都包含的一段

        #endregion Fields

        #region Methods

        public string[] GetVideoInfo(string url)
        {
            string[] result = new string[3];
            if (url.Trim() == "") return result;

            #region 优酷视频地址
            if (url.ToLower().Contains(youKuSwf)) //包含优酷视频前缀
            {
                YouKuSwf yks = new YouKuSwf();
                result = yks.GetVideoInfo(url);
            }
            #region 优酷视频网页地址
            else if (url.ToLower().Contains(youKuHtml))//包含优酷网页前缀
            {
                YouKuHtml ykl = new YouKuHtml();
                result = ykl.GetVideoInfo(url);
            }
            #endregion

            #endregion
            #region 土豆地址
            else if (url.ToLower().Contains(tuDouMain))//包含土豆网页前缀
            {
                if (url.ToLower().Contains(".swf"))
                {
                    TuDouSwf ts = new TuDouSwf();
                    result = ts.GetVideoInfo(url);
                }
                else
                {
                    TuDouHtml th = new TuDouHtml();
                    result = th.GetVideoInfo(url);
                }
            }
            else
            {
                //扩展:
            }
            #endregion
            return result;
        }
Exemple #2
0
        static string htuDouVideoUrlId = "http://v2.tudou.com/v?vn=02&st=1%2C2&it={0}"; //-------根据lid查询视频地址需要的id

        #endregion Fields

        #region Methods

        public override string[] GetVideoInfo(string url)
        {
            Result[0] = url;//网页地址
              string lid = "";
              //1.规则的网页地址:即带html后缀
              if (url.ToLower().Contains(".html"))
              {
              //A:http://www.tudou.com/playlist/p/a64151i123974208.html (playlist后面包含a)

              //B:http://www.tudou.com/playlist/p/l14818376i123661980.html?union_id=100493_100001_02_01 (playlist后面l)
              string fileName = string.Empty;
              fileName = GetVideoIdFromUrl(url);

              #region L
              if (fileName.ToLower().StartsWith("l"))
              {
                  int iindex = fileName.ToLower().IndexOf("i");
                  if (iindex < 0) iindex = fileName.Length - 1;
                  int lindex = fileName.ToLower().IndexOf("l");
                  if (lindex >= 0)
                  {
                      lid = fileName.Substring(lindex + 1, iindex - lindex - 1);
                  }
                  else
                  {
                      lid = "";
                  }
                  //获取视频地址

                  string vedioSl = GetSomething(GetResultFromUrl(CombineStr(htuDouVideoUrlId, lid)), "cd=\"[\\S]+\"");
                  if (vedioSl != "")
                  {
                      Result[1] = CombineStr(htuDouVideoUrlById, vedioSl.Remove(0, 4).Replace("\"", ""));
                  }
                  else
                  {
                      Result[1] = url;
                  }
                  //获取缩略图
                  string newurl = CombineStr(htuDouThumUrl, lid);
                  string picUrl = GetSomething(GetResultFromUrl(newurl).Replace(@"\/", "/"), "http://([\\w]+[./]*)+");
                  //if (System.IO.Path.GetFileNameWithoutExtension(picUrl).ToLower() == "p")
                  //{
                  if (picUrl != "")
                  {
                      Result[2] = picUrl.Replace(System.IO.Path.GetFileName(picUrl), string.Empty) + "w" + System.IO.Path.GetExtension(picUrl);
                  }
                  else
                  {
                      Result[2] = "服务器没有该视频的缩略图";
                  }
              }
              #endregion
              #region A
              else if (fileName.ToLower().StartsWith("a"))
              {
                  string lvid = string.Empty;
                  string iid = string.Empty;
                  if (fileName.ToLower().Trim().IndexOf("i") > 0)
                  {
                      lvid = fileName.Trim().Substring(1, fileName.ToLower().Trim().IndexOf("i") - 1);
                      iid = fileName.Trim().Remove(0, fileName.ToLower().Trim().IndexOf("i") + 1);
                  }
                  else
                  {
                      lvid = fileName.Trim().Remove(0, fileName.ToLower().Trim().IndexOf("a") + 1);
                  }

                  string html = GetResultFromUrl(url);
                  string aCode = string.Empty;

                  aCode = GetSomething(html, "aid_code[ ]*=[ ]*acode[ ]*=[ ]*'[\\w_-]*'");
                  aCode = aCode.Remove(0, aCode.IndexOf("'")).Replace("'", "");

                  if (iid == "")
                  {
                      Result[1] = CombineStr(htuDouVideoAUrlS, aCode);
                  }
                  else
                  {
                      Result[1] = CombineStr(htuDouVideoAUrl, aCode, iid);
                  }

                  Result[2] = GetSomething(GetResultFromUrl(CombineStr(htuDouVideoAImng, lvid)).Replace(@"\/", "/"), hypeLinkRegxStr);
              }
              #endregion
              }
              else if (url.ToLower().StartsWith(htuDouContainUrl))
              {
              int paIndex = url.IndexOf('?');
              string[] directs = url.Remove(paIndex > 0 ? paIndex : url.Length - 1).Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
              string param = string.Empty;//获取地址中的id比如获取http://www.tudou.com/programs/view/uuxZVpkDtUw/?union_id=100493_100001_02_01中uuxZVpkDtUw
              if (directs.Length > 0)
                  param = directs[directs.Length - 1];
              //-----------------------------------得到视频地址---------------------------------
              Result[1] = CombineStr(htuDouVideoUrlByKey, param);
              //接下来得到缩略图,调用方法获取视频缩略图
              TuDouSwf ts = new TuDouSwf();

              Result[2]=ts.GetVideoInfo(CombineStr(htuDouVideoUrlByKey, param))[2];
              }
              else //其他情况
              {
            //
              }
              return Result;
        }