private void AddVideoUrlToDownloadList(Post post) { if (!Blog.DownloadVideo) { return; } Post postCopy = post; if (post.type == "video") { AddVideoUrl(post); postCopy = (Post)post.Clone(); postCopy.video_url = string.Empty; } //var videoUrls = new HashSet<string>(); AddTumblrVideoUrl(InlineSearch(postCopy)); AddInlineTumblrVideoUrl(InlineSearch(postCopy), TumblrParser.GetTumblrVVideoUrlRegex()); if (Blog.RegExVideos) { AddGenericInlineVideoUrl(postCopy); } //AddInlineVideoUrlsToDownloader(videoUrls, postCopy); }
protected string[] AddInlineTumblrVideoUrl(string text, Post post) { var list = new List <string>(); if (Blog.DownloadVideo) { foreach (string videoUrl in TumblrParser.SearchForTumblrInlineVideoUrl(text)) { string url = videoUrl; if (ShellService.Settings.VideoSize == 480) { url += "_480"; } url += ".mp4"; var filename = BuildFileName(url, post, -1); AddDownloadedMedia(url, filename, post); AddToDownloadList(new VideoPost(url, post.Id, post.UnixTimestamp.ToString(), filename)); list.Add(url); } } if (Blog.DownloadVideoThumbnail) { foreach (string thumbnailUrl in TumblrParser.SearchForTumblrVideoThumbnailUrl(text)) { var filename = BuildFileName(thumbnailUrl, post, "photo", -1); AddDownloadedMedia(thumbnailUrl, filename, post); AddToDownloadList(new PhotoPost(thumbnailUrl, post.Id, post.UnixTimestamp.ToString(), filename)); } } return(list.ToArray()); }
protected string[] AddTumblrVideoUrl(string text, Post post) { if (!Blog.DownloadVideo) { return(Array.Empty <string>()); } var list = new List <string>(); foreach (string videoUrl in TumblrParser.SearchForTumblrVideoUrl(text)) { string url = videoUrl; if (ShellService.Settings.VideoSize == 480) { url += "_480"; } url = "https://vtt.tumblr.com/" + url + ".mp4"; var filename = BuildFileName(url, post, -1); AddDownloadedMedia(url, filename, post); AddToDownloadList(new VideoPost(url, post.Id, post.UnixTimestamp.ToString(), filename)); list.Add(url); } return(list.ToArray()); }
protected void AddGenericVideoUrl(string post) { foreach (string videoUrl in TumblrParser.SearchForGenericVideoUrl(post)) { if (TumblrParser.IsTumblrUrl(videoUrl)) { continue; } AddToDownloadList(new VideoPost(videoUrl, Guid.NewGuid().ToString("N"))); } }
protected void AddGenericVideoUrl(string text, Post post) { foreach (string videoUrl in TumblrParser.SearchForGenericVideoUrl(text)) { if (TumblrParser.IsTumblrUrl(videoUrl)) { continue; } AddToDownloadList(new VideoPost(videoUrl, post.Id, post.UnixTimestamp.ToString(), FileName(videoUrl))); } }
protected void AddTumblrVideoUrl(string post) { foreach (string videoUrl in TumblrParser.SearchForTumblrVideoUrl(post)) { string url = videoUrl; if (ShellService.Settings.VideoSize == 480) { url += "_480"; } AddToDownloadList(new VideoPost("https://vtt.tumblr.com/" + url + ".mp4", Guid.NewGuid().ToString("N"))); } }
protected void AddTumblrVideoUrl(string post, int?postTimestamp) { foreach (string videoUrl in TumblrParser.SearchForTumblrVideoUrl(post)) { string url = videoUrl; if (ShellService.Settings.VideoSize == 480) { url += "_480"; } AddToDownloadList(new VideoPost("https://vtt.tumblr.com/" + url + ".mp4", Guid.NewGuid().ToString("N"), postTimestamp?.ToString(), BuildFileName("https://vtt.tumblr.com/" + url + ".mp4", (Post)null, -1))); } }
protected void AddTumblrVideoUrl(string text, Post post) { foreach (string videoUrl in TumblrParser.SearchForTumblrVideoUrl(text)) { string url = videoUrl; if (ShellService.Settings.VideoSize == 480) { url += "_480"; } AddToDownloadList(new VideoPost("https://vtt.tumblr.com/" + url + ".mp4", post.Id, post.UnixTimestamp.ToString(), BuildFileName("https://vtt.tumblr.com/" + url + ".mp4", post, -1))); } }
protected void AddTumblrPhotoUrl(string text, Post post) { TumblrPhotoLookup photosToDownload = new TumblrPhotoLookup(); foreach (string imageUrl in TumblrParser.SearchForTumblrPhotoUrl(text)) { if (CheckIfShouldStop()) { return; } CheckIfShouldPause(); string url = imageUrl; if (CheckIfSkipGif(url)) { continue; } if (!Blog.DownloadVideoThumbnail && (url.Contains("_frame1.") || url.Contains("_smart1."))) { continue; } var matchesNewFormat = Regex.Match(url, "media.tumblr.com/([A-Za-z0-9_/:.-]*)/s([0-9]*)x([0-9]*)"); if (matchesNewFormat.Success) { url = RetrieveOriginalImageUrl(url, 2000, 3000, true); url = CheckPnjUrl(url); matchesNewFormat = Regex.Match(url, "media.tumblr.com/([A-Za-z0-9_/:.-]*)/s([0-9]*)x([0-9]*)"); string id = matchesNewFormat.Groups[1].Value; int width = int.Parse(matchesNewFormat.Groups[2].Value); int height = int.Parse(matchesNewFormat.Groups[3].Value); int resolution = width * height; photosToDownload.AddOrReplace(id, url, resolution); } else { url = ResizeTumblrImageUrl(url); url = RetrieveOriginalImageUrl(url, 2000, 3000, true); url = CheckPnjUrl(url); AddPhotoToDownloadList(url, post); } } foreach (string url in photosToDownload.GetUrls()) { AddPhotoToDownloadList(url, post); } }
private void AddVideoUrlToDownloadList(string document) { if (!Blog.DownloadVideo) { return; } AddTumblrVideoUrl(document); AddInlineTumblrVideoUrl(document, TumblrParser.GetTumblrVVideoUrlRegex()); if (Blog.RegExVideos) { AddGenericVideoUrl(document); } }
protected void AddTumblrPhotoUrl(string post) { foreach (string imageUrl in TumblrParser.SearchForTumblrPhotoUrl(post)) { string url = imageUrl; if (CheckIfSkipGif(url)) { continue; } url = ResizeTumblrImageUrl(url); // TODO: postID AddToDownloadList(new PhotoPost(url, Guid.NewGuid().ToString("N"))); } }
protected void AddGenericPhotoUrl(string post, int?postTimestamp) { foreach (string imageUrl in TumblrParser.SearchForGenericPhotoUrl(post)) { if (TumblrParser.IsTumblrUrl(imageUrl)) { continue; } if (CheckIfSkipGif(imageUrl)) { continue; } AddToDownloadList(new PhotoPost(imageUrl, Guid.NewGuid().ToString("N"), postTimestamp?.ToString(), FileName(imageUrl))); } }
protected void AddTumblrPhotoUrl(string post, int?postTimestamp) { foreach (string imageUrl in TumblrParser.SearchForTumblrPhotoUrl(post)) { string url = imageUrl; if (CheckIfSkipGif(url)) { continue; } url = ResizeTumblrImageUrl(url); url = RetrieveOriginalImageUrl(url, 2000, 3000); // TODO: postID AddToDownloadList(new PhotoPost(url, Guid.NewGuid().ToString("N"), postTimestamp?.ToString(), BuildFileName(url, (Post)null, -1))); } }
protected void AddGenericPhotoUrl(string text, Post post) { foreach (string imageUrl in TumblrParser.SearchForGenericPhotoUrl(text)) { if (TumblrParser.IsTumblrUrl(imageUrl)) { continue; } if (CheckIfSkipGif(imageUrl)) { continue; } AddToDownloadList(new PhotoPost(imageUrl, post.Id, post.UnixTimestamp.ToString(), FileName(imageUrl))); } }
private void AddVideoUrlToDownloadList(string document) { if (!Blog.DownloadVideo && !Blog.DownloadVideoThumbnail) { return; } var post = new Post() { Id = "", Tumblelog = new TumbleLog2() { Name = "" }, UnixTimestamp = (int)((DateTimeOffset)DateTime.Now).ToUnixTimeSeconds() }; AddTumblrVideoUrl(document, post); AddInlineTumblrVideoUrl(document, TumblrParser.GetTumblrVVideoUrlRegex(), TumblrParser.GetTumblrThumbnailUrlRegex()); if (Blog.DownloadVideo && Blog.RegExVideos) { AddGenericVideoUrl(document, post); } }
protected void AddTumblrPhotoUrl(string text, Post post) { TumblrPhotoLookup photosToDownload = new TumblrPhotoLookup(); foreach (string imageUrl in TumblrParser.SearchForTumblrPhotoUrl(text)) { string url = imageUrl; if (CheckIfSkipGif(url)) { continue; } url = RetrieveOriginalImageUrl(url, 2000, 3000); var matchesNewFormat = Regex.Match(url, "media.tumblr.com/([A-Za-z0-9_/:.-]*)/s([0-9]*)x([0-9]*)"); if (matchesNewFormat.Success) { string id = matchesNewFormat.Groups[1].Value; int width = int.Parse(matchesNewFormat.Groups[2].Value); int height = int.Parse(matchesNewFormat.Groups[3].Value); int resolution = width * height; photosToDownload.AddOrReplace(id, url, resolution); } else { url = ResizeTumblrImageUrl(url); AddPhotoToDownloadList(url, post); } } foreach (string url in photosToDownload.GetUrls()) { AddPhotoToDownloadList(url, post); } }