/// <summary>
        ///
        /// </summary>
        /// <param name="offset"></param>
        /// <returns></returns>
        private HashSet <TumblrPost> GetTumblrPhotoPostList(int offset = 0)
        {
            try
            {
                DocumentManager.GetRemoteDocument(TumblrApiHelper.GeneratePostTypeQueryUrl(TumblrDomain, TumblrPostType.Photo, offset));

                if ((ApiVersion == TumblrApiVersion.V2Json && DocumentManager.RemoteDocument != null))
                {
                    DocumentManager.ImageSize = ImageSize;
                    HashSet <TumblrPost> posts = DocumentManager.GetPostListFromDoc(TumblrPostType.Photo);
                    return(posts);
                }
                ProcessingStatusCode = ProcessingCode.UnableDownload;
                return(new HashSet <TumblrPost>());
            }
            catch
            {
                return(new HashSet <TumblrPost>());
            }
        }
        /// <summary>
        ///
        ///
        ///
        ///
        /// </summary>
        /// <param name="offset"></param>
        /// <returns></returns>
        private HashSet <TumblrPost> GetTumblrPostList(int offset = 0)
        {
            try
            {
                TumblrPostType postType = PhotoPostOnly == true ? TumblrPostType.Photo : TumblrPostType.All;
                var            query    = TumblrApiHelper.GeneratePostTypeQueryUrl(TumblrDomain, postType, offset);

                DocumentManager.GetRemoteDocument(query);

                if ((ApiVersion == TumblrApiVersion.V2Json && DocumentManager.JsonDocument != null))
                {
                    HashSet <TumblrPost> posts = DocumentManager.GetPostListFromDoc(TumblrPostType.All);
                    return(posts);
                }
                ProcessingStatusCode = ProcessingCode.UnableDownload;
                return(new HashSet <TumblrPost>());
            }
            catch
            {
                return(new HashSet <TumblrPost>());
            }
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool GetTumblrStats()
        {
            var url = TumblrApiHelper.GeneratePostTypeQueryUrl(TumblrDomain, TumblrPostType.All, 0, 1);

            if (url.TumblrExists())

            {
                DocumentManager.GetRemoteDocument(url);
                TotalPostsOverall = DocumentManager.GetTotalPostCount();

                var postTypes = Enum.GetValues(typeof(TumblrPostType)).Cast <TumblrPostType>().ToHashSet();
                postTypes.RemoveWhere(type => type == TumblrPostType.All || type == TumblrPostType.Regular || type == TumblrPostType.Conversation);

                foreach (TumblrPostType type in postTypes)
                {
                    int TotalPostsForType = 0;
                    url = TumblrApiHelper.GeneratePostTypeQueryUrl(TumblrDomain, type, 0, 1);

                    if (url.TumblrExists())
                    {
                        DocumentManager.GetRemoteDocument(url);
                        TotalPostsForType = DocumentManager.GetTotalPostCount();

                        switch (type)
                        {
                        case TumblrPostType.Photo:
                            TotalPhotoPosts = TotalPostsForType;
                            break;

                        case TumblrPostType.Text:
                            TotalTextPosts = TotalPostsForType;
                            break;

                        case TumblrPostType.Video:
                            TotalVideoPosts = TotalPostsForType;
                            break;

                        case TumblrPostType.Audio:
                            TotalAudioPosts = TotalPostsForType;
                            break;

                        case TumblrPostType.Link:
                            TotalLinkPosts = TotalPostsForType;
                            break;

                        case TumblrPostType.Quote:
                            TotalQuotePosts = TotalPostsForType;
                            break;

                        case TumblrPostType.Chat:
                            TotalChatPosts = TotalPostsForType;
                            break;

                        case TumblrPostType.Answer:
                            TotalAnswerPosts = TotalPostsForType;
                            break;
                        }

                        PostTypesProcessedCount++;

                        ProcessingStatusCode = ProcessingCode.Ok;
                    }
                    else
                    {
                        ProcessingStatusCode = ProcessingCode.InvalidUrl;
                    }
                }
            }

            return(true);
        }