/// <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); }
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")); }
public void GetImageUrlFromUrl() { Assert.IsNotNull(ImgurScraper.GetImageUrl("http://imgur.com/BSMhjEp").Result); }
public void GetImageUrlFromUrl2() { Assert.IsNotNull(ImgurScraper.GetImageUrl("http://imgur.com/DwWgZeH").Result); }
public void GetImageUrlFromId() { Assert.IsNotNull(ImgurScraper.GetImageUrl("CXdOCxi").Result); }