public IEnumerable <ChannelInfo> GetChannels(CancellationToken cancellationToken)
        {
            var builder = new StringBuilder("GetChannelsDetailed");

            if (Configuration.DefaultChannelGroup > 0)
            {
                // This is the only way to get out the channels in the same order that MP displays them.
                builder.AppendFormat("?groupId={0}", Configuration.DefaultChannelGroup);
            }

            var channels = GetFromService <List <Channel> >(cancellationToken, builder.ToString());
            IEnumerable <Channel> query = channels;

            switch (Configuration.DefaultChannelSortOrder)
            {
            case ChannelSorting.ChannelName:
                query = query.OrderBy(q => q.Title);
                break;

            case ChannelSorting.ChannelId:
                query = query.OrderBy(q => q.Id);
                break;
            }

            Plugin.Logger.Info("Found channels: {0}", channels.Where(c => c.VisibleInGuide));
            return(query.Where(c => c.VisibleInGuide).Select((c, index) => new ChannelInfo()
            {
                Name = c.Title,
                Id = c.Id.ToString(CultureInfo.InvariantCulture),
                ChannelType = c.IsTv ? ChannelType.TV : ChannelType.Radio,
                Number = (Configuration.ChannelByIndex) ? (index + 1).ToString("D1", CultureInfo.InvariantCulture) : " ",
                ImageUrl = _wssProxy.GetChannelLogoUrl(c.Id)
            }));
        }
Example #2
0
        public IEnumerable <ChannelInfo> GetChannels(CancellationToken cancellationToken)
        {
            var builder = new StringBuilder("GetChannelsDetailed");

            if (Configuration.DefaultChannelGroup > 0)
            {
                // This is the only way to get out the channels in the same order that MP displays them.
                // No idea why you sepecify Year as the sort field!
                builder.AppendFormat("?groupId={0}", Configuration.DefaultChannelGroup);
            }

            var response = GetFromService <List <Channel> >(cancellationToken, builder.ToString());
            IEnumerable <Channel> query = response;

            switch (Configuration.DefaultChannelSortOrder)
            {
            case ChannelSorting.ChannelName:
                query = query.OrderBy(q => q.Title);
                break;

            case ChannelSorting.ChannelNumber:
                query = query.OrderBy(q => q.Id);
                break;
            }

            return(query.Where(c => c.VisibleInGuide).Select(c => new ChannelInfo()
            {
                Id = c.Id.ToString(CultureInfo.InvariantCulture),
                ChannelType = c.IsTv ? ChannelType.TV : ChannelType.Radio,
                Name = c.Title,
                Number = c.ExternalId,
                ImageUrl = _wssProxy.GetChannelLogoUrl(c.Id)
            }));
        }