Пример #1
0
        public static String DownloadUrl(String url)
        {
            StringBuilder sb = new StringBuilder(url);

            sb.Insert(27, "json/");
            sb.Append("?fields=title,stream_h264_url,stream_h264_ld_url,stream_h264_hq_url,stream_h264_hd_url,stream_h264_hd1080_url");

            String JUrl = sb.ToString();

            String content = Web.getContentFromUrl(JUrl);

            if ((content == null) || (String.IsNullOrEmpty(content)))
            {
                return(String.Empty);
            }

            JToken videourl = null;

            try
            {
                var obj = JObject.Parse(content.ToString());

                videourl = obj["stream_h264_hq_url"];

                if ((videourl == null) || (String.IsNullOrEmpty((string)videourl)) || (videourl.Equals(null)))
                {
                    videourl = obj["stream_h264_ld_url"];
                }
                if ((videourl == null) || (String.IsNullOrEmpty((string)videourl)) || (videourl.Equals(null)))
                {
                    videourl = obj["stream_h264_url"];
                }
                if ((videourl == null) || (String.IsNullOrEmpty((string)videourl)) || (videourl.Equals(null)))
                {
                    videourl = obj["stream_h264_hd1080_url"];
                }
                if ((videourl == null) || (String.IsNullOrEmpty((string)videourl)) || (videourl.Equals(null)))
                {
                    videourl = obj["stream_h264_hd_url"];
                }
                if ((videourl == null) || (String.IsNullOrEmpty((string)videourl)) || (videourl.Equals(null)))
                {
                    videourl = null;
                }
            }
            catch (Exception ex)
            {
                if (Log.getMode())
                {
                    Log.println(ex.ToString());
                }
            }

            if (videourl != null)
            {
                if (Log.getMode())
                {
                    Log.println("Video url: " + (string)videourl);
                }

                if (Log.getMode())
                {
                    Log.println("********************************");
                }

                return((string)videourl);
            }
            else
            {
                return(String.Empty);
            }
        }
Пример #2
0
        public static string DownloadUrl(string Url)
        {
            url  = "";
            url_ = "";

            // Download html content
            string content = Web.getContentFromUrlWithProperty(Url);

            if (Log.getMode())
            {
                Log.println("Content: " + content);
            }

            // Search string
            string          pattern = "config_url.*?player_url";
            MatchCollection result  = Regex.Matches(content, pattern, RegexOptions.Singleline);

            for (int ctr = 0; ctr <= result.Count - 1; ctr++)
            {
                if (Log.getMode())
                {
                    Log.println("Match: " + result[ctr].Value);
                }

                url = result[ctr].Value;

                url = url.Replace("config_url\":\"", "");
                url = url.Replace("\",\"player_url", "");
                url = url.Replace("\\", "");

                if (Log.getMode())
                {
                    Log.println("ConfigUrl : " + url);
                }

                // Download html content
                string content_ = Web.getContentFromUrlWithProperty(url);

                // Search string
                string          pattern_ = "fps.*?level3";
                MatchCollection result_  = Regex.Matches(content_, pattern_, RegexOptions.Singleline);

                for (int ctr_ = 0; ctr_ <= result_.Count - 1; ctr_++)
                {
                    if (Log.getMode())
                    {
                        Log.println("Match: " + result_[ctr_].Value);
                    }

                    url_ = Helper.ExtractValue(result_[ctr_].Value, "fps\":", "\",\"cdn\":\"level3");

                    url_ = url_ + "\"";

                    url_ = Helper.ExtractValue(url_, "url\":\"", "\"");
                }

                if (Log.getMode())
                {
                    Log.println("Url : " + url_);
                }

                if (Log.getMode())
                {
                    Log.println("********************************");
                }
            }

            return(url_);
        }
Пример #3
0
        public static List <xHamsterSearchComponents> Query(string querystring, int querypages)
        {
            items = new List <xHamsterSearchComponents>();

            // Do search
            for (int i = 1; i <= querypages; i++)
            {
                // Search address
                string content = Web.getContentFromUrlWithProperty("https://xhamster.com/search?q=" + querystring.Replace(" ", "+") + "&p=" + i);

                if (Log.getMode())
                {
                    Log.println("Content: " + content);
                }

                // Search string
                string          pattern = "<div class=\"video\">.*?</div></div></div>";
                MatchCollection result  = Regex.Matches(content, pattern, RegexOptions.Singleline);

                for (int ctr = 0; ctr <= result.Count - 1; ctr++)
                {
                    if (Log.getMode())
                    {
                        Log.println("Match: " + result[ctr].Value);
                    }

                    title = Helper.ExtractValue(result[ctr].Value, "class='thumb' alt=\"", "\"/><");

                    if (Log.getMode())
                    {
                        Log.println("Title : " + title);
                    }

                    duration = Helper.ExtractValue(result[ctr].Value, "'></div><b>", "</b><u>");

                    if (Log.getMode())
                    {
                        Log.println("Duration : " + duration);
                    }

                    url = Helper.ExtractValue(result[ctr].Value, "<a href=\"", "\"");

                    if (Log.getMode())
                    {
                        Log.println("Url : " + url);
                    }

                    thumbnail = Helper.ExtractValue(result[ctr].Value, "<img src='", "' class='t");

                    if (Log.getMode())
                    {
                        Log.println("Thumbnail : " + thumbnail);
                    }

                    if (Log.getMode())
                    {
                        Log.println("********************************");
                    }

                    xHamsterSearchComponents comp = new xHamsterSearchComponents(title, duration, url, thumbnail);

                    items.Add(comp);
                }
            }

            return(items);
        }