コード例 #1
0
        public void MappingTest()
        {
            var pluginConfiguration = new PluginConfiguration()
            {
                GenreMappings = new SerializableDictionary<String, List<String>>()
                {
                    { GenreMapper.GENRE_MOVIE, new List<string>() { "Movie", "Film" } },
                    { GenreMapper.GENRE_SPORT, new List<string>() { "Sport", "Football" } },
                }
            };

            var target = new GenreMapper(pluginConfiguration);

            // Test movie
            var movie = new ProgramInfo() { Genres = new List<String>() { "Movie", "Drama" }};
            target.PopulateProgramGenres(movie);
            Assert.IsTrue(movie.IsMovie);
            Assert.IsFalse(movie.IsSports);

            var match = new ProgramInfo() { Genres = new List<String>() { "Sport", "Football" } };
            target.PopulateProgramGenres(match);
            Assert.IsFalse(match.IsMovie);
            Assert.IsTrue(match.IsSports);
        }
コード例 #2
0
        public IEnumerable<ProgramInfo> GetPrograms(string channelId, DateTime startDateUtc, DateTime endDateUtc,
            CancellationToken cancellationToken)
        {
            int x = 0;
            var response = GetFromService<List<Program>>(
                cancellationToken,
                "GetProgramsDetailedForChannel?channelId={0}&starttime={1}&endtime={2}",
                channelId,
                startDateUtc.ToLocalTime().ToUrlDate(),
                endDateUtc.ToLocalTime().ToUrlDate());

            // Create this once per channel - if created at the class level, then changes to configuration would never be caught
            var genreMapper = new GenreMapper(Plugin.Instance.Configuration);

            var programs = response.Select(p =>
            {
                var program = new ProgramInfo()
                {
                    ChannelId = channelId,
                    StartDate = p.StartTime,
                    EndDate = p.EndTime,
                    EpisodeTitle = p.EpisodeName,
                    Genres = new List<String>(),
                    Id = p.Id.ToString(CultureInfo.InvariantCulture),
                    Name = p.Title,
                    Overview = p.Description,
                    // IsSeries = true,
                    // IsPremiere = false,
                    // IsRepeat = true,
                    // OriginalAirDate = p.OriginalAirDate
                };

                if (!String.IsNullOrEmpty(p.EpisodeNum))
                {
                    program.EpisodeNumber = Int32.Parse(p.EpisodeNum);
                }

                if (!String.IsNullOrEmpty(p.SeriesNum))
                {
                    program.SeasonNumber = Int32.Parse(p.SeriesNum);
                }

                if (!String.IsNullOrEmpty(p.Genre))
                {
                    program.Genres.Add(p.Genre);
                    // Call Genre Mapper
                    genreMapper.PopulateProgramGenres(program);
                }

                return program;
            });

            return programs;
        }