public InstaCommentShort Convert() { if (SourceObject == null) { return(null); } var shortComment = new InstaCommentShort { CommentLikeCount = SourceObject.CommentLikeCount, ContentType = (InstaContentType)Enum.Parse(typeof(InstaContentType), SourceObject.ContentType, true), CreatedAt = InstaDateTimeHelper.UnixTimestampToDateTime(SourceObject.CreatedAt), CreatedAtUtc = InstaDateTimeHelper.UnixTimestampToDateTime(SourceObject.CreatedAtUtc), Pk = SourceObject.Pk, Status = SourceObject.Status, Text = SourceObject.Text, Type = SourceObject.Type, User = InstaConvertersFabric.Instance.GetUserShortConverter(SourceObject.User).Convert(), HasLikedComment = SourceObject.HasLikedComment, MediaId = SourceObject.MediaId, ParentCommentId = SourceObject.ParentCommentId }; return(shortComment); }
public InstaRecentActivityFeed Convert() { var activityStory = new InstaRecentActivityFeed { Pk = SourceObject.Pk, Type = SourceObject.Type, ProfileId = SourceObject.Args.ProfileId, ProfileImage = SourceObject.Args.ProfileImage, Text = SourceObject.Args.Text, RichText = SourceObject.Args.RichText, TimeStamp = InstaDateTimeHelper.UnixTimestampToDateTime( (long)System.Convert.ToDouble(SourceObject.Args.TimeStamp, new NumberFormatInfo { NumberDecimalSeparator = "." })) }; if (SourceObject.Args.Links != null) { foreach (var instaLinkResponse in SourceObject.Args.Links) { activityStory.Links.Add( new InstaLink { Start = instaLinkResponse.Start, End = instaLinkResponse.End, Id = instaLinkResponse.Id, Type = instaLinkResponse.Type }); } } if (SourceObject.Args.InlineFollow != null) { activityStory.InlineFollow = new InstaInlineFollow { IsFollowing = SourceObject.Args.InlineFollow.IsFollowing, IsOutgoingRequest = SourceObject.Args.InlineFollow.IsOutgoingRequest }; if (SourceObject.Args.InlineFollow.UserInfo != null) { activityStory.InlineFollow.User = InstaConvertersFabric.Instance.GetUserShortConverter(SourceObject.Args.InlineFollow.UserInfo) .Convert(); } } if (SourceObject.Args.Media != null) { foreach (var media in SourceObject.Args.Media) { activityStory.Medias.Add( new InstaActivityMedia { Id = media.Id, Image = media.Image }); } } return(activityStory); }
public InstaComment Convert() { var comment = new InstaComment { BitFlags = SourceObject.BitFlags, ContentType = (InstaContentType)Enum.Parse(typeof(InstaContentType), SourceObject.ContentType, true), CreatedAt = InstaDateTimeHelper.UnixTimestampToDateTime(SourceObject.CreatedAt), CreatedAtUtc = InstaDateTimeHelper.UnixTimestampToDateTime(SourceObject.CreatedAtUtc), LikesCount = SourceObject.LikesCount, Pk = SourceObject.Pk, Status = SourceObject.Status, Text = SourceObject.Text, Type = SourceObject.Type, UserId = SourceObject.UserId, User = InstaConvertersFabric.Instance.GetUserShortConverter(SourceObject.User).Convert(), DidReportAsSpam = SourceObject.DidReportAsSpam, ChildCommentCount = SourceObject.ChildCommentCount, HasLikedComment = SourceObject.HasLikedComment, HasMoreHeadChildComments = SourceObject.HasMoreHeadChildComments, HasMoreTailChildComments = SourceObject.HasMoreTailChildComments }; if (SourceObject.OtherPreviewUsers != null && SourceObject.OtherPreviewUsers.Any()) { if (comment.OtherPreviewUsers == null) { comment.OtherPreviewUsers = new List <UserShortDescription>(); } foreach (var user in SourceObject.OtherPreviewUsers) { comment.OtherPreviewUsers.Add(InstaConvertersFabric.Instance.GetUserShortConverter(user).Convert()); } } if (SourceObject.PreviewChildComments != null && SourceObject.PreviewChildComments.Any()) { if (comment.PreviewChildComments == null) { comment.PreviewChildComments = new List <InstaCommentShort>(); } foreach (var cm in SourceObject.PreviewChildComments) { comment.PreviewChildComments.Add(InstaConvertersFabric.Instance.GetCommentShortConverter(cm).Convert()); } } return(comment); }
public Caption Convert() { var caption = new Caption { Pk = SourceObject.Pk, CreatedAt = InstaDateTimeHelper.UnixTimestampToDateTime(SourceObject.CreatedAtUnixLike), CreatedAtUtc = InstaDateTimeHelper.UnixTimestampToDateTime(SourceObject.CreatedAtUtcUnixLike), MediaId = SourceObject.MediaId, Text = SourceObject.Text, User = InstaConvertersFabric.Instance.GetUserShortConverter(SourceObject.User).Convert(), UserId = SourceObject.UserId }; return(caption); }
public InstaReelFeed Convert() { if (SourceObject == null) { throw new ArgumentNullException("Source object"); } var reelFeed = new InstaReelFeed { CanReply = SourceObject.CanReply, ExpiringAt = InstaDateTimeHelper.UnixTimestampToDateTime(SourceObject?.ExpiringAt ?? 0), HasBestiesMedia = SourceObject.HasBestiesMedia, Id = SourceObject.Id, LatestReelMedia = SourceObject.LatestReelMedia ?? 0, PrefetchCount = SourceObject.PrefetchCount, Seen = SourceObject.Seen ?? 0, User = InstaConvertersFabric.Instance.GetUserShortFriendshipFullConverter(SourceObject.User).Convert() }; try { if (!string.IsNullOrEmpty(SourceObject.CanReshare)) { reelFeed.CanReshare = bool.Parse(SourceObject.CanReshare); } } catch { } if (SourceObject.Items != null && SourceObject.Items.Any()) { foreach (var item in SourceObject.Items) { try { reelFeed.Items.Add(InstaConvertersFabric.Instance.GetStoryItemConverter(item).Convert()); } catch { } } } return(reelFeed); }
public InstaMedia Convert() { if (SourceObject == null) { throw new ArgumentNullException("Source object"); } var media = new InstaMedia { Identifier = SourceObject.Media.Identifier, Code = SourceObject.Media.Code, Pk = SourceObject.Media.Pk, ClientCacheKey = SourceObject.Media.ClientCacheKey, CommentsCount = SourceObject.Media.CommentsCount, DeviceTimeStamp = InstaDateTimeHelper.UnixTimestampToDateTime(SourceObject.Media.DeviceTimeStampUnixLike), HasLiked = SourceObject.Media.HasLiked, PhotoOfYou = SourceObject.Media.PhotoOfYou, TrackingToken = SourceObject.Media.TrackingToken, TakenAt = InstaDateTimeHelper.UnixTimestampToDateTime(SourceObject.Media.TakenAtUnixLike), Height = SourceObject.Media.Height, LikesCount = SourceObject.Media.LikesCount, MediaType = SourceObject.Media.MediaType, FilterType = SourceObject.Media.FilterType, Width = SourceObject.Media.Width, HasAudio = SourceObject.Media.HasAudio, ViewCount = int.Parse(SourceObject.Media.ViewCount.ToString(CultureInfo.InvariantCulture)), IsCommentsDisabled = SourceObject.Media.IsCommentsDisabled }; if (SourceObject.Media.CarouselMedia != null) { media.Carousel = InstaConvertersFabric.Instance.GetCarouselConverter(SourceObject.Media.CarouselMedia) .Convert(); } if (SourceObject.Media.User != null) { media.User = InstaConvertersFabric.Instance.GetUserConverter(SourceObject.Media.User).Convert(); } if (SourceObject.Media.Caption != null) { media.Caption = InstaConvertersFabric.Instance.GetCaptionConverter(SourceObject.Media.Caption).Convert(); } if (SourceObject.Media.NextMaxId != null) { media.NextMaxId = SourceObject.Media.NextMaxId; } if (SourceObject.Media.Likers != null && SourceObject.Media.Likers?.Count > 0) { foreach (var liker in SourceObject.Media.Likers) { media.Likers.Add(InstaConvertersFabric.Instance.GetUserShortConverter(liker).Convert()); } } if (SourceObject.Media.UserTagList?.In != null && SourceObject.Media.UserTagList?.In?.Count > 0) { foreach (var tag in SourceObject.Media.UserTagList.In) { media.UserTags.Add(InstaConvertersFabric.Instance.GetUserTagConverter(tag).Convert()); } } if (SourceObject.Media.PreviewComments != null) { foreach (var comment in SourceObject.Media.PreviewComments) { media.PreviewComments.Add(InstaConvertersFabric.Instance.GetCommentConverter(comment).Convert()); } } if (SourceObject.Media.Location != null) { media.Location = InstaConvertersFabric.Instance.GetLocationConverter(SourceObject.Media.Location).Convert(); } if (SourceObject.Media.Images?.Candidates == null) { return(media); } foreach (var image in SourceObject.Media.Images.Candidates) { media.Images.Add(new InstaImage(image.Url, int.Parse(image.Width), int.Parse(image.Height))); } if (SourceObject.Media.Videos == null) { return(media); } foreach (var video in SourceObject.Media.Videos) { media.Videos.Add( new InstaVideo( video.Url, int.Parse(video.Width), int.Parse(video.Height), video.Type)); } return(media); }
public InstaStoryItem Convert() { if (SourceObject == null) { throw new ArgumentNullException("Source object"); } var instaStory = new InstaStoryItem { CanViewerSave = SourceObject.CanViewerSave, CaptionIsEdited = SourceObject.CaptionIsEdited, CaptionPosition = SourceObject.CaptionPosition, Code = SourceObject.Code, CommentCount = SourceObject.CommentCount, ExpiringAt = InstaDateTimeHelper.UnixTimestampToDateTime(SourceObject.ExpiringAt), FilterType = SourceObject.FilterType, HasAudio = SourceObject.HasAudio ?? false, HasLiked = SourceObject.HasLiked, HasMoreComments = SourceObject.HasMoreComments, Id = SourceObject.Id, IsReelMedia = SourceObject.IsReelMedia, LikeCount = SourceObject.LikeCount, MaxNumVisiblePreviewComments = SourceObject.MaxNumVisiblePreviewComments, MediaType = SourceObject.MediaType, OriginalHeight = SourceObject.OriginalHeight, OriginalWidth = SourceObject.OriginalWidth, PhotoOfYou = SourceObject.PhotoOfYou, Pk = SourceObject.Pk, TakenAt = InstaDateTimeHelper.UnixTimestampToDateTime(SourceObject.TakenAt), ImportedTakenAt = InstaDateTimeHelper.UnixTimestampToDateTime(SourceObject.ImportedTakenAt ?? 0), VideoDuration = SourceObject.VideoDuration ?? 0, AdAction = SourceObject.AdAction, SupportsReelReactions = SourceObject.SupportsReelReactions, ShowOneTapTooltip = SourceObject.ShowOneTapTooltip, LinkText = SourceObject.LinkText, CanReshare = SourceObject.CanReshare, CommentLikesEnabled = SourceObject.CommentLikesEnabled, CommentThreadingEnabled = SourceObject.CommentThreadingEnabled, NumberOfQualities = SourceObject.NumberOfQualities ?? 0, TimezoneOffset = SourceObject.TimezoneOffset ?? 0, VideoDashManifest = SourceObject.VideoDashManifest, StoryIsSavedToArchive = SourceObject.StoryIsSavedToArchive ?? false, ViewerCount = SourceObject.ViewerCount ?? 0, TotalViewerCount = SourceObject.TotalViewerCount ?? 0, ViewerCursor = SourceObject.ViewerCursor, HasSharedToFb = SourceObject.HasSharedToFb ?? 0 }; if (SourceObject.User != null) { instaStory.User = InstaConvertersFabric.Instance.GetUserShortConverter(SourceObject.User).Convert(); } if (SourceObject.Caption != null) { instaStory.Caption = InstaConvertersFabric.Instance.GetCaptionConverter(SourceObject.Caption).Convert(); } if (SourceObject.Images?.Candidates != null) { foreach (var image in SourceObject.Images.Candidates) { instaStory.ImageList.Add( new InstaImage( image.Url, int.Parse(image.Width), int.Parse(image.Height))); } } if (SourceObject.VideoVersions != null && SourceObject.VideoVersions.Any()) { foreach (var video in SourceObject.VideoVersions) { instaStory.VideoList.Add( new InstaVideo( video.Url, int.Parse(video.Width), int.Parse(video.Height), video.Type)); } } if (SourceObject.ReelMentions != null && SourceObject.ReelMentions.Any()) { foreach (var mention in SourceObject.ReelMentions) { instaStory.ReelMentions.Add(InstaConvertersFabric.Instance.GetMentionConverter(mention).Convert()); } } if (SourceObject.StoryHashtags != null && SourceObject.StoryHashtags.Any()) { foreach (var hashtag in SourceObject.StoryHashtags) { instaStory.StoryHashtags.Add(InstaConvertersFabric.Instance.GetMentionConverter(hashtag).Convert()); } } if (SourceObject.StoryLocations != null && SourceObject.StoryLocations.Any()) { foreach (var location in SourceObject.StoryLocations) { instaStory.StoryLocations.Add(InstaConvertersFabric.Instance.GetStoryLocationConverter(location) .Convert()); } } if (SourceObject.StoryFeedMedia != null && SourceObject.StoryFeedMedia.Any()) { foreach (var storyFeed in SourceObject.StoryFeedMedia) { instaStory.StoryFeedMedia.Add(InstaConvertersFabric.Instance.GetStoryFeedMediaConverter(storyFeed) .Convert()); } } if (SourceObject.StoryCta != null && SourceObject.StoryCta.Any()) { foreach (var cta in SourceObject.StoryCta) { if (cta.Links != null && cta.Links.Any()) { foreach (var link in cta.Links) { instaStory.StoryCta.Add(InstaConvertersFabric.Instance.GetStoryCtaConverter(link).Convert()); } } } } if (SourceObject.StoryPolls?.Count > 0) { foreach (var poll in SourceObject.StoryPolls) { instaStory.StoryPolls.Add(InstaConvertersFabric.Instance.GetStoryPollItemConverter(poll).Convert()); } } if (SourceObject.StorySliders?.Count > 0) { foreach (var slider in SourceObject.StorySliders) { instaStory.StorySliders.Add(InstaConvertersFabric.Instance.GetStorySliderItemConverter(slider) .Convert()); } } if (SourceObject.StoryQuestions?.Count > 0) { foreach (var question in SourceObject.StoryQuestions) { instaStory.StoryQuestions.Add(InstaConvertersFabric.Instance.GetStoryQuestionItemConverter(question) .Convert()); } } if (SourceObject.StoryPollVoters?.Count > 0) { foreach (var voter in SourceObject.StoryPollVoters) { instaStory.StoryPollVoters.Add(InstaConvertersFabric.Instance.GetStoryPollVoterInfoItemConverter(voter) .Convert()); } } if (SourceObject.Viewers?.Count > 0) { foreach (var viewer in SourceObject.Viewers) { instaStory.Viewers.Add(InstaConvertersFabric.Instance.GetUserShortConverter(viewer).Convert()); } } if (SourceObject.Likers?.Count > 0) { foreach (var liker in SourceObject.Likers) { instaStory.Likers.Add(InstaConvertersFabric.Instance.GetUserShortConverter(liker).Convert()); } } if (SourceObject.PreviewComments?.Count > 0) { foreach (var comment in SourceObject.PreviewComments) { instaStory.PreviewComments.Add(InstaConvertersFabric.Instance.GetCommentConverter(comment).Convert()); } } if (SourceObject.StorySliderVoters?.Count > 0) { foreach (var voter in SourceObject.StorySliderVoters) { instaStory.StorySliderVoters.Add(InstaConvertersFabric.Instance .GetStorySliderVoterInfoItemConverter(voter) .Convert()); } } if (SourceObject.StoryQuestionsResponderInfos?.Count > 0) { foreach (var responderInfo in SourceObject.StoryQuestionsResponderInfos) { instaStory.StoryQuestionsResponderInfos.Add( InstaConvertersFabric.Instance.GetStoryQuestionInfoConverter(responderInfo).Convert()); } } if (SourceObject.Countdowns?.Count > 0) { foreach (var countdown in SourceObject.Countdowns) { instaStory.Countdowns.Add(InstaConvertersFabric.Instance.GetStoryCountdownItemConverter(countdown) .Convert()); } } return(instaStory); }
public InstaMedia Convert() { if (SourceObject == null) { throw new ArgumentNullException("Source object"); } var media = new InstaMedia { Identifier = SourceObject.Identifier, Code = SourceObject.Code, Pk = SourceObject.Pk, ClientCacheKey = SourceObject.ClientCacheKey, CommentsCount = SourceObject.CommentsCount, HasLiked = SourceObject.HasLiked, PhotoOfYou = SourceObject.PhotoOfYou, TrackingToken = SourceObject.TrackingToken, TakenAtUnix = long.Parse(string.IsNullOrEmpty(SourceObject.TakenAtUnixLike) ? "0" : SourceObject.TakenAtUnixLike), Height = SourceObject.Height, LikesCount = SourceObject.LikesCount, MediaType = SourceObject.MediaType, FilterType = SourceObject.FilterType, Width = SourceObject.Width, HasAudio = SourceObject.HasAudio, ViewCount = int.Parse(SourceObject.ViewCount.ToString(CultureInfo.InvariantCulture)), IsCommentsDisabled = SourceObject.IsCommentsDisabled, // new properties> CanViewerReshare = SourceObject.CanViewerReshare, CanViewerSave = SourceObject.CanViewerSave, CanViewMorePreviewComments = SourceObject.CanViewMorePreviewComments, CommentLikesEnabled = SourceObject.CommentLikesEnabled, MaxNumVisiblePreviewComments = SourceObject.MaxNumVisiblePreviewComments, HasMoreComments = SourceObject.HasMoreComments, CommentThreadingEnabled = SourceObject.CommentThreadingEnabled, Title = SourceObject.Title, ProductType = SourceObject.ProductType, NearlyCompleteCopyrightMatch = SourceObject.NearlyCompleteCopyrightMatch ?? false, NumberOfQualities = SourceObject.NumberOfQualities ?? 0, VideoDuration = SourceObject.VideoDuration ?? 0, HasViewerSaved = SourceObject.HasViewerSaved, DirectReplyToAuthorEnabled = SourceObject.DirectReplyToAuthorEnabled ?? false }; if (!string.IsNullOrEmpty(SourceObject.TakenAtUnixLike)) { media.TakenAt = InstaDateTimeHelper.UnixTimestampToDateTime(SourceObject.TakenAtUnixLike); } if (!string.IsNullOrEmpty(SourceObject.DeviceTimeStampUnixLike)) { media.DeviceTimeStamp = InstaDateTimeHelper.UnixTimestampToDateTime(SourceObject.DeviceTimeStampUnixLike); } if (SourceObject.CarouselMedia != null) { media.Carousel = InstaConvertersFabric.Instance.GetCarouselConverter(SourceObject.CarouselMedia).Convert(); } if (SourceObject.User != null) { media.User = InstaConvertersFabric.Instance.GetUserConverter(SourceObject.User).Convert(); } if (SourceObject.Caption != null) { media.Caption = InstaConvertersFabric.Instance.GetCaptionConverter(SourceObject.Caption).Convert(); } if (SourceObject.NextMaxId != null) { media.NextMaxId = SourceObject.NextMaxId; } if (SourceObject.Likers?.Count > 0) { foreach (var liker in SourceObject.Likers) { media.Likers.Add(InstaConvertersFabric.Instance.GetUserShortConverter(liker).Convert()); } } if (SourceObject.UserTagList?.In?.Count > 0) { foreach (var tag in SourceObject.UserTagList.In) { media.UserTags.Add(InstaConvertersFabric.Instance.GetUserTagConverter(tag).Convert()); } } if (SourceObject.ProductTags?.In?.Count > 0) { foreach (var tag in SourceObject.ProductTags.In) { media.ProductTags.Add(InstaConvertersFabric.Instance.GetProductTagContainerConverter(tag).Convert()); } } if (SourceObject.PreviewComments?.Count > 0) { foreach (var comment in SourceObject.PreviewComments) { media.PreviewComments.Add(InstaConvertersFabric.Instance.GetCommentConverter(comment).Convert()); } } if (SourceObject.Location != null) { media.Location = InstaConvertersFabric.Instance.GetLocationConverter(SourceObject.Location).Convert(); } if (SourceObject.Images?.Candidates == null) { return(media); } foreach (var image in SourceObject.Images.Candidates) { media.Images.Add(new InstaImage(image.Url, int.Parse(image.Width), int.Parse(image.Height))); } if (SourceObject.Videos == null) { return(media); } foreach (var video in SourceObject.Videos) { media.Videos.Add( new InstaVideo( video.Url, int.Parse(video.Width), int.Parse(video.Height), video.Type)); } return(media); }
public InstaFullMediaInsights Convert() { var fullMediaInsights = new InstaFullMediaInsights { CommentCount = SourceObject.CommentCount ?? 0, DisplayUrl = SourceObject.DisplayUrl, Id = SourceObject.Id, LikeCount = SourceObject.LikeCount ?? 0, SaveCount = SourceObject.SaveCount ?? 0 }; if (SourceObject.CreationTime != null) { fullMediaInsights.CreationTime = InstaDateTimeHelper.UnixTimestampToDateTime(SourceObject.CreationTime.ToString()); } if (SourceObject.InstagramMediaType != null) { try { fullMediaInsights.MediaType = (InstaMediaType)Enum.Parse(typeof(InstaMediaType), SourceObject.InstagramMediaType, true); } catch { } } var inlineInsights = SourceObject.InlineInsightsNode; if (SourceObject.InlineInsightsNode != null) { var node = new InstaFullMediaInsightsMetrics { State = inlineInsights.State }; if (inlineInsights.Metrics != null) { node.ImpressionCount = inlineInsights.Metrics.ImpressionCount ?? 0; node.OwnerAccountFollowsCount = inlineInsights.Metrics.OwnerAccountFollowsCount ?? 0; node.OwnerProfileViewsCount = inlineInsights.Metrics.OwnerProfileViewsCount ?? 0; node.ReachCount = inlineInsights.Metrics.ReachCount ?? 0; if (inlineInsights.Metrics.Reach != null) { try { var reach = new InstaFullMediaInsightsNodeItem { Value = inlineInsights.Metrics.Reach.Value ?? 0 }; foreach (var item in inlineInsights.Metrics.Reach.FollowStatus.Nodes) { var convertedItem = InstaConvertersFabric.Instance.GetInsightsDataNodeConverter(item) .Convert(); reach.Items.Add(convertedItem); } node.Reach = reach; } catch { } } if (inlineInsights.Metrics.Impressions != null) { try { var impressions = new InstaFullMediaInsightsNodeItem { Value = inlineInsights.Metrics.Impressions.Value ?? 0 }; foreach (var item in inlineInsights.Metrics.Impressions.Surfaces.Nodes) { var convertedItem = InstaConvertersFabric.Instance.GetInsightsDataNodeConverter(item) .Convert(); impressions.Items.Add(convertedItem); } node.Impressions = impressions; } catch { } } if (inlineInsights.Metrics.ProfileActions != null) { try { var profileActions = new InstaFullMediaInsightsNodeItem { Value = inlineInsights.Metrics.ProfileActions.Actions.Value ?? 0 }; foreach (var item in inlineInsights.Metrics.ProfileActions.Actions.Nodes) { var convertedItem = InstaConvertersFabric.Instance.GetInsightsDataNodeConverter(item) .Convert(); profileActions.Items.Add(convertedItem); } node.ProfileActions = profileActions; } catch { } } } fullMediaInsights.InlineInsightsNode = node; } return(fullMediaInsights); }