public Media Extract(string url)
        {
            string jsonStr = YoutGetExtract(url);

            Console.WriteLine("miao pai ---- success " + jsonStr);

            return(YouGetCommon.SingleVideoInfo_To_Media(url, jsonStr));
        }
        /// <summary>
        /// 抽取网页真实视频流地址
        /// </summary>
        /// <param name="url">待抽取的网页地址</param>
        /// <returns>视频流的地址</returns>
        /// <exception cref="SWFExtractorNS.InvalidURLException">非法URL</exception>
        /// <exception cref="SWFExtractorNS.DomainNotSupportedException">域不支持</exception>
        public static Media Extract(String url)
        {
            try
            {
                String domain       = "";
                string youGetDomain = YouGetCommon.Url_to_key(url);
                try
                {
                    domain = HTTPHelper.ParseDomain(url);
                }
                catch (Exception e)
                {
                    Console.Write(e.Message);
                }
                Console.WriteLine("-------------------------------------------------------------");
                if (domain == null || domain.Equals("") || extractors.ContainsKey(youGetDomain))
                {
                    domain = youGetDomain;
                }

                if (domain == null)
                {
                    throw new InvalidURLException(url);
                }
                if (!extractors.ContainsKey(domain))
                {
                    int index = url.LastIndexOf('.');
                    if (index > 0)
                    {
                        String lastComponent = url.ToLower().Substring(index);
                        if (lastComponent.CompareTo(".mp4") == 0 || lastComponent.CompareTo(".flv") == 0)
                        {
                            throw new DomainNotSupportedException(domain);
                        }
                    }

                    HTML5Extractor extractor = new HTML5Extractor();
                    Media          videoURL  = extractor.Extract(url);
                    if (videoURL != null)
                    {
                        return(videoURL);
                    }
                    throw new DomainNotSupportedException(domain);
                }
                else
                {
                    Type       extractorType = extractors[domain];
                    IExtractor extractor     = Activator.CreateInstance(extractorType) as IExtractor;
                    return(extractor.Extract(url));
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
Esempio n. 3
0
        public Media Extract(string url)
        {
            //throw new NotImplementedException();
            string jsonStr = YoutGetExtract(url);

            Console.WriteLine("Yixia success-------------" + jsonStr);
            if (jsonStr == null)
            {
                return(null);
            }
            return(YouGetCommon.SingleVideoInfo_To_Media(url, jsonStr));
        }
        public string Miaopai_load(string url)
        {
            Console.WriteLine("miao pai start ----- url = " + url);
            string fid = YouGetCommon.MatchOne(url, @"\?fid=(\d{4}:\w{32})");

            if (fid != null && !fid.Equals(""))
            {
                return(Miaopai_load_bg_fid(fid));
            }
            else if (url.Contains("/p/230444"))
            {
                fid = YouGetCommon.MatchOne(url, @"/p/230444(\w+)");
                return(Miaopai_load_bg_fid("1034:" + fid));
            }
            else
            {
                string mobile_page = YouGetCommon.Get_content(url, fake_headers_mobile);
                Regex  reg         = new Regex(@"""page_url""\s*:\s*""([^""]+)""");
                Match  m           = reg.Match(mobile_page);
                string videoUrl    = YouGetCommon.MatchOne(mobile_page, @"<video.*src=['""](.*?)['""]");
                if (m != null && m.Success)
                {//网页内容里面没有数据
                    string escaped_url = m.Groups[1].Value;
                    string webUrl      = HttpUtility.UrlEncode(escaped_url);
                    return(Miaopai_load(escaped_url));
                }
                else if (videoUrl != null)  //网页内容里直接有video信息
                {
                    Console.WriteLine("web page content video === ");
                    return(YouGetCommon.Url_info_to_json(videoUrl, null));
                }
                else  //尝试header中是否有Location
                {
                    Dictionary <string, string> mobile_header = YouGetCommon.GetHTTPResponseHeaders(url, fake_headers_mobile);
                    string key = "Location";
                    if (mobile_header.ContainsKey(key))
                    {
                        string locationUrl = mobile_header[key];
                        Console.WriteLine("go other link == " + locationUrl);
                        if (locationUrl != null && !locationUrl.Equals(""))
                        {
                            string locaHost = getExtractUrlHost(locationUrl);
                            if (locaHost != null && !locaHost.Equals(""))  //可以转条连接
                            {
                                return(new YouGetExtractor().YoutGetExtract(locationUrl));
                            }
                        }
                    }
                }
            }

            return(null);
        }
Esempio n. 5
0
        public string YoutGetExtract(string url)
        {
            String domain = YouGetCommon.Url_to_key(url);

            if (!youGetType.ContainsKey(domain))
            {
                throw new DomainNotSupportedException(domain);
            }

            Type             extractorType = youGetType[domain];
            IYouGetExtractor extractor     = Activator.CreateInstance(extractorType) as IYouGetExtractor;

            return(extractor.YoutGetExtract(url));
        }
Esempio n. 6
0
        public string Yixia_xiaokaxiu_load_by_scid(string scid)
        {
            string api_endpoint = "http://api.xiaokaxiu.com/video/web/get_play_video?scid=" + scid;
            string html         = YouGetCommon.Get_content(api_endpoint, null);

            if (html == null)
            {
                return(null);
            }
            JObject api_content = (JObject)JsonConvert.DeserializeObject(html);
            string  video_url   = api_content["data"]["linkurl"].ToString();
            string  title       = api_content["data"]["title"].ToString();
            string  resultInfo  = YouGetCommon.Url_info_to_json(video_url, null);

            return(resultInfo);
        }
Esempio n. 7
0
        private string Get_miaopai_scid(string url)
        {
            string scid = null;

            string[] regs = new string[] { @"miaopai\.com/show/channel/(.+)\.htm",
                                           @"miaopai\.com/show/(.+)\.htm",
                                           @"m\.miaopai\.com/show/channel/(.+)\.htm",
                                           @"m\.miaopai\.com/show/channel/(.+)" };
            foreach (string reg in regs)
            {
                scid = YouGetCommon.MatchOne(url, reg);
                if (scid != null && !"".Equals(scid))
                {
                    return(scid);
                }
            }
            return(null);
        }
Esempio n. 8
0
        public string Yixia_miaopai_load_by_scid(string scid)
        {
            string api_endpoint = "http://api.miaopai.com/m/v2_channel.json?fillType=259&scid=" + scid + "&vend=miaopai";
            string html         = YouGetCommon.Get_content(api_endpoint, null);

            if (html == null)
            {
                return(null);
            }
            JObject api_content = (JObject)JsonConvert.DeserializeObject(html);
            string  urlTemp     = api_content["result"]["stream"]["base"].ToString();
            string  video_url   = YouGetCommon.MatchOne(urlTemp, @"(.+)\?vend");
            string  title       = api_content["result"]["ext"]["t"].ToString();

            string resultInfo = YouGetCommon.Url_info_to_json(video_url, null);

            return(resultInfo);
        }
Esempio n. 9
0
        public string Krcom_load(string url)
        {
            string page = YouGetCommon.Get_content(url, null);

            if (page != null)
            {
                try
                {
                    //Console.Write(page);
                    //Console.WriteLine("===================");
                    string videosource = YouGetCommon.MatchOne(page, @"video-sources=\\""fluency=(.*?)\\""");


                    string decodeVideoSource = HttpUtility.UrlDecode(videosource);

                    Console.WriteLine("Krcom_load ---" + decodeVideoSource);
                    string[] videoUrls = Regex.Split(decodeVideoSource, "//", RegexOptions.IgnoreCase);;
                    JArray   jArr      = new JArray();
                    foreach (string v in videoUrls)
                    {
                        if (!YouGetCommon.isEmptyStr(v))
                        {
                            string  videoUrl = "http://" + v;
                            JObject json     = new JObject();
                            json.Add("video_url", videoUrl);
                            if (videoUrl.Contains("map4"))
                            {
                                json.Add("video_type", "mp4");
                            }

                            jArr.Add(json);
                        }
                    }
                    return(jArr.ToString());
                }
                catch (Exception e) {
                    Console.WriteLine(e.Message);
                }
            }
            return(null);
        }
Esempio n. 10
0
        public string Miaopai_load_bg_fid(string fid)
        {
            string page_url    = "http://video.weibo.com/show?fid=" + fid + "&type=mp4";
            string mobile_page = YouGetCommon.Get_content(page_url, fake_headers_mobile);

            if (mobile_page != null)
            {
                string p = @"<video id=.*?src=[\'""](.*?)[\'""]\W";
                Console.WriteLine(p);
                string url   = YouGetCommon.MatchOne(mobile_page, p);
                string title = YouGetCommon.MatchOne(mobile_page, @"<title>((.|\n)+?)</title>");
                if (title == null || title.Equals(""))
                {
                    title = fid;
                }
                title = title.Replace("\n", "_");

                return(YouGetCommon.Url_info_to_json(url, null));
            }
            return(null);
        }
Esempio n. 11
0
 private string getExtractUrlHost(string url)
 {
     return(YouGetCommon.MatchOne(url, @"(https?://[^/]+)/"));
 }
Esempio n. 12
0
 private string getHostName(string host)
 {
     return(YouGetCommon.MatchOne(host, @"//([^.]+)\."));
 }