public static IProgram ToProgram(this Mediaportal.TV.Server.TVDatabase.Entities.Program tvProgram, bool includeRecordingStatus = false)
        {
            if (tvProgram == null)
            {
                return(null);
            }
            Program program = new Program
            {
                ChannelId   = tvProgram.IdChannel,
                ProgramId   = tvProgram.IdProgram,
                Title       = tvProgram.Title,
                Description = tvProgram.Description,
                StartTime   = tvProgram.StartTime,
                EndTime     = tvProgram.EndTime,
                // TODO: Genre!
            };

            if (includeRecordingStatus)
            {
                ProgramBLL programLogic = new ProgramBLL(tvProgram);
                program.RecordingStatus = programLogic.IsRecording ? RecordingStatus.Recording : RecordingStatus.None;
                if (programLogic.IsRecordingOncePending)
                {
                    program.RecordingStatus |= RecordingStatus.Scheduled;
                }
                if (programLogic.IsRecordingSeriesPending)
                {
                    program.RecordingStatus |= RecordingStatus.SeriesScheduled;
                }
            }
            return(program);
        }
Beispiel #2
0
        protected virtual IProgram GetProgram(Mediaportal.TV.Server.TVDatabase.Entities.Program tvProgram, bool includeRecordingStatus = false)
#endif
        {
            InitGenreMap();

            //Convert to IProgram
            IProgram prog = tvProgram.ToProgram(includeRecordingStatus);

            if (prog == null)
            {
                return(null);
            }

            //Map genre color if possible
            if (_tvGenres.Count > 0 && !string.IsNullOrEmpty(prog.Genre))
            {
                var genre = _tvGenres.FirstOrDefault(g => g.Value.Any(e => prog.Genre.Equals(e, StringComparison.InvariantCultureIgnoreCase)));
                if (genre.Key != EpgGenre.Unknown)
                {
                    prog.EpgGenreId = (int)genre.Key;
                    switch (genre.Key)
                    {
                    case EpgGenre.Movie:
                        prog.EpgGenreColor = _epgColorSettings.MovieGenreColor;
                        break;

                    case EpgGenre.Series:
                        prog.EpgGenreColor = _epgColorSettings.SeriesGenreColor;
                        break;

                    case EpgGenre.Documentary:
                        prog.EpgGenreColor = _epgColorSettings.DocumentaryGenreColor;
                        break;

                    case EpgGenre.Music:
                        prog.EpgGenreColor = _epgColorSettings.MusicGenreColor;
                        break;

                    case EpgGenre.Kids:
                        prog.EpgGenreColor = _epgColorSettings.KidsGenreColor;
                        break;

                    case EpgGenre.News:
                        prog.EpgGenreColor = _epgColorSettings.NewsGenreColor;
                        break;

                    case EpgGenre.Sport:
                        prog.EpgGenreColor = _epgColorSettings.SportGenreColor;
                        break;

                    case EpgGenre.Special:
                        prog.EpgGenreColor = _epgColorSettings.SpecialGenreColor;
                        break;
                    }
                }
            }

            //If genre is unknown and the program contains series info, mark it as a series genre
            if (prog.EpgGenreId == (int)EpgGenre.Unknown &&
                (!string.IsNullOrWhiteSpace(tvProgram.SeriesNum) || !string.IsNullOrWhiteSpace(tvProgram.EpisodeNum) || !string.IsNullOrWhiteSpace(tvProgram.EpisodePart)))
            {
                prog.EpgGenreId    = (int)EpgGenre.Series;
                prog.EpgGenreColor = _epgColorSettings.SeriesGenreColor;
            }
            return(prog);
        }