public DateTime UpdateRecords(DateTime date, string host, int rec_id = 0) { if (_lastUpdate + _maxAge < DateTime.Now) { if (_childItems.Count == 0) { UpdateChannels(); } var ch = (ItemContainer)_childItems.Find(item => item.Id.Split("|".ToCharArray())[0] == rec_id.ToString()); if (date != DateTime.Today) { ch = GetContainterByDate(date, ch); } ch.ClearChild(); date = ((DateTime)ch.Tag).Date; var records = new TTVApi.ArcRecords(rec_id, date).Run(_device.Proxy.SessionState.session); if (!records.IsSuccess && records.Error == TTVApi.ApiError.incorrect) { while (!_device.Proxy.Login() || _device.Proxy.SessionState.Error == TTVApi.ApiError.noconnect) { } if (!_device.Proxy.SessionState.IsSuccess) { throw new Exception("No authorized"); } } if (!records.IsSuccess && records.Error == TTVApi.ApiError.norecord && date != DateTime.Today) { return(date); } var bufdate = date.AddDays(-1); ch.AddChild(new ItemContainer(ch, _device) { Type = MediaType.Video, IconUrl = ch.IconUrl, Id = rec_id + "|" + bufdate.ToShortDateString(), Title = bufdate.ToShortDateString(), ParentId = ParentId + "_" + Id, Tag = bufdate.AddTicks(1) }); foreach (var rec in records.records) { ItemStream itemrec = new ItemStream(ch, MediaType.Video, _device) { Type = MediaType.Video, IconUrl = ch.IconUrl, Id = rec.record_id.ToString(), Title = String.Format("[{0}]{1}", rec.Time.ToShortTimeString(), rec.name), ParentId = ch.GetIds(), Tag = rec.Time.AddSeconds(1), ContentUrl = String.Format("{0}/archive/play?id={1}", host, rec.record_id) }; ch.AddChild(itemrec); } } return(date); }
private Item GetItem(IPluginContent content, string host) { Item item; if (content is IPluginContainer) { item = new ItemContainer(null, _device) { Title = "[" + content.Title + "]" }; } else if (content.Translation == TranslationType.VoD) { item = new ItemVideo(null, _device) { Title = content.Title }; item.ContentUrl = host + "/" + _plugin.Id + "/play?id=" + content.Id; } else { item = new ItemStream(null, MediaType.Video, _device) { Title = content.Title, ContentUrl = string.IsNullOrEmpty(content.GetUrl(host)) ? string.Format("{0}/{1}/play?id={2}", host, Id, content.Id) : content.GetUrl(host) }; } item.ParentId = ParentId + "_" + Id; item.Id = item.ParentId + "_" + content.Id; if (!string.IsNullOrEmpty(content.Parent.Id)) { item.ParentId = item.ParentId + "_" + content.Parent.Id; } item.IconUrl = content.Icon; item.Type = MediaType.Video; return(item); }
private Item GetItem(IPluginContent content, string host) { Item item; if (content is IPluginContainer) { item = new ItemContainer(null, _device) {Title = "[" + content.Title + "]"}; } else if (content.Translation == TranslationType.VoD) { item = new ItemVideo(null, _device) {Title = content.Title}; item.ContentUrl = host + "/" + _plugin.Id + "/play?id=" + content.Id; } else { item = new ItemStream(null, MediaType.Video, _device) { Title = content.Title, ContentUrl = string.IsNullOrEmpty(content.GetUrl(host)) ? string.Format("{0}/{1}/play?id={2}", host, Id, content.Id) : content.GetUrl(host) }; } item.ParentId = ParentId + "_" + Id; item.Id = item.ParentId + "_" + content.Id; if (!string.IsNullOrEmpty(content.Parent.Id)) item.ParentId = item.ParentId + "_" + content.Parent.Id; item.IconUrl = content.Icon; item.Type = MediaType.Video; return item; }
public DateTime UpdateRecords(DateTime date, string host, int rec_id = 0) { if (_lastUpdate + _maxAge < DateTime.Now) { if (_childItems.Count == 0) UpdateChannels(); var ch = (ItemContainer)_childItems.Find(item => item.Id.Split("|".ToCharArray())[0] == rec_id.ToString()); if (date != DateTime.Today) { ch = GetContainterByDate(date, ch); } ch.ClearChild(); date = ((DateTime) ch.Tag).Date; var records = new TTVApi.ArcRecords(rec_id, date).Run(_device.Proxy.SessionState.session); if (!records.IsSuccess && records.Error == TTVApi.ApiError.incorrect) { while (!_device.Proxy.Login() || _device.Proxy.SessionState.Error == TTVApi.ApiError.noconnect) { } if (!_device.Proxy.SessionState.IsSuccess) throw new Exception("No authorized"); } if (!records.IsSuccess && records.Error == TTVApi.ApiError.norecord && date != DateTime.Today) return date; var bufdate = date.AddDays(-1); ch.AddChild(new ItemContainer(ch, _device) { Type = MediaType.Video, IconUrl = ch.IconUrl, Id = rec_id + "|" + bufdate.ToShortDateString(), Title = bufdate.ToShortDateString(), ParentId = ParentId + "_" + Id, Tag = bufdate.AddTicks(1) }); foreach (var rec in records.records) { ItemStream itemrec = new ItemStream(ch, MediaType.Video, _device) { Type = MediaType.Video, IconUrl = ch.IconUrl, Id = rec.record_id.ToString(), Title = String.Format("[{0}]{1}", rec.Time.ToShortTimeString(), rec.name), ParentId = ch.GetIds(), Tag = rec.Time.AddSeconds(1), ContentUrl = String.Format("{0}/archive/play?id={1}", host, rec.record_id) }; ch.AddChild(itemrec); } } return date; }