<commit_before>﻿using Orion.Service.Mastodon.Enum;
using Orion.Shared.Absorb.Enums;

using CroudiaAttachment = Orion.Service.Croudia.Models.Media;
using MastodonAttachment = Orion.Service.Mastodon.Models.Attachment;
using TwitterAttachment = CoreTweet.MediaEntity;

namespace Orion.Shared.Absorb.Objects
{
    public class Attachment
    {
        private readonly CroudiaAttachment _croudiaAttachment;
        private readonly MastodonAttachment _mastodonAttachment;
        private readonly TwitterAttachment _twitterAttachment;

        /// <summary>
        ///     URL
        /// </summary>
        public string Url => _croudiaAttachment?.MediaUrl ?? _mastodonAttachment?.Url ?? _twitterAttachment.MediaUrl;

        /// <summary>
        ///     Preview url
        /// </summary>
        public string PreviewUrl => _croudiaAttachment?.MediaUrl ?? _mastodonAttachment?.PreviewUrl ?? _twitterAttachment.MediaUrlHttps;

        public MediaType MediaType { get; }

        public Attachment(CroudiaAttachment attachment)
        {
            _croudiaAttachment = attachment;
            MediaType = MediaType.Image;
        }

        public Attachment(MastodonAttachment attachment)
        {
            _mastodonAttachment = attachment;
            MediaType = attachment.Type == AttachmentType.Video ? MediaType.Video : MediaType.Image;
        }

        public Attachment(TwitterAttachment attachment)
        {
            _twitterAttachment = attachment;
            MediaType = attachment.Type == "photo" ? MediaType.Image : MediaType.Video; // ??
        }
    }
}<commit_msg>:bug: Fix for Twitter video<commit_after>﻿using System.Linq;

using Orion.Service.Mastodon.Enum;
using Orion.Shared.Absorb.Enums;

using CroudiaAttachment = Orion.Service.Croudia.Models.Media;
using MastodonAttachment = Orion.Service.Mastodon.Models.Attachment;
using TwitterAttachment = CoreTweet.MediaEntity;

namespace Orion.Shared.Absorb.Objects
{
    public class Attachment
    {
        private readonly CroudiaAttachment _croudiaAttachment;
        private readonly MastodonAttachment _mastodonAttachment;
        private readonly TwitterAttachment _twitterAttachment;

        /// <summary>
        ///     URL
        /// </summary>
        public string Url { get; }

        /// <summary>
        ///     Preview url
        /// </summary>
        public string PreviewUrl => _croudiaAttachment?.MediaUrl ?? _mastodonAttachment?.PreviewUrl ?? _twitterAttachment.MediaUrlHttps;

        public MediaType MediaType { get; }

        public Attachment(CroudiaAttachment attachment)
        {
            _croudiaAttachment = attachment;
            Url = attachment.MediaUrl;
            MediaType = MediaType.Image;
        }

        public Attachment(MastodonAttachment attachment)
        {
            _mastodonAttachment = attachment;
            Url = attachment.Url;
            MediaType = attachment.Type == AttachmentType.Video ? MediaType.Video : MediaType.Image;
        }

        public Attachment(TwitterAttachment attachment)
        {
            _twitterAttachment = attachment;
            Url = attachment.Type == "video" ? attachment.VideoInfo.Variants.First(w => w.Bitrate != null).Url : attachment.MediaUrlHttps;
            MediaType = attachment.Type == "photo" ? MediaType.Image : MediaType.Video; // ??
        }
    }
}
{'fraction_non_alphanumeric': 0.0889286780065652, 'fraction_numerical': 0.0, 'mean_word_length': 2.5247108307045214, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2551739', 'n_tokens_mistral': 898, 'n_tokens_neox': 902, 'n_words': 175}