Ejemplo n.º 1
0
        public static Blog Create(string url, string location)
        {
            var blog = new TumblrHiddenBlog()
            {
                Url       = ExtractUrl(url),
                Name      = ExtractName(url),
                BlogType  = BlogTypes.tmblrpriv,
                Location  = location,
                Online    = true,
                Version   = "3",
                DateAdded = DateTime.Now,
            };

            Directory.CreateDirectory(location);
            Directory.CreateDirectory(Path.Combine(Directory.GetParent(location).FullName, blog.Name));

            blog.ChildId = Path.Combine(location, blog.Name + "_files." + blog.BlogType);
            if (!File.Exists(blog.ChildId))
            {
                IFiles files = new TumblrHiddenBlogFiles(blog.Name, blog.Location);
                files.Save();
                files = null;
            }
            return(blog);
        }
Ejemplo n.º 2
0
        public IBlog GetBlog(string blogUrl, string path)
        {
            blogUrl = _urlValidator.AddHttpsProtocol(blogUrl);
            if (_urlValidator.IsValidTumblrUrl(blogUrl))
            {
                return(TumblrBlog.Create(blogUrl, path));
            }

            if (_urlValidator.IsValidTumblrHiddenUrl(blogUrl))
            {
                return(TumblrHiddenBlog.Create(blogUrl, path));
            }

            if (_urlValidator.IsValidTumblrLikedByUrl(blogUrl))
            {
                return(TumblrLikedByBlog.Create(blogUrl, path));
            }

            if (_urlValidator.IsValidTumblrSearchUrl(blogUrl))
            {
                return(TumblrSearchBlog.Create(blogUrl, path));
            }

            if (_urlValidator.IsValidTumblrTagSearchUrl(blogUrl))
            {
                return(TumblrTagSearchBlog.Create(blogUrl, path));
            }

            throw new ArgumentException("Website is not supported!", nameof(blogUrl));
        }
Ejemplo n.º 3
0
        public IBlog GetBlog(string blogUrl, string path, string filenameTemplate)
        {
            blogUrl = _urlValidator.AddHttpsProtocol(blogUrl);

            if (_urlValidator.IsValidTumblrLikesUrl(blogUrl))
            {
                return(TumblrLikedByBlog.Create(blogUrl, path, filenameTemplate));
            }

            if (_urlValidator.IsValidTumblrUrl(blogUrl))
            {
                return(TumblrBlog.Create(blogUrl, path, filenameTemplate));
            }

            if (_urlValidator.IsTumbexUrl(blogUrl))
            {
                return(TumblrBlog.Create(CreateTumblrUrlFromTumbex(blogUrl), path, filenameTemplate));
            }

            if (_urlValidator.IsValidTumblrHiddenUrl(blogUrl))
            {
                return(TumblrHiddenBlog.Create(blogUrl, path, filenameTemplate));
            }

            if (_urlValidator.IsValidTumblrLikedByUrl(blogUrl))
            {
                return(TumblrLikedByBlog.Create(blogUrl, path, filenameTemplate));
            }

            if (_urlValidator.IsValidTumblrSearchUrl(blogUrl))
            {
                return(TumblrSearchBlog.Create(blogUrl, path, filenameTemplate));
            }

            if (_urlValidator.IsValidTumblrTagSearchUrl(blogUrl))
            {
                return(TumblrTagSearchBlog.Create(blogUrl, path, filenameTemplate));
            }

            if (_urlValidator.IsValidTwitterUrl(blogUrl))
            {
                return(TwitterBlog.Create(blogUrl, path, filenameTemplate));
            }

            throw new ArgumentException("Website is not supported!", nameof(blogUrl));
        }