Beispiel #1
0
        // Token: 0x0600194A RID: 6474 RVA: 0x00057EF4 File Offset: 0x000560F4
        public override GetLinkPreviewResponse CreatePreview(DataProviderInformation dataProviderInformation)
        {
            string text = ((WebPageInformation)dataProviderInformation).Text;
            Dictionary <string, string> queryParmDictionary;
            LinkPreviewBuilder          linkPreviewBuilder;

            if (YouTubeLinkPreviewBuilder.TryGetYouTubePlayerQueryParms(dataProviderInformation.ResponseUri, this.logger, out queryParmDictionary))
            {
                linkPreviewBuilder = new YouTubeLinkPreviewBuilder(queryParmDictionary, this.request, text, this.logger, dataProviderInformation.ResponseUri);
            }
            else if (AmazonLinkPreviewBuilder.IsAmazonUri(dataProviderInformation.ResponseUri))
            {
                linkPreviewBuilder = new AmazonLinkPreviewBuilder(this.request, text, this.logger, dataProviderInformation.ResponseUri);
            }
            else if (CraigsListLinkPreviewBuilder.IsCraigsListUri(dataProviderInformation.ResponseUri))
            {
                linkPreviewBuilder = new CraigsListLinkPreviewBuilder(this.request, text, this.logger, dataProviderInformation.ResponseUri);
            }
            else
            {
                linkPreviewBuilder = new WebPageLinkPreviewBuilder(this.request, text, this.logger, dataProviderInformation.ResponseUri, false);
            }
            return(linkPreviewBuilder.Execute());
        }
Beispiel #2
0
        // Token: 0x06001966 RID: 6502 RVA: 0x000588FC File Offset: 0x00056AFC
        internal static bool TryGetYouTubePlayerQueryParms(Uri uri, RequestDetailsLogger logger, out Dictionary <string, string> queryParmDictionary)
        {
            queryParmDictionary = null;
            bool flag = false;

            if (!YouTubeLinkPreviewBuilder.IsYoutubeUri(uri))
            {
                return(false);
            }
            string text = uri.Query.TrimStart(new char[]
            {
                '?'
            });

            if (text.Length == 0)
            {
                return(false);
            }
            string[] array = text.Split(new char[]
            {
                '&'
            });
            if (array.Length > 3)
            {
                logger.Set(GetLinkPreviewMetadata.YouTubeLinkValidationFailed, 1);
                return(false);
            }
            queryParmDictionary = new Dictionary <string, string>(4);
            foreach (string text2 in array)
            {
                string[] array3 = text2.Split(new char[]
                {
                    '='
                });
                if (array3.Length == 2)
                {
                    string text3 = array3[0].ToLower();
                    string a;
                    if ((a = text3) != null)
                    {
                        if (!(a == "v") && !(a == "app") && !(a == "feature"))
                        {
                            if (!(a == "t"))
                            {
                                goto IL_EE;
                            }
                            flag = true;
                        }
                        queryParmDictionary.Add(text3, array3[1]);
                        goto IL_117;
                    }
IL_EE:
                    logger.Set(GetLinkPreviewMetadata.YouTubeLinkValidationFailed, 1);
                    return(false);
                }
                IL_117 :;
            }
            if (!queryParmDictionary.ContainsKey("v"))
            {
                logger.Set(GetLinkPreviewMetadata.YouTubeLinkValidationFailed, 1);
                return(false);
            }
            if (!flag && uri.Fragment != null && uri.Fragment.Length > 0 && uri.Fragment.StartsWith("#t=", StringComparison.InvariantCultureIgnoreCase))
            {
                string text4 = uri.Fragment.Substring("#t=".Length);
                if (text4.Length > 0)
                {
                    queryParmDictionary.Add("t", text4);
                }
            }
            return(true);
        }