public string GetImgurIdNum() { if (GetContentType() != ContentType.ImgurGallery) { return(""); } else if (UrlContent.Contains("https")) { return(UrlContent.Replace("https://imgur.com/a/", "")); } return(UrlContent.Replace("http://imgur.com/a/", "")); }
public ContentType GetContentType() { ContentType type = ContentType.Blank; if (UrlContent.Contains("v.redd.it")) { if (UrlContent.Contains(" ")) { type = ContentType.Vreddit; } else { type = ContentType.VredditPostOnly; } } else if (UrlContent.Contains("https://rule34video.com/videos/")) { type = ContentType.R34Video; } else if (UrlContent.Contains("imgur.com/a/")) { if (UrlContent.Contains(" ")) // Was split { int numOfUrls = UrlContent.Count(letter => letter == ' ') + 1; if (numOfUrls > 2) { type = ContentType.Gallery; } else // Only one image in gallery { if (UrlContent.Contains(".gif")) { type = ContentType.Gif; } else { type = ContentType.Image; } } } else // Hasn't been split { type = ContentType.ImgurGallery; } } else if (UrlContent.Contains(" ") && UrlContent.Contains("i.imgur.com") && !UrlContent.Contains(".gifv") && !UrlContent.Contains(".mp4")) { type = ContentType.Image; if (UrlContent.Contains(".gif")) { type = ContentType.Gif; } } else if (UrlContent.Contains(" ")) { type = ContentType.Gallery; } else if (UrlContent.Contains("//imgur.com/") && !UrlContent.Contains(".gifv") && !UrlContent.Contains(".mp4")) { type = ContentType.ImgurImage; } else if (UrlContent.Contains(".jpg") || UrlContent.Contains(".png") || UrlContent.Contains(".jpeg")) { type = ContentType.Image; } else if (UrlContent.Contains(".mp4")) { type = ContentType.Mp4; } else if (UrlContent.Contains("redgifs") && UrlContent.Contains("watch")) { type = ContentType.RedGifWatch; } else if (UrlContent.Contains("twitter.com/")) { type = ContentType.Twitter; } else if (UrlContent.Contains("youtu.be") || UrlContent.Contains("youtube.com")) { type = ContentType.Youtube; } else if (UrlContent.Contains(".gifv")) { type = ContentType.Gifv; } else if (UrlContent.Contains(".gif")) { type = ContentType.Gif; } else if (UrlContent.Contains("gfycat.com")) { type = ContentType.GfyCat; } else if (!UrlThumbnail.Contains("self") && !UrlThumbnail.Contains("default")) { type = ContentType.UrlPreview; } return(type); }
public string[] GetContentUrls() { string[] toReturn = new string[] { UrlContent }; if (UrlContent.Contains("reddit.com/gallery/")) { toReturn = UrlContent.Split(" "); } else if (UrlContent.Contains("https://rule34video.com/videos/")) { string vidId = toReturn[0].Replace("https://rule34video.com/videos/", ""); vidId = vidId.Substring(0, vidId.IndexOf("/")); toReturn[0] = "https://rule34video.com/embed/" + vidId; } else if (UrlContent.Contains(".gifv")) { toReturn[0] = toReturn[0].Replace(".gifv", ".mp4"); toReturn[0] = toReturn[0].Replace("//imgur.com/", "//i.imgur.com/"); } else if (UrlContent.Contains("https://gfycat.com/")) { toReturn[0] = toReturn[0].Replace("https://gfycat.com/", "https://gfycat.com/ifr/"); } else if (UrlContent.Contains(" ") && UrlContent.Contains("i.imgur.com") && (GetContentType() == ContentType.Gif || GetContentType() == ContentType.Image)) { toReturn[0] = UrlContent.Split(" ")[1]; } else if (UrlContent.Contains("//imgur.com/") && !UrlContent.Contains("/a/")) // An Imgur pic that wasn't posted with the direct link { toReturn[0] = toReturn[0].Replace("//imgur.com/", "//i.imgur.com/") + ".png"; } else if (UrlContent.Contains("v.redd.it") && UrlContent.Contains(" ")) { toReturn = UrlContent.Split(" "); } else if (UrlContent.Contains("youtu.be")) { toReturn[0] = toReturn[0].Replace("https://youtu.be/", "https://www.youtube.com/embed/"); } else if (UrlContent.Contains("youtube.com")) { toReturn[0] = toReturn[0].Replace("https://www.youtube.com/watch?v=", "https://www.youtube.com/embed/"); } else if (UrlContent.Contains("imgur.com/a/") && GetContentType() == ContentType.Gallery) { toReturn = UrlContent.Split(" "); } else if (UrlContent.Contains("imgur.com/a/") && (GetContentType() == ContentType.Image || GetContentType() == ContentType.Gif)) { toReturn[0] = UrlContent.Split(" ")[1]; } else if (UrlContent.Contains("https://rule34.xxx//samples/") && UrlContent.Contains("?")) { toReturn[0] = toReturn[0].Replace("https://rule34.xxx//samples/", "https://us.rule34.xxx//images/"); toReturn[0] = toReturn[0].Replace("sample_", ""); toReturn[0] = toReturn[0].Substring(0, toReturn[0].LastIndexOf("?")); toReturn[0] = toReturn[0].Replace("jpg", "jpeg"); } return(toReturn); }