示例#1
0
文件: Item.cs 项目: northspb/p2pproxy
 protected Item(ItemContainer parent, P2pProxyDevice device)
 {
     Title = "Unknown";
     Id = "0";
     ParentId = "0";
     IconUrl = null;
     this.parent = parent;
     _device = device;
 }
示例#2
0
文件: Item.cs 项目: northspb/p2pproxy
 public ItemStream(ItemContainer parent, MediaType type, P2pProxyDevice device, string file_ext = ".m2ts") : base(parent, device)
 {
     Type = type;
     _info = device.UpnpSettings.Profile.Live.Info.FirstOrDefault(info => info.FileExt.Equals(file_ext, StringComparison.OrdinalIgnoreCase)) ??
             device.UpnpSettings.Profile.Live.Info[0];
 }
示例#3
0
文件: Item.cs 项目: northspb/p2pproxy
        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;

        }
示例#4
0
文件: Item.cs 项目: northspb/p2pproxy
 public ItemContainer(ItemContainer parent, P2pProxyDevice device) : base(parent, device)
 {
     _childItems = new List<Item>();
 }
示例#5
0
文件: Item.cs 项目: northspb/p2pproxy
 public PluginContainer(ItemContainer parent, P2pProxyDevice device, IPluginProxy plugin) : base(parent, device)
 {
     _plugin = plugin;
     Id = _plugin.Id;
     Title = _plugin.Name;
     if (parent != null)
         ParentId = parent.GetIds();
     Type = MediaType.Video;
 }
示例#6
0
文件: Item.cs 项目: northspb/p2pproxy
 public RecordItemContainer(ItemContainer parent, P2pProxyDevice device) : base(parent, device)
 {
     Id = "records";
     Title = "Локальные записи";
     Type = MediaType.Video;
 }
示例#7
0
文件: Item.cs 项目: northspb/p2pproxy
        public void UpdateChannels()
        {
            if (_lastUpdate + _maxAge < DateTime.Now)
            {
                _childItems.Clear();
                var channels = new TTVApi.ArcList().Run(_device.Proxy.SessionState.session);
                if (!channels.IsSuccess)
                {
                    while (!_device.Proxy.Login() || _device.Proxy.SessionState.Error == TTVApi.ApiError.noconnect)
                    {

                    }
                    if (!_device.Proxy.SessionState.IsSuccess)
                        throw new Exception("No authorized");
                }
                foreach (var channel in channels.channels)
                {
                    ItemContainer container = new ItemContainer(this, _device)
                        {
                            Type = MediaType.Video,
                            IconUrl = channel.ObsaluteLogo,
                            Id = channel.epg_id + "|" + DateTime.Today.ToShortDateString(),
                            Title = channel.name,
                            ParentId = ParentId + "_" + Id,
                            Tag = DateTime.Today.AddTicks(2)
                        };
                    AddChild(container);
                }
            }
        }
示例#8
0
文件: Item.cs 项目: northspb/p2pproxy
 private ItemContainer GetContainterByDate(DateTime date, ItemContainer container)
 {  
     if (container.Count() == 0 || date == DateTime.Today)
         return container;
     ItemContainer ch = (ItemContainer)container.GetChild(0);
     TimeSpan ts = DateTime.Today - date;
     for (int i = 0; i < ts.Days - 1 && ch.Count() > 0; i++)
     {
         ch = (ItemContainer) ch.GetChild(0);
     }
     return ch;
 }
示例#9
0
文件: Item.cs 项目: northspb/p2pproxy
 public ArchiveItemContainer(ItemContainer parent, P2pProxyDevice device) : base(parent, device)
 {
     Type = MediaType.Video;
     _childItems = new List<Item>();
     IconUrl = "";
     Id = "archives";
     Title = "Архив";
     ParentId = parent.GetIds();
     this.parent = parent;
     
 }
示例#10
0
文件: Item.cs 项目: northspb/p2pproxy
        public ItemRootContainer(ItemContainer parent, P2pProxyDevice device) : base(parent, device)
        {
            Title = "Root";
            Id = "0";
            ParentId = "0";
            _childItems.Add(new ChannelItemContainer(this, device));
            _childItems.Add(new ArchiveItemContainer(this, device));
            _childItems.Add(new RecordItemContainer(this, device));

            var plugs = _device.PluginProvider.GetPlugins();
            foreach (var plug in plugs)
            {
                try
                {
                    if (plug.GetContent(null) != null)
                        _childItems.Add(new PluginContainer(this, device, plug));
                }
                catch (Exception e)
                {
                    P2pProxyApp.Log.Write(e.Message, TypeMessage.Error);
                }
            }
        }
示例#11
0
文件: Item.cs 项目: northspb/p2pproxy
 public BlockItemContainer(ItemContainer parent, P2pProxyDevice device) : base(parent, device)
 {
     Title = "Доступно только в полной версии";
     Id = "block";
     ParentId = "0";
     _childItems.Add(this);
 }
示例#12
0
文件: Item.cs 项目: northspb/p2pproxy
        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;
            }
        }
示例#13
0
文件: Item.cs 项目: northspb/p2pproxy
 public ChannelItemContainer(ItemContainer parent, P2pProxyDevice device) : base(parent, device)
 {
     Type = MediaType.Video;
     _childItems = new List<Item>();
     IconUrl = "";
     Id = "channels";
     Title = "Каналы";
     ParentId = parent.GetIds();
     this.parent = parent;
 }
示例#14
0
 public ItemStream(ItemContainer parent, MediaType type, P2pProxyDevice device, string file_ext = ".m2ts") : base(parent, device)
 {
     Type  = type;
     _info = device.UpnpSettings.Profile.Live.Info.FirstOrDefault(info => info.FileExt.Equals(file_ext, StringComparison.OrdinalIgnoreCase)) ??
             device.UpnpSettings.Profile.Live.Info[0];
 }
示例#15
0
 public ItemContainer(ItemContainer parent, P2pProxyDevice device) : base(parent, device)
 {
     _childItems = new List <Item>();
 }
示例#16
0
 public RecordItemContainer(ItemContainer parent, P2pProxyDevice device) : base(parent, device)
 {
     Id    = "records";
     Title = "Локальные записи";
     Type  = MediaType.Video;
 }