コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
            }
        }