Пример #1
0
        /// <summary>
        /// Create direct picture link from given url
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        internal static async Task <string> createPictureLink(string url)
        {
            // is it already rdy?
            if (isPictureLink(url))
            {
                return(url);
            }

            // try to create direct link
            if (url.IndexOf("imgur", StringComparison.InvariantCultureIgnoreCase) != -1)
            {
                // imgur
                try
                {
                    url = await ImgurScraper.GetImageUrl(url);
                }
                catch (WebException we)
                {
                    // imgur scrape failed
                    Debug.WriteLine(we.Message);
                }
            }

            // result
            if (isPictureLink(url))
            {
                return(url);
            }
            return(null);
        }
Пример #2
0
        public void RemoveParameters()
        {
            string yes = "http://i.imgur.com/UD5PpJs.jpg?1?fb";
            string no  = "http://i.imgur.com/UD5PpJs.jpg";

            Assert.AreNotEqual(yes, ImgurScraper.removeParameters(yes));
            Assert.AreEqual(no, ImgurScraper.removeParameters(no));
            Assert.AreEqual("http://i.imgur.com/sgLIGyk.png", ImgurScraper.removeParameters("http://i.imgur.com/sgLIGyk.png?1"));
        }
Пример #3
0
 public void GetImageUrlFromUrl()
 {
     Assert.IsNotNull(ImgurScraper.GetImageUrl("http://imgur.com/BSMhjEp").Result);
 }
Пример #4
0
 public void GetImageUrlFromUrl2()
 {
     Assert.IsNotNull(ImgurScraper.GetImageUrl("http://imgur.com/DwWgZeH").Result);
 }
Пример #5
0
 public void GetImageUrlFromId()
 {
     Assert.IsNotNull(ImgurScraper.GetImageUrl("CXdOCxi").Result);
 }