private Post FindPost(AdferoVideoDotNet.AdferoArticles.Articles.AdferoArticle a)
 {
     return Post.Posts.Find(p => p.Title.Trim() == a.Fields["title"].Trim());
 }
        private PhotoInstance? GetPhotoInstance(AdferoVideoDotNet.AdferoArticles.Articles.AdferoArticle article, AdferoVideoDotNet.AdferoArticles.ArticlePhotos.AdferoArticlePhotosClient photos, AdferoVideoDotNet.AdferoPhotos.AdferoPhotoClient photoClient, string scaleAxis, int scale)
        {
            PhotoInstance? inst = null;

            AdferoVideoDotNet.AdferoArticles.ArticlePhotos.AdferoArticlePhotoList photoList = photos.ListForArticle(article.Id, 0, 100);
            if (photoList.TotalCount > 0)
            {
                AdferoVideoDotNet.AdferoArticles.ArticlePhotos.AdferoArticlePhoto apho = photos.Get(photoList.Items[0].Id);
                int photoId = apho.SourcePhotoId;
                AdferoVideoDotNet.AdferoPhotos.Photos.AdferoPhoto pho = photoClient.Photos().GetScaleLocationUrl(photoId, scaleAxis, scale);
                string photoUrl = pho.LocationUri;
                string photoCaption = photos.Get(photoList.Items[0].Id).Fields["caption"];

                enumeratedTypes.enumPhotoOrientation ori = enumeratedTypes.enumPhotoOrientation.Landscape;
                if (scaleAxis == AdferoVideoDotNet.AdferoPhotos.Photos.AdferoScaleAxis.Y)
                    ori = enumeratedTypes.enumPhotoOrientation.Portrait;

                string cleanedUrl = photoUrl;
                if (cleanedUrl.IndexOf('?') >= 0)
                    cleanedUrl = cleanedUrl.Substring(0, cleanedUrl.IndexOf('?'));

                inst = new PhotoInstance()
                {
                    AltText = photoCaption,
                    Caption = photoCaption,
                    DestinationFileName = Slugify(article.Fields["title"]) + "-" + scale + Path.GetExtension(cleanedUrl),
                    Height = 0,
                    Id = apho.Id,
                    Orientation = ori,
                    Type = enumeratedTypes.enumPhotoInstanceType.Custom,
                    Url = photoUrl,
                    Width = 0
                };
            }

            return inst;
        }
        private Post ConvertToPost(AdferoVideoDotNet.AdferoArticles.Articles.AdferoArticle article, AdferoVideoDotNet.AdferoArticles.Categories.AdferoCategoriesClient categories, AdferoVideoClient videoClient)
        {
            Post p = new Post();

            p.Author = "Admin";
            AdferoVideoDotNet.AdferoArticles.Categories.AdferoCategoryList categoryList = categories.ListForArticle(article.Id, 0, 100);
            for (int i = 0; i < categoryList.TotalCount; i++)
            {
                AdferoVideoDotNet.AdferoArticles.Categories.AdferoCategory category = categories.Get(categoryList.Items[i].Id);
                p.Categories.Add(new Category(GetCleanCategoryName(category.Name), ""));
            }

            string embedCode = videoClient.VideoPlayers().GetWithFallback(article.Id, AdferoVideoDotNet.AdferoArticlesVideoExtensions.VideoPlayers.AdferoPlayers.RedBean, new AdferoVideoDotNet.AdferoArticlesVideoExtensions.VideoPlayers.AdferoVersion(1,0,0),AdferoVideoDotNet.AdferoArticlesVideoExtensions.VideoPlayers.AdferoPlayers.RcFlashPlayer, new AdferoVideoDotNet.AdferoArticlesVideoExtensions.VideoPlayers.AdferoVersion(1,0,0)).EmbedCode;
            p.Content = string.Format("<div class=\"videoContainer\">{0}</div> {1}", embedCode, article.Fields["content"]);

            p.DateCreated = DateTime.Parse(article.Fields["date"]);
            p.DateModified = DateTime.Parse(article.Fields["lastModifiedDate"]);
            p.Description = article.Fields["extract"];

            p.Slug = Slugify(article.Fields["title"]);
            p.Title = article.Fields["title"].Trim();

            return p;
        }