Example #1
0
        public async Task <List <ChannelInfo> > GetChannelsAsync(ILogger logger)
        {
            List <ChannelInfo> channels = new List <ChannelInfo>();

            logger.Info("[VDR LiveTV] GetChannelsAsync --- START --- ");
            GetChannelsResponse response = await client.GetAsync(new GetChannelsRequest());

            if (response.Channels != null)
            {
                foreach (VdrChannel channel in response.Channels)
                {
                    logger.Info("[VDR LiveTV] GetChannelsAsync data | ID {0} | CHANTYPE {1} | NAME {2} | NUMBER {3} | HASIMAGE {4} | IMAGEURL {5}  ...", channel.channel_id, channel.is_radio ? ChannelType.Radio : ChannelType.TV, channel.name, channel.number.ToString(), channel.image, channel.image ? string.Format("{0}/channels/image/{1}", baseUrl, channel.channel_id) : null);
                    channels.Add(new ChannelInfo()
                    {
                        Id          = channel.channel_id,
                        ChannelType = channel.is_radio ? ChannelType.Radio : ChannelType.TV,
                        Name        = channel.name,
                        Number      = channel.number.ToString(),
                        HasImage    = channel.image,
                        ImageUrl    = channel.image ? string.Format("{0}/channels/image/{1}", baseUrl, channel.channel_id) : null
                    });
                }
            }

            logger.Info("[VDR LiveTV] GetChannelsAsync --- END --- ");
            return(channels);
        }
        public async Task <List <ChannelInfo> > GetChannelsAsync()
        {
            List <ChannelInfo> channels = new List <ChannelInfo>();

            GetChannelsResponse response = await client.GetAsync(new GetChannelsRequest());

            if (response.Channels != null)
            {
                foreach (VdrChannel channel in response.Channels)
                {
                    channels.Add(new ChannelInfo()
                    {
                        Id          = channel.channel_id,
                        ChannelType = channel.is_radio ? ChannelType.Radio : ChannelType.TV,
                        Name        = channel.name,
                        Number      = channel.number.ToString(),
                        HasImage    = channel.image,
                        ImageUrl    = string.Format("{0}/channels/image/{1}", baseUrl, channel.channel_id)
                    });
                }
            }

            return(channels);
        }