Esempio n. 1
0
        public async Task WriteContent(InstaMedia media)
        {
            string fileName;
            var    width      = 0;
            var    height     = 0;
            var    displayUrl = "";

            switch (media.MediaType)
            {
            case InstaMediaType.Image:
                fileName   = media.Pk + InputValidation.GetUriExtension(media.Images[0].URI);
                width      = media.Images[0].Width;
                height     = media.Images[0].Height;
                displayUrl = media.Images[0].URI;
                break;

            case InstaMediaType.Video:
                fileName   = media.Pk + InputValidation.GetUriExtension(media.Videos[0].Url);
                width      = media.Videos[0].Width;
                height     = media.Videos[0].Height;
                displayUrl = media.Videos[0].Url;
                break;

            case InstaMediaType.Carousel:
                fileName = "Carousel";
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            var csvData = new CsvData
            {
                FileName   = $"{fileName}",
                ShortCode  = media.Code,
                DisplaySrc = displayUrl,
                MediaId    = media.Pk,
                Dimensions = $"W: {width} H: {height}",
                Caption    = media.Caption?.Text,
                Likes      = media.LikesCount.ToString(),
                Comments   = media.CommentsCount,
                IsVideo    = media.HasAudio,
                VideoViews = media.ViewCount.ToString(),
                Date       = media.TakenAt.ToLocalTime()
            };

            _csvWriter.WriteRecord(csvData);
            await _csvWriter.NextRecordAsync();
        }
Esempio n. 2
0
        public async Task WriteContent(InstaCarouselItem media)
        {
            var fileName   = "";
            var width      = 0;
            var height     = 0;
            var displayUrl = "";
            var isVideo    = false;

            switch (media.MediaType)
            {
            case InstaMediaType.Image:
                fileName   = media.Pk + InputValidation.GetUriExtension(media.Images[0].URI);
                width      = media.Images[0].Width;
                height     = media.Images[0].Height;
                displayUrl = media.Images[0].URI;
                break;

            case InstaMediaType.Video:
                fileName   = media.Pk + InputValidation.GetUriExtension(media.Videos[0].Url);
                width      = media.Videos[0].Width;
                height     = media.Videos[0].Height;
                displayUrl = media.Videos[0].Url;
                isVideo    = true;
                break;
            }

            var csvData = new CsvData
            {
                FileName   = $"{fileName}",
                ShortCode  = "",
                DisplaySrc = displayUrl,
                MediaId    = media.Pk,
                Dimensions = $"W: {width} H: {height}",
                Caption    = "",
                Likes      = "0",
                Comments   = "0",
                IsVideo    = isVideo,
                VideoViews = "0",
                Date       = null
            };

            _csvWriter.WriteRecord(csvData);
            await _csvWriter.NextRecordAsync();
        }