Exemplo n.º 1
0
 public IBlog GetBlog(string blogUrl, string path)
 {
     if (Validator.IsValidTumblrUrl(blogUrl))
     {
         return(Blog.Create(blogUrl, path, BlogTypes.tumblr));
     }
     if (Validator.IsValidTumblrLikedByUrl(blogUrl))
     {
         return(TumblrLikeByBlog.Create(blogUrl, path, BlogTypes.tlb));
     }
     if (Validator.IsValidTumblrSearchUrl(blogUrl))
     {
         return(TumblrSearchBlog.Create(blogUrl, path, BlogTypes.tumblrsearch));
     }
     if (Validator.IsValidTumblrTagSearchUrl(blogUrl))
     {
         return(TumblrTagSearchBlog.Create(blogUrl, path, BlogTypes.tumblrtagsearch));
     }
     throw new ArgumentException("Website is not supported!", nameof(blogUrl));
 }
Exemplo n.º 2
0
        public static new Blog Create(string url, string location, BlogTypes blogType)
        {
            var blog = new TumblrLikeByBlog()
            {
                Url       = ExtractUrl(url),
                Name      = ExtractName(url),
                BlogType  = blogType,
                Location  = location,
                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." + blogType);
            if (!File.Exists(blog.ChildId))
            {
                IFiles files = new Files(blog.Name, blog.Location, blog.BlogType);
                files.Save();
                files = null;
            }
            return(blog);
        }