Ejemplo n.º 1
0
        protected override void SetAdditionalProperties(LinkPreview linkPreview)
        {
            if (this.oEmbedResponse == null)
            {
                GetLinkPreview.ThrowInvalidRequestException("OEmbedResponseNull", string.Format("The OEmbedResponse was null for the webpage information for {0}", this.responseUri.AbsoluteUri));
            }
            if (this.oEmbedResponse.Html == null)
            {
                GetLinkPreview.ThrowInvalidRequestException("OEmbedResponseHtmlNull", string.Format("The OEmbedResponse HTML was null for the webpage information for {0}", this.responseUri.AbsoluteUri));
            }
            string text = this.oEmbedResponse.Html;

            if (this.oEmbedResponse.ProviderName.Equals("YouTube") || this.oEmbedResponse.ProviderName.Equals("Dailymotion"))
            {
                text = text.Replace("http://", "https://");
            }
            else if (this.oEmbedResponse.ProviderName.Equals("Hulu"))
            {
                text = text.Replace("http://www.hulu.com", "https://secure.hulu.com");
            }
            ((OEmbedVideoPreview)linkPreview).EmbeddedHtml = text;
        }
Ejemplo n.º 2
0
        // Token: 0x06001962 RID: 6498 RVA: 0x00058764 File Offset: 0x00056964
        protected override void SetAdditionalProperties(LinkPreview linkPreview)
        {
            string        format        = this.autoplay ? "https://www.youtube.com/embed/{0}?autoplay=1" : "https://www.youtube.com/embed/{0}";
            string        value         = LinkPreviewBuilder.ConvertToSafeHtml(string.Format(format, this.youTubeId));
            StringBuilder stringBuilder = new StringBuilder(value);
            int           startTime     = this.GetStartTime();

            if (startTime > 0)
            {
                if (!this.autoplay)
                {
                    stringBuilder.Append('?');
                }
                else
                {
                    stringBuilder.Append('&');
                }
                stringBuilder.Append("start");
                stringBuilder.Append('=');
                stringBuilder.Append(startTime);
            }
            ((YouTubeLinkPreview)linkPreview).PlayerUrl = stringBuilder.ToString();
        }
        // Token: 0x060018D0 RID: 6352 RVA: 0x00055DB0 File Offset: 0x00053FB0
        internal override GetLinkPreviewResponse Execute()
        {
            GetLinkPreviewResponse getLinkPreviewResponse = new GetLinkPreviewResponse();
            LinkPreview            linkPreview            = this.CreateLinkPreviewInstance();

            linkPreview.Id  = this.id;
            linkPreview.Url = this.url;
            linkPreview.RequestStartTimeMilliseconds = this.requestStartTimeMilliseconds;
            int imageTagCount;

            linkPreview.ImageUrl = this.GetImage(out imageTagCount);
            linkPreview.Title    = this.GetTitle();
            int descriptionTagCount;

            linkPreview.Description = this.GetDescription(out descriptionTagCount);
            linkPreview.IsVideo     = base.IsVideo;
            if (string.IsNullOrWhiteSpace(linkPreview.Title))
            {
                if (string.IsNullOrWhiteSpace(linkPreview.Description))
                {
                    GetLinkPreview.ThrowInvalidRequestException("TitleAndDescriptionNotFound", "No title or description were found.");
                }
                else if (string.IsNullOrWhiteSpace(linkPreview.ImageUrl))
                {
                    GetLinkPreview.ThrowInvalidRequestException("TitleAndImageNotFound", "No title or image were found.");
                }
            }
            else if (string.IsNullOrWhiteSpace(linkPreview.Description) && string.IsNullOrWhiteSpace(linkPreview.ImageUrl))
            {
                GetLinkPreview.ThrowInvalidRequestException("DescriptionAndImageNotFound", "No description or image were found.");
            }
            this.SetAdditionalProperties(linkPreview);
            getLinkPreviewResponse.LinkPreview         = linkPreview;
            getLinkPreviewResponse.ImageTagCount       = imageTagCount;
            getLinkPreviewResponse.DescriptionTagCount = descriptionTagCount;
            return(getLinkPreviewResponse);
        }
 // Token: 0x060018D6 RID: 6358 RVA: 0x00056063 File Offset: 0x00054263
 protected virtual void SetAdditionalProperties(LinkPreview linkPreview)
 {
 }