Exemplo n.º 1
0
        public TVGuideViewModel(IEnumerable <WebChannelGroup> groups, WebChannelGroup channelGroup, DateTime guideStart, DateTime guideEnd)
        {
            this.groups = groups;

            GuideStart   = guideStart;
            GuideEnd     = guideEnd;
            HasDateSplit = GuideStart.Date != GuideEnd.Date && !(GuideEnd.Hour == 0 && GuideEnd.Minute == 0);
            if (!HasDateSplit)
            {
                FirstDayHours  = (GuideEnd - GuideStart).Hours + ((double)(GuideEnd - GuideStart).Minutes / 60);
                SecondDayHours = 0;
            }
            else
            {
                FirstDayHours  = (24 - GuideStart.Hour) - ((double)GuideStart.Minute / 60);
                SecondDayHours = GuideEnd.Hour + ((double)GuideEnd.Minute / 60);
            }


            GroupId   = channelGroup.Id;
            GroupName = channelGroup.GroupName;

            DateTime loadGuideEnd = guideEnd.Subtract(TimeSpan.FromSeconds(1)); // do not load programs that start at the end of the guid

            Channels = Connections.Current.TAS.GetChannelsDetailed(channelGroup.Id).Select(x => new TVGuideChannelViewModel(x, guideStart, loadGuideEnd));
        }
Exemplo n.º 2
0
        public static RadioChannelGroup ToRadioChannelGroup(this WebChannelGroup group)
        {
            if (group == null)
            {
                return(null);
            }

            return(RadioChannelGroup.Retrieve(group.Id));
        }
Exemplo n.º 3
0
        public TVGuideViewModel(IEnumerable <WebChannelGroup> groups, WebChannelGroup channelGroup, DateTime guideStart, DateTime guideEnd)
        {
            this.groups = groups;

            GuideStart = guideStart;
            GuideEnd   = guideEnd;

            GroupId   = channelGroup.Id;
            GroupName = channelGroup.GroupName;

            DateTime loadGuideEnd = guideEnd.Subtract(TimeSpan.FromSeconds(1)); // do not load programs that start at the end of the guid

            Channels = MPEServices.TAS.GetChannelsBasic(channelGroup.Id).Select(x => new TVGuideChannelViewModel(x, guideStart, loadGuideEnd));
        }
Exemplo n.º 4
0
        internal static WebChannelGroup ChannelGroup(IChannelGroup group)
        {
            WebChannelGroup webChannelGroup = new WebChannelGroup
            {
                GroupName = @group.Name,
                Id        = @group.ChannelGroupId,
                IsRadio   = @group.MediaType == MediaType.Radio,
                IsTv      = @group.MediaType == MediaType.TV,
                SortOrder = @group.SortOrder,
                IsChanged = true,
            };

            //webChannelGroup.IsChanged;

            return(webChannelGroup);
        }
Exemplo n.º 5
0
        public static async Task <WebChannelGroup> ProcessAsync(IOwinContext context, string groupId)
        {
            if (!ServiceRegistration.IsRegistered <ITvProvider>())
            {
                throw new BadRequestException("GetRadioGroupById: ITvProvider not found");
            }

            // select the channel Group we are looking for
            var group = await TVAccess.GetGroupAsync(context, int.Parse(groupId));

            if (group == null)
            {
                throw new NotFoundException(string.Format("GetRadioGroupById: group with id: {0} not found", groupId));
            }

            WebChannelGroup webChannelGroup = ChannelGroup(group);

            return(webChannelGroup);
        }
Exemplo n.º 6
0
        public override List <VideoInfo> GetVideos(Category category)
        {
            RssLink          cat        = category as RssLink;
            List <VideoInfo> returnList = new List <VideoInfo>();

            if (cat.Url.Equals("movies"))
            {
                WebBackendProvider provider = (WebBackendProvider)cat.Other;

                if (provider != null)
                {
                    WebMovieBasic[] movies = mediaAccess.GetMoviesBasic(provider.Id, true, null, MpExtendedService.WebSortField.Title, true, MpExtendedService.WebSortOrder.Asc, true);

                    foreach (WebMovieBasic m in movies)
                    {
                        VideoInfo info = new VideoInfo();
                        info.VideoUrl = m.Id;
                        if (m.Artwork.Any(a => a.Type == MpExtendedService.WebFileType.Cover))
                        {
                            info.Thumb = String.Format("http://{0}:{1}/MPExtended/StreamingService/stream/GetArtworkResized?id={2}&provider={3}&artworktype=4&offset=0&mediatype=0&maxWidth=160&maxHeight=160", mServer, mPort, m.Id, m.PID);
                        }
                        info.Other       = m;
                        info.Title       = m.Title;
                        info.Length      = new DateTime(TimeSpan.FromMinutes(m.Runtime).Ticks).ToString("HH:mm:ss");
                        info.Airdate     = m.Year.ToString();
                        info.Description =
                            (m.Genres != null && m.Genres.Length > 0 ? string.Format("\n{0}: {1}", Translation.Instance.Genre, string.Join(", ", m.Genres)) : "") +
                            (m.Actors != null && m.Actors.Length > 0 ? string.Format("\n{0}: {1}", Translation.Instance.Actors, string.Join(", ", m.Actors.Take(4).Select(a => a.Title).ToArray())) : "");
                        returnList.Add(info);
                    }
                }
            }
            else if (cat.Url.Equals("tvseason"))
            {
                WebTVSeasonDetailed season = (WebTVSeasonDetailed)cat.Other;

                if (season != null)
                {
                    WebTVEpisodeBasic[] episodes = mediaAccess.GetTVEpisodesBasicForSeason(season.PID, true, season.Id, MpExtendedService.WebSortField.TVEpisodeNumber, true, MpExtendedService.WebSortOrder.Asc, true);

                    foreach (WebTVEpisodeBasic e in episodes)
                    {
                        VideoInfo info = new VideoInfo();
                        info.VideoUrl = e.Id;
                        if (e.Artwork.Any(a => a.Type == MpExtendedService.WebFileType.Banner))
                        {
                            info.Thumb = String.Format("http://{0}:{1}/MPExtended/StreamingService/stream/GetArtworkResized?id={2}&provider={3}&artworktype=2&offset=0&mediatype=3&maxWidth=160&maxHeight=160", mServer, mPort, e.Id, e.PID);
                        }
                        if (e.RatingSpecified && e.Rating > 0.0f)
                        {
                            info.Description = string.Format("Rating: {0}", e.Rating);
                        }
                        info.Other   = e;
                        info.Title   = string.Format("s{0:D2}e{1:D2} - {2}", e.SeasonNumber, e.EpisodeNumber, e.Title);
                        info.Airdate = e.FirstAired.ToString("d", OnlineVideoSettings.Instance.Locale);

                        returnList.Add(info);
                    }
                }
            }
            else if (cat.Url.Equals("tvgroup"))
            {
                WebChannelGroup group = (WebChannelGroup)cat.Other;

                if (group != null)
                {
                    WebChannelDetailed[] channels = tvAccess.GetChannelsDetailed(group.Id, true, MpExtendedTvService.WebSortField.Channel, true, MpExtendedTvService.WebSortOrder.Asc, true);

                    foreach (var c in channels)
                    {
                        VideoInfo info = new VideoInfo();
                        info.VideoUrl = c.Id.ToString();
                        info.Other    = c;
                        info.Title    = string.Format("{0}{1}", c.Title, c.CurrentProgram != null ? " --- " + c.CurrentProgram.Title : "");
                        if (c.CurrentProgram != null)
                        {
                            info.Airdate     = string.Format("{0:t} - {1:t}", c.CurrentProgram.StartTime, c.CurrentProgram.EndTime);
                            info.Description = c.CurrentProgram.Description;
                            info.Length      = (c.CurrentProgram.DurationInMinutes * 60).ToString();
                        }
                        info.Thumb = String.Format("http://{0}:{1}/MPExtended/StreamingService/stream/GetArtworkResized?id={2}&artworktype={3}&offset=0&mediatype={4}&maxWidth=160&maxHeight=160", mServer, mPort, c.Id, (int)MpExtendedStreamingService.WebFileType.Logo, (int)MpExtendedStreamingService.WebMediaType.TV);
                        returnList.Add(info);
                    }
                }
            }
            return(returnList);
        }