Example #1
0
        public static IVideoResult GetVideo(string originalUrl, IResourceNetworkLayer networkLayer)
        {
            string targetHost = null;
            string fileName   = null;

            if (Uri.IsWellFormedUriString(originalUrl, UriKind.Absolute))
            {
                var uri = new Uri(originalUrl);
                targetHost = uri.DnsSafeHost.ToLower();
                fileName   = uri.AbsolutePath;
            }

            if (fileName.EndsWith(".gifv"))
            {
                return(new DummyVideoResult(originalUrl, originalUrl.Replace(".gifv", "l.jpg")));
            }
            else if (fileName.EndsWith(".mp4") || fileName.EndsWith(".mpg"))
            {
                return(new DummyVideoResult(originalUrl, null));
            }
            else if (YouTube.IsAPI(originalUrl))
            {
                return(YouTube.GetVideoResult(originalUrl, networkLayer));
            }
            else
            {
                switch (HttpClientUtility.GetDomainFromUrl(originalUrl).ToLower())
                {
                case "liveleak.com":
                    return(Liveleak.GetVideoResult(originalUrl));

                case "gfycat.com":
                    return(Gfycat.GetVideoResult(originalUrl));

                case "vimeo.com":
                    return(Vimeo.GetVideoResult(originalUrl));
                }
            }
            return(null);
        }
Example #2
0
        //someday we will support other video providers
        public static bool IsAPI(string originalUrl)
        {
            var isYoutube = YouTube.IsAPI(originalUrl);

            if (!isYoutube)
            {
                switch (HttpClientUtility.GetDomainFromUrl(originalUrl).ToLower())
                {
                case "gfycat.com":
                    return(!string.IsNullOrWhiteSpace(Gfycat.GetGfyName(originalUrl)));

                case "liveleak.com":
                case "vimeo.com":
                    return(true);

                default:
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }