Exemplo n.º 1
0
        public static async Task ReadOutChannels(XmlTvReader reader, StreamWriter resultsFileStream)
        {
            var channels = reader.GetChannels().Distinct().ToList();

            resultsFileStream.Write(EntityExtensions.GetHeader("Channels"));

            foreach (var channel in channels)
            {
                System.Console.WriteLine("Retrieved Channel: {0} - {1}", channel.Id, channel.DisplayName);
                resultsFileStream.Write(channel.GetChannelDetail());
            }

            var totalProgrammeCount = 0;

            resultsFileStream.Write("\r\n");
            foreach (var channel in channels)
            {
                System.Console.WriteLine("Processing Channel: {0}", channel.DisplayName);

                resultsFileStream.Write(EntityExtensions.GetHeader("Programs for " + channel.DisplayName));
                var channelProgrammeCount = await ReadOutChannelProgrammes(reader, channel, resultsFileStream);

                totalProgrammeCount += channelProgrammeCount;
                await resultsFileStream.WriteLineAsync(String.Format("Total Programmes for {1}: {0}", channelProgrammeCount, channel.DisplayName));
            }

            await resultsFileStream.WriteLineAsync(String.Format("Total Programmes: {0}", totalProgrammeCount));
        }
Exemplo n.º 2
0
        public void UKDataGeneralTest()
        {
            var testFile = Path.Join("Test Data", "UK_Data.xml");
            var reader   = new XmlTvReader(testFile, null);

            var channels = reader.GetChannels().ToList();

            Assert.Equal(5, channels.Count);

            // Pick a channel to check the data for
            var channel = channels.SingleOrDefault(c => c.Id == "UK_RT_2056");

            Assert.NotNull(channel);

            var startDate  = new DateTimeOffset(2015, 11, 26, 0, 0, 0, new TimeSpan());
            var programmes = reader.GetProgrammes(channel !.Id, startDate, startDate.AddDays(1)).ToList();

            Assert.Equal(27, programmes.Count);
            var programme = programmes.SingleOrDefault(p => p.Title == "The Secret Life of");

            Assert.NotNull(programme);
            Assert.Equal(new DateTimeOffset(2015, 11, 26, 20, 0, 0, 0, new TimeSpan()), programme !.StartDate);
            Assert.Equal(new DateTimeOffset(2015, 11, 26, 21, 0, 0, 0, new TimeSpan()), programme.EndDate);
            Assert.Equal("Cameras follow the youngsters' development after two weeks apart and time has made the heart grow fonder for Alfie and Emily, who are clearly happy to be back together. And although Alfie struggled to empathise with the rest of his peers before, a painting competition proves to be a turning point for him. George takes the children's rejection of his family recipe to heart, but goes on to triumph elsewhere, and romance is in the air when newcomer Sienna captures Arthur's heart.", programme.Description);
            Assert.Equal("Documentary", programme.Categories.Single());
            Assert.NotNull(programme.Episode);
            Assert.Equal("The Secret Life of 5 Year Olds", programme.Episode.Title);
            Assert.Equal(1, programme.Episode.Series);
            Assert.Null(programme.Episode.SeriesCount);
            Assert.Equal(4, programme.Episode.Episode);
            Assert.Equal(6, programme.Episode.EpisodeCount);
            Assert.NotNull(programme.Premiere);
            Assert.Equal("First showing on national terrestrial TV", programme !.Premiere !.Details);
            Assert.True(programme.IsNew);
        }
Exemplo n.º 3
0
        public void ES_MultiLanguageDataTest()
        {
            var testFile = Path.GetFullPath(@"ES_MultiLanguageData.xml");
            var reader   = new XmlTvReader(testFile, "es"); // Specify the spanish language explicitly

            var channels = reader.GetChannels().ToList();

            Assert.AreEqual(141, channels.Count);

            // Pick a channel to check the data for
            var channel = channels.SingleOrDefault(c => c.Id == "Canal + HD" && c.DisplayName == "Canal + HD");

            Assert.IsNotNull(channel);

            var startDate         = new DateTime(2016, 02, 18);
            var cancellationToken = new CancellationToken();
            var programmes        = reader.GetProgrammes(channel.Id, startDate, startDate.AddDays(1), cancellationToken).ToList();

            Assert.AreEqual(22, programmes.Count);
            var programme = programmes.SingleOrDefault(p => p.Title == "This is Comedy. Judd Apatow & Co.");

            /*
             * <programme start="20160218055100 +0100" stop="20160218065400 +0100" channel="Canal + HD">
             *  <title lang="es">This is Comedy. Judd Apatow &amp; Co.</title>
             *  <title lang="en">This is Comedy</title>
             *  <desc lang="es">El resurgir creativo de la comedia estadounidense en los últimos 15 años ha tenido un nombre indiscutible, Judd Apatow, y unos colaboradores indispensables, sus amigos (actores, cómicos, escritores) Jonah Hill, Steve Carrell, Paul Rudd, Seth Rogen, Lena Dunham... A través de extractos de sus filmes y de entrevistas a algunos los miembros de su 'banda' (Adam Sandler, Lena Dunham o Jason Segel), este documental muestra la carrera de un productor y director excepcional que ha sido capaz de llevar la risa a su máxima expresión</desc>
             *  <credits>
             *    <director>Jacky Goldberg</director>
             *  </credits>
             *  <date>2014</date>
             *  <category lang="es">Documentales</category>
             *  <category lang="es">Sociedad</category>
             *  <icon src="http://www.plus.es/recorte/n/caratula4/F3027798" />
             *  <country>Francia</country>
             *  <rating system="MPAA">
             *    <value>TV-G</value>
             *  </rating>
             *  <star-rating>
             *    <value>3/5</value>
             *  </star-rating>
             * </programme>
             */

            Assert.IsNotNull(programme);
            Assert.AreEqual(new DateTime(2016, 02, 18, 4, 51, 0), programme.StartDate);
            Assert.AreEqual(new DateTime(2016, 02, 18, 5, 54, 0), programme.EndDate);
            Assert.AreEqual("El resurgir creativo de la comedia estadounidense en los últimos 15 años ha tenido un nombre indiscutible, Judd Apatow, y unos colaboradores indispensables, sus amigos (actores, cómicos, escritores) Jonah Hill, Steve Carrell, Paul Rudd, Seth Rogen, Lena Dunham... A través de extractos de sus filmes y de entrevistas a algunos los miembros de su 'banda' (Adam Sandler, Lena Dunham o Jason Segel), este documental muestra la carrera de un productor y director excepcional que ha sido capaz de llevar la risa a su máxima expresión", programme.Description);
            Assert.AreEqual(2, programme.Categories.Count);
            Assert.AreEqual("Documentales", programme.Categories[0]);
            Assert.AreEqual("Sociedad", programme.Categories[1]);
            Assert.IsNotNull(programme.Episode);
            Assert.IsNull(programme.Episode.Episode);
            Assert.IsNull(programme.Episode.EpisodeCount);
            Assert.IsNull(programme.Episode.Part);
            Assert.IsNull(programme.Episode.PartCount);
            Assert.IsNull(programme.Episode.Series);
            Assert.IsNull(programme.Episode.SeriesCount);
            Assert.IsNull(programme.Episode.Title);
        }
Exemplo n.º 4
0
        public void HoneybeeTest()
        {
            var testFile = Path.GetFullPath(@"honeybee.xml");
            var reader   = new XmlTvReader(testFile, null);

            var channels = reader.GetChannels().ToList();

            Assert.AreEqual(16, channels.Count);
        }
Exemplo n.º 5
0
        public void HoneybeeTest()
        {
            var testFile = Path.GetFullPath(@"honeybee.xml");
            var reader   = new XmlTvReader(testFile, null);

            var channels = reader.GetChannels().ToList();

            Assert.AreEqual(16, channels.Count);

            var programs = reader.GetProgrammes("2013.honeybee.it", DateTime.UtcNow.AddYears(-1),
                                                DateTime.UtcNow.AddYears(1), CancellationToken.None).ToList();

            Assert.AreEqual(297, programs.Count);
        }
Exemplo n.º 6
0
        public async Task <List <NameIdPair> > GetLineups(ListingsProviderInfo info, string country, string location)
        {
            // In theory this should never be called because there is always only one lineup
            var path = await GetXml(info.Path, CancellationToken.None).ConfigureAwait(false);

            var reader  = new XmlTvReader(path, GetLanguage());
            var results = reader.GetChannels();

            // Should this method be async?
            return(results.Select(c => new NameIdPair()
            {
                Id = c.Id, Name = c.DisplayName
            }).ToList());
        }
Exemplo n.º 7
0
        public void UKDataChannelsTest()
        {
            var testFile = Path.Join("Test Data", "UK_Data.xml");
            var reader   = new XmlTvReader(testFile);

            var channels = reader.GetChannels().ToList();

            Assert.Equal(5, channels.Count);

            // Check each channel
            var channel = channels.SingleOrDefault(c => c.Id == "UK_RT_2667");

            Assert.NotNull(channel);
            Assert.Equal("BBC1 HD", channel !.DisplayName);
            Assert.Equal("7.1", channel.Number);
            Assert.NotNull(channel.Icon);
            Assert.Equal("Logo_UK_RT_2667", channel !.Icon !.Source);
            Assert.Equal(100, channel.Icon.Width);
            Assert.Equal(200, channel.Icon.Height);

            channel = channels.SingleOrDefault(c => c.Id == "UK_RT_105");
            Assert.NotNull(channel);
            Assert.Equal("BBC2", channel !.DisplayName);
            Assert.NotNull(channel.Icon);
            Assert.Equal("Logo_UK_RT_105", channel !.Icon !.Source);
            Assert.False(channel.Icon.Width.HasValue);
            Assert.False(channel.Icon.Height.HasValue);

            channel = channels.SingleOrDefault(c => c.Id == "UK_RT_2118");
            Assert.NotNull(channel);
            Assert.Equal("ITV1 HD", channel !.DisplayName);
            Assert.NotNull(channel.Icon);
            Assert.Equal("Logo_UK_RT_2118", channel !.Icon !.Source);
            Assert.Equal(100, channel.Icon.Width);
            Assert.False(channel.Icon.Height.HasValue);

            channel = channels.SingleOrDefault(c => c.Id == "UK_RT_2056");
            Assert.NotNull(channel);
            Assert.Equal("Channel 4 HD", channel !.DisplayName);
            Assert.NotNull(channel.Icon);
            Assert.Equal("Logo_UK_RT_2056", channel !.Icon !.Source);
            Assert.False(channel.Icon.Width.HasValue);
            Assert.Equal(200, channel.Icon.Height);

            channel = channels.SingleOrDefault(c => c.Id == "UK_RT_134");
            Assert.NotNull(channel);
            Assert.Equal("Channel 5", channel !.DisplayName);
            Assert.Null(channel.Icon);
        }
Exemplo n.º 8
0
        public void UK_DataTest_ChannelsTest()
        {
            var testFile = Path.GetFullPath(@"UK_Data.xml");
            var reader   = new XmlTvReader(testFile, null);

            var channels = reader.GetChannels().ToList();

            Assert.AreEqual(5, channels.Count);

            // Check each channel
            var channel = channels.SingleOrDefault(c => c.Id == "UK_RT_2667");

            Assert.IsNotNull(channel);
            Assert.AreEqual("BBC1 HD", channel.DisplayName);
            Assert.IsNotNull(channel.Icon);
            Assert.AreEqual("Logo_UK_RT_2667", channel.Icon.Source);
            Assert.AreEqual(100, channel.Icon.Width);
            Assert.AreEqual(200, channel.Icon.Height);

            channel = channels.SingleOrDefault(c => c.Id == "UK_RT_105");
            Assert.IsNotNull(channel);
            Assert.AreEqual("BBC2", channel.DisplayName);
            Assert.IsNotNull(channel.Icon);
            Assert.AreEqual("Logo_UK_RT_105", channel.Icon.Source);
            Assert.IsFalse(channel.Icon.Width.HasValue);
            Assert.IsFalse(channel.Icon.Height.HasValue);

            channel = channels.SingleOrDefault(c => c.Id == "UK_RT_2118");
            Assert.IsNotNull(channel);
            Assert.AreEqual("ITV1 HD", channel.DisplayName);
            Assert.IsNotNull(channel.Icon);
            Assert.AreEqual("Logo_UK_RT_2118", channel.Icon.Source);
            Assert.AreEqual(100, channel.Icon.Width);
            Assert.IsFalse(channel.Icon.Height.HasValue);

            channel = channels.SingleOrDefault(c => c.Id == "UK_RT_2056");
            Assert.IsNotNull(channel);
            Assert.AreEqual("Channel 4 HD", channel.DisplayName);
            Assert.IsNotNull(channel.Icon);
            Assert.AreEqual("Logo_UK_RT_2056", channel.Icon.Source);
            Assert.IsFalse(channel.Icon.Width.HasValue);
            Assert.AreEqual(200, channel.Icon.Height);

            channel = channels.SingleOrDefault(c => c.Id == "UK_RT_134");
            Assert.IsNotNull(channel);
            Assert.AreEqual("Channel 5", channel.DisplayName);
            Assert.IsNull(channel.Icon);
        }
Exemplo n.º 9
0
        public void FirstMatchingLanguageESTest()
        {
            var testFile = Path.Join("Test Data", "MultilanguageData.xml");
            var reader = new XmlTvReader(testFile, "es");
            var channel = reader.GetChannels().FirstOrDefault();
            Assert.NotNull(channel);

            var startDate = new DateTime(2015, 11, 26);
            var cancellationToken = new CancellationToken();
            var programme = reader.GetProgrammes(channel.Id, startDate, startDate.AddDays(1), cancellationToken).FirstOrDefault();

            Assert.NotNull(programme);
            Assert.Equal("Homes Under the Hammer - Spanish", programme.Title);
            Assert.Single(programme.Categories);
            Assert.Equal("Property - Spanish", programme.Categories[0]);
        }
Exemplo n.º 10
0
        public void HoneybeeTest()
        {
            var testFile = Path.Join("Test Data", "honeybee.xml");
            var reader   = new XmlTvReader(testFile, null);

            var channels = reader.GetChannels().ToList();

            Assert.Equal(16, channels.Count);

            var startDate = new DateTimeOffset(2017, 2, 1, 0, 0, 0, new TimeSpan());
            var programs  = reader.GetProgrammes(
                "2013.honeybee.it",
                startDate,
                startDate.AddMonths(1)).ToList();

            Assert.Equal(297, programs.Count);
        }
Exemplo n.º 11
0
        public void Should_Return_The_First_Matching_Language_ES()
        {
            var testFile = Path.GetFullPath(@"MultilanguageData.xml");
            var reader   = new XmlTvReader(testFile, "es");
            var channel  = reader.GetChannels().FirstOrDefault();

            Assert.IsNotNull(channel);

            var startDate         = new DateTime(2015, 11, 26);
            var cancellationToken = new CancellationToken();
            var programme         = reader.GetProgrammes(channel.Id, startDate, startDate.AddDays(1), cancellationToken).FirstOrDefault();

            Assert.IsNotNull(programme);
            Assert.AreEqual("Homes Under the Hammer - Spanish", programme.Title);
            Assert.AreEqual(1, programme.Categories.Count);
            Assert.AreEqual("Property - Spanish", programme.Categories[0]);
        }
        public void FirstMatchingEmptyLanguageTest()
        {
            var testFile = Path.Join("Test Data", "MultilanguageData.xml");
            var reader   = new XmlTvReader(testFile, string.Empty);

            var channel = reader.GetChannels().FirstOrDefault();

            Assert.NotNull(channel);

            var startDate = new DateTime(2015, 11, 26);
            var programme = reader.GetProgrammes(channel !.Id, startDate, startDate.AddDays(1)).FirstOrDefault();

            Assert.NotNull(programme);
            Assert.Equal("Homes Under the Hammer - Empty Language", programme !.Title);
            Assert.Single(programme.Categories);
            Assert.Equal("Property - Empty Language", programme.Categories[0]);
        }
Exemplo n.º 13
0
        public async Task <List <ChannelInfo> > GetChannels(ListingsProviderInfo info, CancellationToken cancellationToken)
        {
            // In theory this should never be called because there is always only one lineup
            var path = await GetXml(info.Path, cancellationToken).ConfigureAwait(false);

            var reader  = new XmlTvReader(path, GetLanguage());
            var results = reader.GetChannels();

            // Should this method be async?
            return(results.Select(c => new ChannelInfo()
            {
                Id = c.Id,
                Name = c.DisplayName,
                ImageUrl = c.Icon != null && !String.IsNullOrEmpty(c.Icon.Source) ? c.Icon.Source : null,
                Number = c.Id
            }).ToList());
        }
Exemplo n.º 14
0
        public async Task <List <ChannelInfo> > GetChannels(ListingsProviderInfo info, CancellationToken cancellationToken)
        {
            // In theory this should never be called because there is always only one lineup
            string path = await GetXml(info, cancellationToken).ConfigureAwait(false);

            _logger.LogDebug("Opening XmlTvReader for {Path}", path);
            var reader  = new XmlTvReader(path, GetLanguage(info));
            var results = reader.GetChannels();

            // Should this method be async?
            return(results.Select(c => new ChannelInfo
            {
                Id = c.Id,
                Name = c.DisplayName,
                ImageUrl = c.Icon != null && !string.IsNullOrEmpty(c.Icon.Source) ? c.Icon.Source : null,
                Number = string.IsNullOrWhiteSpace(c.Number) ? c.Id : c.Number
            }).ToList());
        }
Exemplo n.º 15
0
        public void FirstNoMatchFoundTest()
        {
            var testFile = Path.Join("Test Data", "MultilanguageData.xml");
            var reader = new XmlTvReader(testFile, "es"); // There are no titles or categories for spanish

            var channel = reader.GetChannels().FirstOrDefault();
            Assert.NotNull(channel);

            var startDate = new DateTime(2015, 11, 26);
            var cancellationToken = new CancellationToken();
            var programme = reader.GetProgrammes(channel.Id, startDate, startDate.AddDays(1), cancellationToken).Skip(1).FirstOrDefault();

            Assert.NotNull(programme);
            Assert.Equal("Homes Under the Hammer - No Language", programme.Title);

            // Should return all categories
            Assert.Equal(2, programme.Categories.Count);
            Assert.Contains("Property - English", programme.Categories);
            Assert.Contains("Property - Empty Language", programme.Categories);
        }
        public void FirstNoLanguageTest()
        {
            var testFile = Path.Join("Test Data", "MultilanguageData.xml");
            var reader   = new XmlTvReader(testFile, null);

            var channel = reader.GetChannels().FirstOrDefault();

            Assert.NotNull(channel);

            var startDate = new DateTime(2015, 11, 26);
            var programme = reader.GetProgrammes(channel !.Id, startDate, startDate.AddDays(1)).Skip(1).FirstOrDefault();

            Assert.NotNull(programme);
            Assert.Equal("Homes Under the Hammer - No Language", programme !.Title); // Should return the first in the list

            // Should return all categories
            Assert.Equal(2, programme.Categories.Count);
            Assert.Contains("Property - English", programme.Categories);
            Assert.Contains("Property - Empty Language", programme.Categories);
        }
Exemplo n.º 17
0
        public void Should_Return_The_First_When_NoLanguage()
        {
            var testFile = Path.GetFullPath(@"MultilanguageData.xml");
            var reader   = new XmlTvReader(testFile, null);

            var channel = reader.GetChannels().FirstOrDefault();

            Assert.IsNotNull(channel);

            var startDate         = new DateTime(2015, 11, 26);
            var cancellationToken = new CancellationToken();
            var programme         = reader.GetProgrammes(channel.Id, startDate, startDate.AddDays(1), cancellationToken).Skip(1).FirstOrDefault();

            Assert.IsNotNull(programme);
            Assert.AreEqual("Homes Under the Hammer - English", programme.Title); // Should return the first in the list

            // Should return all categories
            Assert.AreEqual(2, programme.Categories.Count);
            Assert.IsTrue(programme.Categories.Contains("Property - English"));
            Assert.IsTrue(programme.Categories.Contains("Property - Empty Language"));
        }
Exemplo n.º 18
0
        public async Task AddMetadata(ListingsProviderInfo info, List <ChannelInfo> channels, CancellationToken cancellationToken)
        {
            // Add the channel image url
            var path = await GetXml(info.Path, cancellationToken).ConfigureAwait(false);

            var reader  = new XmlTvReader(path, GetLanguage());
            var results = reader.GetChannels().ToList();

            if (channels != null)
            {
                foreach (var c in channels)
                {
                    var channelNumber = info.GetMappedChannel(c.Number);
                    var match         = results.FirstOrDefault(r => string.Equals(r.Id, channelNumber, StringComparison.OrdinalIgnoreCase));

                    if (match != null && match.Icon != null && !String.IsNullOrEmpty(match.Icon.Source))
                    {
                        c.ImageUrl = match.Icon.Source;
                    }
                }
            }
        }
Exemplo n.º 19
0
        public void SchedulesDirectTest()
        {
            var testFile = Path.Join("Test Data", "schedulesdirect.xml");
            var reader   = new XmlTvReader(testFile, null);

            var channels = reader.GetChannels().ToList();

            // Pick a channel to check the data for
            var channel = channels.SingleOrDefault(c => c.Id == "EPG123.10108.schedulesdirect.org"); // CTV Toronto

            Assert.NotNull(channel);

            var startDate  = new DateTimeOffset(2020, 07, 29, 0, 0, 0, new TimeSpan());
            var programmes = reader.GetProgrammes(channel !.Id, startDate, startDate.AddDays(1)).ToList();

            var programme = programmes.SingleOrDefault(p => p.Title == "Match Game");

            Assert.NotNull(programme !.Episode);
            Assert.True(programme.Credits.Count == 9);

            Assert.NotNull(programme.Icon);
            Assert.True(programme !.Icon !.Width > programme.Icon.Height);
        }