private void LoadImageDone(TumblrPost post) { Utils.DebugLog("LoadImageDone"); loadingIndicator.Visible = false; imageView.Image = post.LargeImage; isImageLoaded = true; }
public LicenseForm() { InitializeComponent(); this.Menu = new MainMenu(); MenuItem miClose = new MenuItem { Text = Messages.Close }; miClose.Click +=new EventHandler(miClose_Click); this.Menu.MenuItems.Add(miClose); this.post = new TumblrPost(); this.post.Html = "<html>" + global::Tumblott.Properties.Resources.license.Replace("<", "<").Replace(">", ">").Replace("\n", "<br/>") + "</html>"; }
public void SetPost(TumblrPost post) { this.post = post; imageView.Image = null; if (post.Image != null) { imageView.Image = post.Image; } imageView.ResetPosition(); loadingIndicator.Visible = true; isImageLoaded = false; LoadImage(); }
protected override async Task DownloadPhotoAsync(IProgress <DataModels.DownloadProgress> progress, TumblrPost downloadItem, CancellationToken ct) { string url = Url(downloadItem); if (blog.ForceSize) { url = ResizeTumblrImageUrl(url); } foreach (string host in shellService.Settings.TumblrHosts) { url = BuildRawImageUrl(url, host); if (await DownloadDetectedImageUrl(progress, url, PostDate(downloadItem), ct)) { return; } } await DownloadDetectedImageUrl(progress, Url(downloadItem), PostDate(downloadItem), ct); }
private static string PostId(TumblrPost downloadItem) { return(downloadItem.Id); }
private static string FileName(TumblrPost downloadItem) { return(downloadItem.Url.Split('/').Last()); }
protected void AddToDownloadList(TumblrPost addToList) { postQueue.Add(addToList); statisticsBag.Add(addToList); }
protected virtual async Task <bool> DownloadBinaryPost(TumblrPost downloadItem) { string url = Url(downloadItem); if (!CheckIfFileExistsInDB(url)) { string blogDownloadLocation = blog.DownloadLocation(); string fileLocationUrlList = FileLocationLocalized(blogDownloadLocation, downloadItem.TextFileLocation); DateTime postDate = PostDate(downloadItem); string fileName = FileName(downloadItem); string fileLocation = FileLocation(blogDownloadLocation, fileName); if (url.Contains("https://mega.nz/#")) { Uri link = new Uri(url); Crawler.MegaLinkType linkType = Crawler.MegaLinkType.Single; //Determines if the MEGA link is a folder or single file based on if the url is mega.nz/#! or mega.nz/#F Regex regType = new Regex("(http[A-Za-z0-9_/:.]*mega.nz/#(.*)([A-Za-z0-9_]*))"); foreach (Match rmatch in regType.Matches(url)) { string subStr = rmatch.Groups[2].Value[0].ToString(); if (subStr == "!") { linkType = Crawler.MegaLinkType.Single; } if (subStr == "F") { linkType = Crawler.MegaLinkType.Folder; } } MegaApiClient client = new MegaApiClient(); client.LoginAnonymous(); switch (linkType) { case Crawler.MegaLinkType.Single: INodeInfo nodeInfo = client.GetNodeFromLink(link); fileName = nodeInfo.Name; fileLocation = FileLocation(blogDownloadLocation, fileName); UpdateProgressQueueInformation(Resources.ProgressDownloadImage, fileName); if (await DownloadBinaryFile(fileLocation, fileLocationUrlList, url)) { updateBlog(fileLocation, postDate, downloadItem, fileName); return(true); } client.Logout(); return(false); case Crawler.MegaLinkType.Folder: //If the link is a folder, download all files from it. IEnumerable <INode> nodes = client.GetNodesFromLink(link); List <INode> allFiles = nodes.Where(n => n.Type == NodeType.File).ToList(); foreach (INode node in allFiles) { fileName = node.Name; fileLocation = FileLocation(blogDownloadLocation, fileName); UpdateProgressQueueInformation(Resources.ProgressDownloadImage, fileName); if (await DownloadBinaryFile(fileLocation, fileLocationUrlList, url, node)) { updateBlog(fileLocation, postDate, downloadItem, fileName); } } client.Logout(); return(false); default: throw new ArgumentOutOfRangeException(); } } if (url.Contains("https://drive.google.com/")) { UserCredential credentials = Authenticate(); DriveService service = OpenService(credentials); RequestInfo(service, url, blogDownloadLocation + "\\"); } UpdateProgressQueueInformation(Resources.ProgressDownloadImage, fileName); if (await DownloadBinaryFile(fileLocation, fileLocationUrlList, url)) { updateBlog(fileLocation, postDate, downloadItem, fileName); return(true); } return(false); } else { string fileName = FileName(downloadItem); UpdateProgressQueueInformation(Resources.ProgressSkipFile, fileName); } return(true); }
private static string FileNameNew(TumblrPost downloadItem) { return(downloadItem.Filename); }
protected virtual string FileNameUrl(TumblrPost downloadItem) { return(downloadItem.Url.Split('/').Last()); }
protected override async Task DownloadPhotoAsync(IProgress <DataModels.DownloadProgress> progress, TumblrPost downloadItem, CancellationToken ct) { string url = Url(downloadItem); url = TestImageRawUrl(url, shellService.Settings); if (!(CheckIfFileExistsInDB(url) || CheckIfBlogShouldCheckDirectory(GetCoreImageUrl(url)))) { string blogDownloadLocation = blog.DownloadLocation(); string fileName = url.Split('/').Last(); string fileLocation = FileLocation(blogDownloadLocation, fileName); string fileLocationUrlList = FileLocationLocalized(blogDownloadLocation, Resources.FileNamePhotos); DateTime postDate = PostDate(downloadItem); UpdateProgressQueueInformation(progress, Resources.ProgressDownloadImage, fileName); if (await DownloadBinaryFile(fileLocation, fileLocationUrlList, url, ct)) { SetFileDate(fileLocation, postDate); UpdateBlogPostCount(ref counter.Photos, value => blog.DownloadedPhotos = value); UpdateBlogProgress(ref counter.TotalDownloads); UpdateBlogDB(fileName); if (shellService.Settings.EnablePreview) { if (!fileName.EndsWith(".gif")) { blog.LastDownloadedPhoto = Path.GetFullPath(fileLocation); } else { blog.LastDownloadedVideo = Path.GetFullPath(fileLocation); } } } //TODO: Refactoring code! Same as above, just with different url. Note: What Url to store in the files DB? url = TestImageRawUrl(url, shellService.Settings); if (await DownloadBinaryFile(fileLocation, fileLocationUrlList, url, ct)) { SetFileDate(fileLocation, postDate); UpdateBlogPostCount(ref counter.Photos, value => blog.DownloadedPhotos = value); UpdateBlogProgress(ref counter.TotalDownloads); UpdateBlogDB(fileName); if (shellService.Settings.EnablePreview) { if (!fileName.EndsWith(".gif")) { blog.LastDownloadedPhoto = Path.GetFullPath(fileLocation); } else { blog.LastDownloadedVideo = Path.GetFullPath(fileLocation); } } } } }
private static string Url(TumblrPost downloadItem) { return(downloadItem.Url); }
private async Task DownloadPostAsync(IProgress <DownloadProgress> progress, CancellationToken ct, TumblrPost downloadItem) { switch (downloadItem.PostType) { case PostTypes.Photo: await DownloadPhotoAsync(progress, downloadItem, ct); break; case PostTypes.Video: await DownloadVideoAsync(progress, downloadItem, ct); break; case PostTypes.Audio: await DownloadAudioAsync(progress, downloadItem, ct); break; case PostTypes.Text: DownloadText(progress, downloadItem); break; case PostTypes.Quote: DownloadQuote(progress, downloadItem); break; case PostTypes.Link: DownloadLink(progress, downloadItem); break; case PostTypes.Conversation: DownloadConversation(progress, downloadItem); break; case PostTypes.Answer: DownloadAnswer(progress, downloadItem); break; case PostTypes.PhotoMeta: DownloadPhotoMeta(progress, downloadItem); break; case PostTypes.VideoMeta: DownloadVideoMeta(progress, downloadItem); break; case PostTypes.AudioMeta: DownloadAudioMeta(progress, downloadItem); break; default: break; } }
private void AddToDownloadList(TumblrPost addToList) { producerConsumerCollection.Add(addToList); statisticsBag.Add(addToList); }
private void AddTextToDb(TumblrPost downloadItem) { files.AddFileToDb(PostId(downloadItem), downloadItem.Filename); }
protected static string Url(TumblrPost downloadItem) { return(downloadItem.Url); }
protected override string FileNameUrl(TumblrPost downloadItem) { return(FileName(downloadItem)); }