private List <TvShow> GetEpisodesFromFileList(List <FileInfo> fileInfos) { try { List <TvShow> tvShows = new List <TvShow>(); foreach (var fileInfo in fileInfos) { Episode episode = new Episode() { Name = _fileNameParser.GetNameFromFeedItem(fileInfo.Name), LocalPath = fileInfo.FullName }; double episodeNumber = _fileNameParser.GetEpisodeNumberFromFeedItem(fileInfo.Name); if (episodeNumber.Equals(-1)) { OnExceptionEvent(new FileFormatException("Can't parse Local Episode-number from: " + fileInfo.Name)); continue; } else { episode.EpisodeNumber = episodeNumber; } TvShow tvShow = tvShows.SingleOrDefault(item => item.Name.Equals(episode.Name)); if (tvShow == null) { tvShows.Add(new TvShow() { Name = episode.Name, Episodes = new List <Episode>() { episode } }); } else { tvShow.Episodes.Add(episode); } } return(tvShows); } catch (Exception e) { OnExceptionEvent(e); return(null); } }
public List <Episode> DownloadFeedList() { try { List <Episode> episodes = new List <Episode>(); // Create reader and get items XmlTextReader reader = new XmlTextReader(FeedUrl); SyndicationFeed syndicationFeed = SyndicationFeed.Load(reader); List <SyndicationItem> feedList = new List <SyndicationItem>(syndicationFeed.Items); foreach (SyndicationItem syndicationItem in feedList) { Episode episode = new Episode() { Name = _fileNameParser.GetNameFromFeedItem(syndicationItem.Title.Text), Link = syndicationItem.Links[0].Uri.ToString() }; double episodeNumber = _fileNameParser.GetEpisodeNumberFromFeedItem(syndicationItem.Title.Text); if (episodeNumber.Equals(-1)) { throw new FormatException("Can't parse Feed Episode-number from: " + syndicationItem.Title.Text); } else { episode.EpisodeNumber = episodeNumber; } episodes.Add(episode); } return(episodes); } catch (Exception ex) { LogHandler.WriteSystemLog("DownloadFeedList: " + ex, LogLevel.Error); return(null); } }