Ejemplo n.º 1
0
        /// <summary>
        /// Represents a single episode parsed from a stream.
        /// </summary>
        /// <param name="baseItem"></param>
        internal EpisodeModel(SyndicationItem baseItem, int epIndex, string showTitle)
        {
            Title       = baseItem.Title.Text.CleanFileName();
            Description = baseItem.Summary.Text.CleanMarkup();
            PubDate     = baseItem.PublishDate;

            foreach (var link in baseItem.Links)
            {
                var uri = link.GetAbsoluteUri();
                // Check if we have an actual audio file. If not... store it.
                if (link.RelationshipType == "enclosure")
                {
                    Permalink = link.Uri.ToString();
                    Extension = Path.GetExtension(Permalink).Substring(0, 4);
                    if (string.IsNullOrWhiteSpace(Extension))
                    {
                        Extension = ParseOutExtension(Permalink.ToLowerInvariant());
                    }
                    FileName = $"{showTitle} {epIndex} - {Title}{Extension}";
                }
                else
                {
                    DisplayLink = uri.AbsoluteUri;
                }
            }

            foreach (var extension in baseItem.ElementExtensions)
            {
                var ele = extension.GetObject <XElement>();

                switch (extension.OuterName)
                {
                case "keywords":
                    KeywordString = ele.Value;
                    break;

                case "explicit":
                    IsExplicit = ele.Value.ToLowerInvariant() == "yes";
                    break;

                case "image":
                    ImageLink = ele.Value;
                    break;
                }
            }
        }