private void UpdatePlaylist(string host) { if (_lastUpdate + _maxAge < DateTime.Now) { _childItems.Clear(); var res = new TTVApi.TranslationList(TTVApi.FilterType.all).Run(_device.Proxy.SessionState.session); if (!res.IsSuccess) { while (!_device.Proxy.Login() || _device.Proxy.SessionState.Error == TTVApi.ApiError.noconnect) { } if (!_device.Proxy.SessionState.IsSuccess) { throw new Exception("No authorized"); } } foreach (var cat in res.categories) { ItemContainer container = new ItemContainer(this, _device) { Type = MediaType.Video, IconUrl = "RandomFromChild", Id = cat.id.ToString(), Title = cat.name, ParentId = ParentId + "_" + Id }; TTVApi.ChannelGroup cat1 = cat; foreach (var source in res.channels.Where(channel => channel.group == cat1.id)) { container.AddChild(new ItemStream(container, MediaType.Video, _device) { IconUrl = source.ObsaluteLogo, Id = source.id.ToString(), Title = source.name, ParentId = container.GetIds(), ContentUrl = String.Format("{0}/channels/play?id={1}", host, source.id) + (!string.IsNullOrEmpty(_device.UpnpSettings.Profile.Live.Info[0].TranscodingProfile) ? "&transcode=" + _device.UpnpSettings.Profile.Live.Info[0].TranscodingProfile : "") }); } AddChild(container); } _lastUpdate = DateTime.Now; } }
private void UpdatePlaylist(string host) { if (_lastUpdate + _maxAge < DateTime.Now) { _childItems.Clear(); var res = new TTVApi.TranslationList(TTVApi.FilterType.all).Run(_device.Proxy.SessionState.session); if (!res.IsSuccess) { while (!_device.Proxy.Login() || _device.Proxy.SessionState.Error == TTVApi.ApiError.noconnect) { } if (!_device.Proxy.SessionState.IsSuccess) throw new Exception("No authorized"); } foreach (var cat in res.categories) { ItemContainer container = new ItemContainer(this, _device) { Type = MediaType.Video, IconUrl = "RandomFromChild", Id = cat.id.ToString(), Title = cat.name, ParentId = ParentId + "_" + Id }; TTVApi.ChannelGroup cat1 = cat; foreach (var source in res.channels.Where(channel => channel.group == cat1.id)) { container.AddChild(new ItemStream(container, MediaType.Video, _device) { IconUrl = source.ObsaluteLogo, Id = source.id.ToString(), Title = source.name, ParentId = container.GetIds(), ContentUrl = String.Format("{0}/channels/play?id={1}", host, source.id) + (!string.IsNullOrEmpty(_device.UpnpSettings.Profile.Live.Info[0].TranscodingProfile) ? "&transcode=" + _device.UpnpSettings.Profile.Live.Info[0].TranscodingProfile : "") }); } AddChild(container); } _lastUpdate = DateTime.Now; } }