// -------------------------------------------------------------------------------
        // -------------------------------------------------------------------------------
        /// <summary>
        /// Creates a RSSMediaContent object from a RssCoreItemEnclosure object
        /// </summary>
        /// <param name="enc">RSSItemEnclosure</param>
        /// <returns>RSSMediaContent</returns>
        // -------------------------------------------------------------------------------
        // -------------------------------------------------------------------------------
        public RssMediaContent CreateMediaContentItemFromEnclosure(RssCoreItemEnclosure enc)
        {
            RssMediaContent rt = new RssMediaContent();
            rt.url = enc.url;
            rt.type = enc.type;

            if (RSS.IsImageMimeType(enc.type))
            {
                rt.medium = RSS.MEDIUM_TYPE_IMAGE;
            }
            else if (RSS.IsVideoMimeType(enc.type))
            {
                rt.medium = RSS.MEDIUM_TYPE_VIDEO;
            }
            else if (RSS.IsAudioMimeType(enc.type))
            {
                rt.medium = RSS.MEDIUM_TYPE_AUDIO;
            }

            return rt;
        }
예제 #2
0
        // -------------------------------------------------------------------------------
        // -------------------------------------------------------------------------------
        /// <summary>
        /// THis returns the effective image for the item.  If the enclosure is found, it returns that in the form of a
        /// RSSMediaContent object.  Otherwise, it searches the tree downwards looking for a media content item.
        /// </summary>
        /// <returns>RssMediaContent</returns>
        // -------------------------------------------------------------------------------
        // -------------------------------------------------------------------------------
        public RssMediaContent GetFirstContentItem(string medium, string mimeType = "", bool IncludeEnclosures = true)
        {
            RssMediaContent rt = null;

            if (IncludeEnclosures)
            {
                // try and get an image enclosure
                RssCoreItemEnclosure enc = base.GetFirstEnclosure(medium, mimeType);

                // if we got an enclosure, good, set the return and we will fall through
                if (enc != null)
                {
                    rt = rssUtil.CreateMediaContentItemFromEnclosure(enc);
                }
            }


            // if no enclosures, search the media content items
            if (rt == null)
            {
                rt = rssUtil.GetFirstContentItem(this, medium, mimeType);

                // none found in current content items, lets look to the content groupings
                if (rt == null)
                {
                    for (int i = 0; i < mediaGroups.Count; i++)
                    {
                        rt = rssUtil.GetFirstContentItem(mediaGroups[i], medium, mimeType);
                        if (rt != null)
                        {
                            break;
                        }
                    }
                }
            }

            return(rt);
        }