Ejemplo n.º 1
0
        private ProgramInfo GetProgram(string channelId, Program prog)
        {
            var info = new ProgramInfo()
            {
                /// Id of the program.
                Id = string.Format("{1}_{0}", ((DateTime)prog.StartTime).Ticks, channelId),

                /// Gets or sets the channel identifier.
                ChannelId = channelId,

                /// Name of the program
                Name = prog.Title,

                /// Gets or sets the official rating.
                // public OfficialRating { get; set; }

                /// Gets or sets the overview.
                Overview = prog.Description,

                /// Gets or sets the short overview.
                ShortOverview = null,

                /// The start date of the program, in UTC.
                StartDate = (DateTime)prog.StartTime,

                /// The end date of the program, in UTC.
                EndDate = (DateTime)prog.EndTime,

                /// Genre of the program.
                // public List<string> Genres { get; set; }

                /// Gets or sets the original air date.
                OriginalAirDate = prog.Airdate,

                /// Gets or sets a value indicating whether this instance is hd.
                IsHD = (prog.VideoProps & VideoFlags.VID_HDTV) == VideoFlags.VID_HDTV,

                Is3D = (prog.VideoProps & VideoFlags.VID_3DTV) == VideoFlags.VID_3DTV,

                /// Gets or sets the audio.
                Audio = ConvertAudioFlags(prog.AudioProps),     //Hardcode for now (ProgramAudio)item.AudioProps,

                /// Gets or sets the community rating.
                CommunityRating = prog.Stars,

                /// Gets or sets a value indicating whether this instance is repeat.
                IsRepeat = prog.Repeat,

                IsSubjectToBlackout = false,

                /// Gets or sets the episode title.
                EpisodeTitle = prog.SubTitle,

                /// Supply the image path if it can be accessed directly from the file system
                // public string ImagePath { get; set; }

                /// Supply the image url if it can be downloaded
                // public string ImageUrl { get; set; }

                // public string LogoImageUrl { get; set; }

                /// Gets or sets a value indicating whether this instance has image.
                // public bool? HasImage { get; set; }

                /// Gets or sets a value indicating whether this instance is movie.
                IsMovie = GeneralHelpers.ContainsWord(prog.CatType, "movie", StringComparison.OrdinalIgnoreCase),

                /// Gets or sets a value indicating whether this instance is sports.
                IsSports =
                    GeneralHelpers.ContainsWord(prog.Category, "sport",
                                                StringComparison.OrdinalIgnoreCase) ||
                    GeneralHelpers.ContainsWord(prog.Category, "motor sports",
                                                StringComparison.OrdinalIgnoreCase) ||
                    GeneralHelpers.ContainsWord(prog.Category, "football",
                                                StringComparison.OrdinalIgnoreCase) ||
                    GeneralHelpers.ContainsWord(prog.Category, "cricket",
                                                StringComparison.OrdinalIgnoreCase),

                /// Gets or sets a value indicating whether this instance is series.
                IsSeries = GeneralHelpers.ContainsWord(prog.CatType, "series", StringComparison.OrdinalIgnoreCase),

                /// Gets or sets a value indicating whether this instance is live.
                // public bool IsLive { get; set; }

                /// Gets or sets a value indicating whether this instance is news.
                IsNews = GeneralHelpers.ContainsWord(prog.Category, "news",
                                                     StringComparison.OrdinalIgnoreCase),

                /// Gets or sets a value indicating whether this instance is kids.
                IsKids = GeneralHelpers.ContainsWord(prog.Category, "animation",
                                                     StringComparison.OrdinalIgnoreCase),

                // public bool IsEducational { get; set; }

                /// Gets or sets a value indicating whether this instance is premiere.
                // public bool IsPremiere { get; set;  }

                /// Gets or sets the production year.
                // public int? ProductionYear { get; set; }

                /// Gets or sets the home page URL.
                // public string HomePageUrl { get; set; }

                /// Gets or sets the series identifier.
                SeriesId = prog.SeriesId,

                /// Gets or sets the show identifier.
                ShowId = prog.ProgramId,
            };

            if (prog.Season != null && prog.Season > 0 &&
                prog.Episode != null && prog.Episode > 0)
            {
                info.SeasonNumber  = prog.Season;
                info.EpisodeNumber = prog.Episode;
            }

            return(info);
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <ProgramInfo> > GetProgramsAsync(string channelId, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken)
        {
            _logger.Info("[MythTV] Start GetPrograms Async, retrieve programs for: {0}", channelId);
            EnsureSetup();
            List <ProgramInfo> ret = new List <ProgramInfo>();
            var options            = GetOptions(cancellationToken, "/Guide/GetProgramGuide?StartTime={0}&EndTime={1}&StartChanId={2}&NumChannels=1&Details=1", FormateMythDate(startDateUtc), FormateMythDate(endDateUtc), channelId);

            using (var stream = await _httpClient.Get(options).ConfigureAwait(false))
            {
                var data = GuideResponse.ParseGuide(stream, _jsonSerializer, _logger);

                foreach (var item in data.Channels)
                {
                    foreach (var prog in item.Programs)
                    {
                        List <string> categories = new List <string>();
                        categories.AddRange(prog.Category.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries));

                        ProgramInfo val = new ProgramInfo()
                        {
                            Name         = prog.Title,
                            EpisodeTitle = prog.SubTitle,
                            Overview     = prog.Description,
                            Audio        = ProgramAudio.Stereo, //Hardcode for now (ProgramAudio)item.AudioProps,
                            ChannelId    = item.ChanId.ToString(),
                            EndDate      = (DateTime)prog.EndTime,
                            StartDate    = (DateTime)prog.StartTime,
                            Id           = string.Format("StartTime={0}&ChanId={1}", ((DateTime)prog.StartTime).Ticks, item.ChanId),
                            IsSeries     = GeneralHelpers.ContainsWord(prog.CatType, "series", StringComparison.OrdinalIgnoreCase),
                            IsMovie      = GeneralHelpers.ContainsWord(prog.CatType, "movie", StringComparison.OrdinalIgnoreCase),
                            IsRepeat     = prog.Repeat,
                            IsNews       = GeneralHelpers.ContainsWord(prog.Category, "news",
                                                                       StringComparison.OrdinalIgnoreCase),
                            IsKids = GeneralHelpers.ContainsWord(prog.Category, "animation",
                                                                 StringComparison.OrdinalIgnoreCase),
                            IsSports =
                                GeneralHelpers.ContainsWord(prog.Category, "sport",
                                                            StringComparison.OrdinalIgnoreCase) ||
                                GeneralHelpers.ContainsWord(prog.Category, "motor sports",
                                                            StringComparison.OrdinalIgnoreCase) ||
                                GeneralHelpers.ContainsWord(prog.Category, "football",
                                                            StringComparison.OrdinalIgnoreCase) ||
                                GeneralHelpers.ContainsWord(prog.Category, "cricket",
                                                            StringComparison.OrdinalIgnoreCase)
                        };
                        val.Genres.AddRange(categories);
                        if (!string.IsNullOrWhiteSpace(item.IconURL))
                        {
                            val.HasImage = true;
                            val.ImageUrl = string.Format("{0}{1}", Plugin.Instance.Configuration.WebServiceUrl, item.IconURL);
                        }
                        else
                        {
                            val.HasImage = false;
                        }

                        ret.Add(val);
                    }
                }
            }

            return(ret);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the Programs async
        /// </summary>
        /// <param name="channelId"></param>
        /// <param name="startDateUtc"></param>
        /// <param name="endDateUtc"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <IEnumerable <ProgramInfo> > GetProgramsAsync(string channelId, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken)
        {
            _logger.Info(string.Format("[ArgusTV] Start GetPrograms Async, retrieve all programs for ChannelId: {0}", channelId));
            await EnsureConnectionAsync(cancellationToken);

            try
            {
                //We need the guideChannelId for the EPG 'Container'
                var guideChannelId = Proxies.SchedulerService.GetChannelById(Guid.Parse(channelId)).Result.GuideChannelId;

                if (guideChannelId == null)
                {
                    return(new List <ProgramInfo>());
                }
                var programs = Proxies.GuideService.GetChannelProgramsBetween(Guid.Parse(guideChannelId.ToString()), startDateUtc, endDateUtc).Result;

                var programList = new List <ProgramInfo>();

                foreach (var guideProgramSummary in programs)
                {
                    var program = new ProgramInfo
                    {
                        ChannelId  = channelId,
                        Id         = guideProgramSummary.GuideProgramId.ToString(),
                        Overview   = Proxies.GuideService.GetProgramById(guideProgramSummary.GuideProgramId).Result.Description,
                        StartDate  = guideProgramSummary.StartTimeUtc,
                        EndDate    = guideProgramSummary.StopTimeUtc,
                        IsHD       = (guideProgramSummary.Flags == GuideProgramFlags.HighDefinition),
                        IsRepeat   = guideProgramSummary.IsRepeat,
                        IsPremiere = guideProgramSummary.IsPremiere,
                        HasImage   = false, //TODO
                        //ImageUrl = , //TODO
                        //IsMovie = ,
                    };

                    if (!string.IsNullOrEmpty(guideProgramSummary.Title))
                    {
                        program.Name = guideProgramSummary.Title;
                    }
                    ;

                    if (!string.IsNullOrEmpty(guideProgramSummary.SubTitle))
                    {
                        program.EpisodeTitle = guideProgramSummary.SubTitle;
                    }
                    ;


                    if (!string.IsNullOrEmpty(guideProgramSummary.Category))
                    {
                        //We only have 1 category
                        program.Genres = new List <string>
                        {
                            guideProgramSummary.Category
                        };

                        program.IsSeries = GeneralHelpers.ContainsWord(guideProgramSummary.Category, "series",
                                                                       StringComparison.OrdinalIgnoreCase);
                        program.IsNews = GeneralHelpers.ContainsWord(guideProgramSummary.Category, "news",
                                                                     StringComparison.OrdinalIgnoreCase);
                        program.IsKids = GeneralHelpers.ContainsWord(guideProgramSummary.Category, "animation",
                                                                     StringComparison.OrdinalIgnoreCase);
                        program.IsSports =
                            GeneralHelpers.ContainsWord(guideProgramSummary.Category, "sport",
                                                        StringComparison.OrdinalIgnoreCase) ||
                            GeneralHelpers.ContainsWord(guideProgramSummary.Category, "motor sports",
                                                        StringComparison.OrdinalIgnoreCase) ||
                            GeneralHelpers.ContainsWord(guideProgramSummary.Category, "football",
                                                        StringComparison.OrdinalIgnoreCase) ||
                            GeneralHelpers.ContainsWord(guideProgramSummary.Category, "cricket",
                                                        StringComparison.OrdinalIgnoreCase);
                    }
                    programList.Add(program);
                }

                return(programList);
            }
            catch (Exception ex)
            {
                _logger.ErrorException("[ArgusTV] Get Programs Async failed", ex);
            }

            return(new List <ProgramInfo>());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the Recordings async
        /// </summary>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task{IEnumerable{RecordingInfo}}</returns>
        public async Task <IEnumerable <RecordingInfo> > GetRecordingsAsync(CancellationToken cancellationToken)
        {
            List <RecordingInfo> ret = new List <RecordingInfo>();

            _logger.Info("[MythTV] Start GetRecordings Async, retrieve all 'Pending', 'Inprogress' and 'Completed' recordings ");
            EnsureSetup();

            using (var stream = await _httpClient.Get(GetOptions(cancellationToken, "/Dvr/GetRecordedList")).ConfigureAwait(false))
            {
                var recordings = DvrResponse.ParseProgramList(stream, _jsonSerializer, _logger);

                foreach (var item in recordings.Programs)
                {
                    if (!Plugin.Instance.RecGroupExclude.Contains(item.Recording.RecGroup))
                    {
                        RecordingInfo val = new RecordingInfo()
                        {
                            Name          = item.Title,
                            EpisodeTitle  = item.SubTitle,
                            Overview      = item.Description,
                            Audio         = ProgramAudio.Stereo, //Hardcode for now (ProgramAudio)item.AudioProps,
                            ChannelId     = item.Channel.ChanId.ToString(),
                            ProgramId     = item.ProgramId,
                            SeriesTimerId = item.Recording.RecordId.ToString(),
                            EndDate       = (DateTime)item.EndTime,
                            StartDate     = (DateTime)item.StartTime,
                            Url           = string.Format("{0}{1}", Plugin.Instance.Configuration.WebServiceUrl, string.Format("/Content/GetFile?StorageGroup={0}&FileName={1}", item.Recording.StorageGroup, item.FileName)),
                            Id            = string.Format("StartTime={0}&ChanId={1}", ((DateTime)item.StartTime).Ticks, item.Channel.ChanId),
                            IsSeries      = GeneralHelpers.ContainsWord(item.CatType, "series", StringComparison.OrdinalIgnoreCase),
                            IsMovie       = GeneralHelpers.ContainsWord(item.CatType, "movie", StringComparison.OrdinalIgnoreCase),
                            IsRepeat      = item.Repeat,
                            IsNews        = GeneralHelpers.ContainsWord(item.Category, "news",
                                                                        StringComparison.OrdinalIgnoreCase),
                            IsKids = GeneralHelpers.ContainsWord(item.Category, "animation",
                                                                 StringComparison.OrdinalIgnoreCase),
                            IsSports =
                                GeneralHelpers.ContainsWord(item.Category, "sport",
                                                            StringComparison.OrdinalIgnoreCase) ||
                                GeneralHelpers.ContainsWord(item.Category, "motor sports",
                                                            StringComparison.OrdinalIgnoreCase) ||
                                GeneralHelpers.ContainsWord(item.Category, "football",
                                                            StringComparison.OrdinalIgnoreCase) ||
                                GeneralHelpers.ContainsWord(item.Category, "cricket",
                                                            StringComparison.OrdinalIgnoreCase)
                        };

                        if (Plugin.Instance.RecordingUncs.Count > 0)
                        {
                            foreach (string unc in Plugin.Instance.RecordingUncs)
                            {
                                string recPath = Path.Combine(unc, item.FileName);
                                if (File.Exists(recPath))
                                {
                                    val.Path = recPath;
                                    break;
                                }
                            }
                        }
                        val.Genres.AddRange(item.Category.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries));
                        if (item.Artwork.ArtworkInfos.Count() > 0)
                        {
                            val.HasImage = true;
                            val.ImageUrl = string.Format("{0}{1}", Plugin.Instance.Configuration.WebServiceUrl, item.Artwork.ArtworkInfos[0].URL);
                        }
                        else
                        {
                            val.HasImage = false;
                        }

                        ret.Add(val);
                    }
                }
            }

            return(ret);
        }
Ejemplo n.º 5
0
        private RecordingInfo ProgramToRecordingInfo(Program item, IFileSystem fileSystem)
        {
            RecordingInfo recInfo = new RecordingInfo()
            {
                Id              = item.Recording.RecordedId,
                SeriesTimerId   = item.Recording.RecordId,
                ChannelId       = item.Channel.ChanId,
                ChannelType     = ChannelType.TV,
                Name            = item.Title,
                Overview        = item.Description,
                StartDate       = item.StartTime,
                EndDate         = item.EndTime,
                ProgramId       = $"{item.Channel.ChanId}_{item.StartTime.Ticks}",
                Status          = RecStatusToRecordingStatus(item.Recording.Status),
                IsRepeat        = item.Repeat,
                IsHD            = (item.VideoProps & VideoFlags.VID_HDTV) == VideoFlags.VID_HDTV,
                Audio           = ProgramAudio.Stereo,
                OriginalAirDate = item.Airdate,
                IsMovie         = item.CatType == "movie",
                IsSports        = item.CatType == "sports" ||
                                  GeneralHelpers.ContainsWord(item.Category, "sport",
                                                              StringComparison.OrdinalIgnoreCase) ||
                                  GeneralHelpers.ContainsWord(item.Category, "motor sports",
                                                              StringComparison.OrdinalIgnoreCase) ||
                                  GeneralHelpers.ContainsWord(item.Category, "football",
                                                              StringComparison.OrdinalIgnoreCase) ||
                                  GeneralHelpers.ContainsWord(item.Category, "cricket",
                                                              StringComparison.OrdinalIgnoreCase),
                IsSeries = item.CatType == "series" || item.CatType == "tvshow",
                IsNews   = GeneralHelpers.ContainsWord(item.Category, "news",
                                                       StringComparison.OrdinalIgnoreCase),
                IsKids = GeneralHelpers.ContainsWord(item.Category, "animation",
                                                     StringComparison.OrdinalIgnoreCase),
                ShowId = item.ProgramId,
            };

            if (!string.IsNullOrEmpty(item.SubTitle))
            {
                recInfo.EpisodeTitle = item.SubTitle;
            }
            else if (item.Season != null && item.Episode != null && item.Season > 0 && item.Episode > 0)
            {
                recInfo.EpisodeTitle = string.Format("{0:D}x{1:D2}", item.Season, item.Episode);
            }
            else
            {
                recInfo.EpisodeTitle = item.Airdate.ToString("yyyy-MM-dd");
            }

            string recPath = Path.Combine(StorageGroups[item.Recording.StorageGroup].DirNameEmby, item.FileName);

            if (fileSystem.FileExists(recPath))
            {
                recInfo.Path = recPath;
            }
            else
            {
                recInfo.Url = string.Format("{0}/Content/GetFile?StorageGroup={1}&FileName={2}",
                                            Plugin.Instance.Configuration.WebServiceUrl,
                                            item.Recording.StorageGroup,
                                            item.FileName);
            }

            recInfo.Genres.AddRange(item.Category.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries));

            recInfo.HasImage = false;
            if (item.Artwork.ArtworkInfos.Count > 0)
            {
                var art = item.Artwork.ArtworkInfos.Where(i => i.Type.Equals("coverart"));
                if (art.Any())
                {
                    var url = item.Artwork.ArtworkInfos.Where(i => i.Type.Equals("coverart")).First().URL;
                    recInfo.ImageUrl = string.Format("{0}{1}",
                                                     Plugin.Instance.Configuration.WebServiceUrl,
                                                     url);
                    recInfo.HasImage = true;
                }
            }

            return(recInfo);
        }