Beispiel #1
0
        private string GetShow(SyndicationItem item, SourceFeed sourceFeed)
        {
            if (sourceFeed != null)
            {
                return(sourceFeed.Name);
            }

            var show = item.Title.Text.Split("|").ElementAt(1);

            return(show?.Trim());
        }
Beispiel #2
0
 private Episode CreateEpisode(SyndicationItem item, SourceFeed sourceFeed)
 {
     return(new Episode
     {
         Title = GetTitle(item),
         Show = GetShow(item, sourceFeed),
         Summary = GetSummary(item),
         Date = item.PublishDate,
         Categories = GetCategories(item).ToArray(),
         ImageUri = GetThumbnailUri(item),
         EpisodeUri = GetEpisodeUri(item),
         VideoUri = GetVideoUri(item),
         Duration = GetDuration(item)
     });
 }
Beispiel #3
0
 private Post CreatePost(SyndicationItem item, SourceFeed source)
 {
     return(new Post
     {
         Title = GetTitle(item),
         Show = source.Show ?? GetShow(item),
         Summary = GetSummary(item),
         Date = item.PublishDate,
         Categories = GetCategories(item).ToArray(),
         ImageUri = GetThumbnailUri(item),
         PostUri = GetPostUri(item),
         VideoUri = GetVideoUri(item),
         Duration = GetDuration(item)
     });
 }
Beispiel #4
0
        private IEnumerable <Episode> GetEpisodes(SourceFeed sourceFeed, SyndicationFeed rssFeed)
        {
            var episodes = new List <Episode>();

            var feedEpisodes = rssFeed
                               .Items
                               .Select(i => CreateEpisode(i, sourceFeed))
                               .ToArray();

            episodes.AddRange(feedEpisodes);

            var comparer = new EpisodeEqualityComparer();

            return(episodes
                   .Distinct(comparer)
                   .OrderByDescending(p => p.Date)
                   .ToArray());
        }
Beispiel #5
0
        /// <inheritdoc/>
        public Task <Show> GetShow(SourceFeed sourceFeed = null)
        {
            var url = sourceFeed != null ? sourceFeed.Url : _channel9Feed.Url;

            if (_cache.TryGetValue(url, out var cachedShow))
            {
                return(Task.FromResult(cachedShow));
            }

            var rssFeed = GetRssFeed(url);

            var show = new Show()
            {
                Description = rssFeed.Description.Text,
                Image       = sourceFeed?.Image,
                Name        = sourceFeed?.Name
            };

            show.Episodes = GetEpisodes(sourceFeed, rssFeed);

            _cache.Add(url, show);

            return(Task.FromResult(show));
        }
Beispiel #6
0
        /// <inheritdoc/>
        public async Task <Show> GetShow(SourceFeed sourceFeed = null)
        {
            var url = sourceFeed != null ? sourceFeed.FeedUrl : _channel9Feed.FeedUrl;

            if (_cache.TryGetValue(url, out var cachedShow))
            {
                return(cachedShow);
            }

            var rssFeed = await GetRssFeed(url);

            var show = new Show()
            {
                Description = rssFeed.Description.Text,
                Image       = sourceFeed?.ThumbnailUrl,
                Name        = sourceFeed?.Name
            };

            show.Episodes = GetEpisodes(sourceFeed, rssFeed);

            _cache.Add(url, show);

            return(show);
        }