Ejemplo n.º 1
0
        /*
         * No arguments needed
         */
        public override void handleCommand(string command, string[] arguments, ref TvControl.IUser me)
        {
            TimeShiftURLs timeShiftURLs = TVServerConnection.getTimeshiftURLs(ref me);
            bool result = true;

            if (timeShiftURLs == null || String.IsNullOrEmpty(timeShiftURLs.RTSPUrl) || String.IsNullOrEmpty(timeShiftURLs.TimeShiftFileName))
            {
                timeShiftURLs = new TimeShiftURLs { RTSPUrl = "", TimeShiftFileName = "" };
                result = false;
            }

            // results = isShifting;url;chanInfo as in ListChannels
            // chanInfo must be the same as the listchannel..
            ChannelInfo c = new ChannelInfo();
            if (result)
            {
                c = TVServerConnection.getTimeshiftInfo(ref me);
            }

            writer.write(writer.makeItemSmart(result.ToString(), timeShiftURLs.RTSPUrl, timeShiftURLs.TimeShiftFileName, c));
        }
Ejemplo n.º 2
0
        public List<ChannelInfo> GetChannelInfosForGroup(string groupName)
        {
            List<ChannelInfo> refChannelInfos = new List<ChannelInfo>();
            try
            {
                IList<TvDatabase.ChannelGroup> tvgroups = ChannelGroup.ListAll();
                if (tvgroups != null)
                {
                    foreach (ChannelGroup group in tvgroups)
                    {
                        if (group.GroupName == groupName || groupName == "")
                        {
                            IList<GroupMap> maps = group.ReferringGroupMap();
                            TvDatabase.Program epg;
                            foreach (GroupMap map in maps)
                            {
                                ChannelInfo channelInfo = new ChannelInfo();
                                channelInfo.channelID = map.ReferencedChannel().IdChannel.ToString();
                                channelInfo.name = map.ReferencedChannel().DisplayName;
                                channelInfo.epgNow = new ProgrammInfo();

                                try
                                {
                                    epg = map.ReferencedChannel().CurrentProgram;
                                    if (epg != null)
                                    {
                                        channelInfo.epgNow.timeInfo = epg.StartTime.ToShortTimeString() + "-" + epg.EndTime.ToShortTimeString();
                                        channelInfo.epgNow.description = epg.Title;
                                    }
                                    epg = map.ReferencedChannel().NextProgram;
                                    channelInfo.epgNext = new ProgrammInfo();
                                    if (epg != null)
                                    {
                                        channelInfo.epgNext.timeInfo = epg.StartTime.ToShortTimeString() + "-" + epg.EndTime.ToShortTimeString();
                                        channelInfo.epgNext.description = epg.Title;
                                    }
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine("Error while obtaining the EPG for channel " + channelInfo.channelID + ": " + e.ToString());
                                    Log.Error("TVServerKodi: Error while obtaining the EPG for channel " + channelInfo.channelID + ": " + e.ToString());
                                }

                                //Get the tuning details
                                try
                                {
                                    IList<TuningDetail> listtuningdetails = map.ReferencedChannel().ReferringTuningDetail();
                                    foreach (TuningDetail tuningdetail in listtuningdetails)
                                    {
                                        channelInfo.isScrambled = !(tuningdetail.FreeToAir);
                                    }
                                }
                                catch
                                {
                                    channelInfo.isScrambled = false;
                                }

                                refChannelInfos.Add(channelInfo);
                            }
                            if (groupName != "")
                                break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                lastException = ex;
                Console.WriteLine(ex.ToString());
                Log.Error("TVServerKodi: " + ex.ToString());
                return null;
            }
            return refChannelInfos;
        }
Ejemplo n.º 3
0
        public List<ChannelInfo> getRadioChannels(string groupName)
        {
            List<ChannelInfo> radioChannels = new List<ChannelInfo>();
            try
            {
                if (groupName == "")
                {
                    TvDatabase.Program epg;

                    IList<Channel> channels = Channel.ListAll();
                    foreach (Channel chan in channels)
                    {
                        if (!chan.IsRadio)
                            continue;
                        ChannelInfo channelInfo = new ChannelInfo();
                        channelInfo.channelID = chan.IdChannel.ToString();
                        channelInfo.name = chan.DisplayName;
                        channelInfo.isWebStream = chan.IsWebstream();
                        epg = chan.CurrentProgram;
                        channelInfo.epgNow = new ProgrammInfo();
                        if (epg != null)
                        {
                            channelInfo.epgNow.timeInfo = epg.StartTime.ToShortTimeString() + "-" + epg.EndTime.ToShortTimeString();
                            channelInfo.epgNow.description = epg.Title;
                        }
                        epg = chan.NextProgram;
                        channelInfo.epgNext = new ProgrammInfo();
                        if (epg != null)
                        {
                            channelInfo.epgNext.timeInfo = epg.StartTime.ToShortTimeString() + "-" + epg.EndTime.ToShortTimeString();
                            channelInfo.epgNext.description = epg.Title;
                        }
                        radioChannels.Add(channelInfo);
                    }
                }
                else
                {
                    IList<TvDatabase.RadioChannelGroup> radiogroups = RadioChannelGroup.ListAll();
                    foreach (RadioChannelGroup group in radiogroups)
                    {
                        if (group.GroupName == groupName)
                        {
                            IList<RadioGroupMap> maps = group.ReferringRadioGroupMap();
                            TvDatabase.Program epg;
                            foreach (RadioGroupMap map in maps)
                            {
                                ChannelInfo channelInfo = new ChannelInfo();

                                if (map.ReferencedChannel() == null) continue;

                                channelInfo.channelID = map.ReferencedChannel().IdChannel.ToString();
                                channelInfo.name = map.ReferencedChannel().DisplayName;
                                epg = map.ReferencedChannel().CurrentProgram;
                                channelInfo.epgNow = new ProgrammInfo();
                                if (epg != null)
                                {
                                    channelInfo.epgNow.timeInfo = epg.StartTime.ToShortTimeString() + "-" + epg.EndTime.ToShortTimeString();
                                    channelInfo.epgNow.description = epg.Title;
                                }
                                epg = map.ReferencedChannel().NextProgram;
                                channelInfo.epgNext = new ProgrammInfo();
                                if (epg != null)
                                {
                                    channelInfo.epgNext.timeInfo = epg.StartTime.ToShortTimeString() + "-" + epg.EndTime.ToShortTimeString();
                                    channelInfo.epgNext.description = epg.Title;
                                }
                                radioChannels.Add(channelInfo);
                            }
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                lastException = ex;
                Console.WriteLine(ex.ToString());
                Log.Error("TVServerKodi: " + ex.ToString());
                return null;
            }
            return radioChannels;
        }
Ejemplo n.º 4
0
        public ChannelInfo GetChannelInfo(int chanId)
        {
            try
              {
            IList<Channel> channels = Channel.ListAll();
            foreach (Channel chan in channels)
            {
              if (chan.IdChannel == chanId)
              {
                // this is the channel we want
                ChannelInfo channelInfo = new ChannelInfo();
                TvDatabase.Program epg = null;

                channelInfo.channelID = chan.IdChannel.ToString();
                channelInfo.name = chan.DisplayName;
                channelInfo.isWebStream = chan.IsWebstream();
                channelInfo.epgNow = new ProgrammInfo();
                channelInfo.epgNext = new ProgrammInfo();

                try
                {
                  epg = chan.CurrentProgram;
                  if (epg != null)
                  {
                    channelInfo.epgNow.timeInfo = epg.StartTime.ToShortTimeString() + "-" + epg.EndTime.ToShortTimeString();
                    channelInfo.epgNow.description = epg.Title;
                  }
                  epg = chan.NextProgram;
                  if (epg != null)
                  {
                    channelInfo.epgNext.timeInfo = epg.StartTime.ToShortTimeString() + "-" + epg.EndTime.ToShortTimeString();
                    channelInfo.epgNext.description = epg.Title;
                  }
                }
                catch { }

                return channelInfo;
              }
            }
              }
              catch (Exception ex)
              {
            Log.Error("TVServerKodi: An exception occurred in GetChannelInfo(): " + ex.Message);
              }
              return null;
        }