예제 #1
0
        //
        // GET: /UAAP/

        public ActionResult Index()
        {
            if (!Request.Cookies.AllKeys.Contains("version"))
                return View("Index3");

            var profiler = MiniProfiler.Current;
            var context = new IPTV2Entities();
            ViewBag.CoverItLiveAltCastCode = GlobalConfig.UAAPCoverItLiveAltCastCode;
            var registDt = DateTime.Now;
            ViewBag.HasActiveSubscriptionBasedOnCategoryId = new CheckSubscriptionReturnObject() { HasSubscription = false, Within5DaysOrLess = false };
            if (User.Identity.IsAuthenticated)
            {
                System.Guid userId = new System.Guid(HttpContext.User.Identity.Name);
                var user = context.Users.FirstOrDefault(u => u.UserId == userId);
                ViewBag.HasActiveSubscriptionBasedOnCategoryId = ContextHelper.HasActiveSubscriptionBasedOnCategoryId(user, GlobalConfig.UAAPMainCategoryId, registDt);
            }
            List<Episode> latestEpisodes = null;
            var cache = DataCache.Cache;
            string cacheKey = "UAAPLatestGame";
            latestEpisodes = (List<Episode>)cache[cacheKey];

            if (latestEpisodes == null)
            {
                latestEpisodes = new List<Episode>();
                var service = context.Offerings.Find(GlobalConfig.offeringId).Services.FirstOrDefault(s => s.PackageId == GlobalConfig.serviceId);
                var cats = (Category)context.CategoryClasses.Find(GlobalConfig.UAAPGamesParentId);
                var listOfShows = service.GetAllOnlineShowIds(GlobalConfig.DefaultCountry, cats);
                var episodeids = context.EpisodeCategories1.Where(e => listOfShows.Contains(e.CategoryId)).Select(e => e.EpisodeId);
                var episodes = context.Episodes.Where(e => episodeids.Contains(e.EpisodeId) && e.OnlineStatusId == GlobalConfig.Visible && e.OnlineStartDate < registDt && e.OnlineEndDate > registDt).OrderByDescending(e => e.DateAired).ThenBy(e => e.AuditTrail.CreatedOn).Take(4);
                foreach (var e in episodes)
                {
                    Episode ep = new Episode() { EpisodeCode = e.EpisodeCode, EpisodeId = e.EpisodeId, EpisodeName = e.EpisodeName, Description = e.Description, DateAired = e.DateAired, ImageAssets = e.ImageAssets };
                    latestEpisodes.Add(ep);
                }
                cache.Put(cacheKey, latestEpisodes, DataCache.CacheDuration);

            }
            string countryCode = MyUtility.GetCurrentCountryCodeOrDefault();
            ViewBag.CountryCode = countryCode;
            ViewBag.LatestGameImage1 = GlobalConfig.EpisodeImgPath + latestEpisodes[0].EpisodeId.ToString() + "/" + latestEpisodes[0].ImageAssets.ImageVideo.ToString();
            ViewBag.LatestGameID1 = latestEpisodes[0].EpisodeId.ToString();
            ViewBag.LatestGameDescription1 = latestEpisodes[0].EpisodeName.ToString();
            ViewBag.LatestGameAirDate1 = ((DateTime)latestEpisodes[0].DateAired).ToString("MMM d, yyyy");
            ViewBag.LatestGameImage2 = GlobalConfig.EpisodeImgPath + latestEpisodes[1].EpisodeId.ToString() + "/" + latestEpisodes[1].ImageAssets.ImageVideo.ToString();
            ViewBag.LatestGameImage3 = GlobalConfig.EpisodeImgPath + latestEpisodes[2].EpisodeId.ToString() + "/" + latestEpisodes[2].ImageAssets.ImageVideo.ToString();
            ViewBag.LatestGameImage4 = GlobalConfig.EpisodeImgPath + latestEpisodes[3].EpisodeId.ToString() + "/" + latestEpisodes[3].ImageAssets.ImageVideo.ToString();
            ViewBag.LatestGameID2 = latestEpisodes[1].EpisodeId.ToString();
            ViewBag.LatestGameID3 = latestEpisodes[2].EpisodeId.ToString();
            ViewBag.LatestGameID4 = latestEpisodes[3].EpisodeId.ToString();
            return View();
        }
예제 #2
0
        public static bool CheckUser_Entitlement(Episode model)
        {
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
            {
                return false;
            }
            else
            {
                using (IPTV2Entities context = new IPTV2Entities())
                {
                    Guid userID = new Guid(HttpContext.Current.User.Identity.Name);
                    var user = context.Users.FirstOrDefault(u => u.UserId == userID);
                    var off = context.Offerings.Find(GlobalConfig.offeringId);

                    if (user.IsEpisodeEntitled(off, model, model.PremiumAssets.FirstOrDefault().Asset, RightsType.Online))
                    {
                        return true;
                    }
                }
            }
            return false;
        }
예제 #3
0
        private Dictionary<string, object> ProcessPreviewAssetFIX(Episode episode, int p, int q)
        {
            Dictionary<string, object> collection = new Dictionary<string, object>();
            ErrorCodes errorCode = ErrorCodes.UnknownError;
            string errorMessage = String.Empty;
            AkamaiFlowPlayerPluginClipDetails clipDetails = null;
            try
            {
                var previewAsset = episode.PreviewAssets.LastOrDefault();
                if (previewAsset != null)
                {
                    Asset asset = previewAsset.Asset;
                    if (asset != null)
                    {
                        int assetId = asset == null ? 0 : asset.AssetId;
                        if (episode.IsLiveChannelActive == true) //isLiveEvent
                        {
                            if (!ContextHelper.DoesEpisodeHaveIosCdnReferenceBasedOAsset(previewAsset))
                            {
                                if (Request.Browser.IsMobileDevice)
                                {
                                    errorCode = ErrorCodes.IsNotAvailableOnMobileDevices;
                                    collection = MyUtility.setError(errorCode, "Live event not available on mobile.");
                                    return collection;
                                }
                            }
                            clipDetails = Helpers.Akamai.GetAkamaiLiveEventClipDetails(episode.EpisodeId, assetId, Request, User, true);

                            ///**ADDED PREVIEW VIDEO (VOD) for Livestream**/
                            //VideoQualityCdnReference quality = q == 0 ? VideoQualityCdnReference.StandardDefinition : VideoQualityCdnReference.HighDefinition;
                            //if (p > 0 && p != 3)
                            //{
                            //    var progressive = p == 1 ? Progressive.Low : Progressive.High;
                            //    if (GlobalConfig.UseProgressiveViaAdaptiveTechnology)
                            //        clipDetails = Helpers.Akamai.GetAkamaiProgressiveViaAdaptiveClipDetails(episode.EpisodeId, assetId, Request, User, progressive, quality);
                            //    else
                            //    {
                            //        if (GlobalConfig.CheckForEpisodesToMakeUseOfProgessiveViaAdaptiveTechnology)
                            //        {
                            //            if (!String.IsNullOrEmpty(GlobalConfig.EpisodeIdsToMakeUseOfProgressiveViaAdaptiveTechnology))
                            //            {
                            //                var listOfEpisodeIds = MyUtility.StringToIntList(GlobalConfig.EpisodeIdsToMakeUseOfProgressiveViaAdaptiveTechnology);
                            //                if (listOfEpisodeIds.Contains(episode.EpisodeId))
                            //                    clipDetails = Helpers.Akamai.GetAkamaiProgressiveViaAdaptiveClipDetails(episode.EpisodeId, assetId, Request, User, progressive, quality);
                            //                else
                            //                    clipDetails = Helpers.Akamai.GetAkamaiProgressiveClipDetails(episode.EpisodeId, assetId, Request, User, progressive, quality);
                            //            }
                            //            else
                            //                clipDetails = Helpers.Akamai.GetAkamaiProgressiveClipDetails(episode.EpisodeId, assetId, Request, User, progressive, quality);
                            //        }
                            //        else
                            //            clipDetails = Helpers.Akamai.GetAkamaiProgressiveClipDetails(episode.EpisodeId, assetId, Request, User, progressive, quality);
                            //    }
                            //}
                            //else if (p == 3)
                            //{
                            //    clipDetails = Helpers.Akamai.GetAkamaiClipDetailsHD(episode.EpisodeId, assetId, Request, User);
                            //    if (clipDetails != null)
                            //        if (String.IsNullOrEmpty(clipDetails.Url))
                            //            clipDetails = Helpers.Akamai.GetAkamaiClipDetails(episode.EpisodeId, assetId, Request, User, quality);
                            //}
                            //else
                            //    clipDetails = Helpers.Akamai.GetAkamaiClipDetails(episode.EpisodeId, assetId, Request, User, quality);
                            ///** END **/

                        }
                        else
                        {
                            VideoQualityCdnReference quality = q == 0 ? VideoQualityCdnReference.StandardDefinition : VideoQualityCdnReference.HighDefinition;
                            if (p > 0 && p != 3)
                            {
                                var progressive = p == 1 ? Progressive.Low : Progressive.High;
                                if (GlobalConfig.UseProgressiveViaAdaptiveTechnology)
                                    clipDetails = Helpers.Akamai.GetAkamaiProgressiveViaAdaptiveClipDetails(episode.EpisodeId, assetId, Request, User, progressive, quality);
                                else
                                {
                                    if (GlobalConfig.CheckForEpisodesToMakeUseOfProgessiveViaAdaptiveTechnology)
                                    {
                                        if (!String.IsNullOrEmpty(GlobalConfig.EpisodeIdsToMakeUseOfProgressiveViaAdaptiveTechnology))
                                        {
                                            var listOfEpisodeIds = MyUtility.StringToIntList(GlobalConfig.EpisodeIdsToMakeUseOfProgressiveViaAdaptiveTechnology);
                                            if (listOfEpisodeIds.Contains(episode.EpisodeId))
                                                clipDetails = Helpers.Akamai.GetAkamaiProgressiveViaAdaptiveClipDetails(episode.EpisodeId, assetId, Request, User, progressive, quality);
                                            else
                                                clipDetails = Helpers.Akamai.GetAkamaiProgressiveClipDetailsFIX(episode.EpisodeId, assetId, Request, User, progressive, quality);
                                        }
                                        else
                                            clipDetails = Helpers.Akamai.GetAkamaiProgressiveClipDetailsFIX(episode.EpisodeId, assetId, Request, User, progressive, quality);
                                    }
                                    else
                                        clipDetails = Helpers.Akamai.GetAkamaiProgressiveClipDetailsFIX(episode.EpisodeId, assetId, Request, User, progressive, quality);
                                }
                            }
                            else if (p == 3)
                            {
                                clipDetails = Helpers.Akamai.GetAkamaiClipDetailsHDFIX(episode.EpisodeId, assetId, Request, User);
                                if (clipDetails != null)
                                    if (String.IsNullOrEmpty(clipDetails.Url))
                                        clipDetails = Helpers.Akamai.GetAkamaiClipDetailsFIX(episode.EpisodeId, assetId, Request, User, quality);
                            }
                            else
                                clipDetails = Helpers.Akamai.GetAkamaiClipDetailsFIX(episode.EpisodeId, assetId, Request, User, quality);

                        }
                    }
                }
                if (!String.IsNullOrEmpty(clipDetails.Url))
                {
                    errorCode = ErrorCodes.Success;
                    collection = MyUtility.setError(errorCode, clipDetails.Url);
                    collection.Add("data", clipDetails);
                }
                else
                {
                    errorCode = ErrorCodes.VideoNotFound;
                    collection = MyUtility.setError(errorCode, "Media not found.");
                }
            }
            catch (Exception) { }
            return collection;
        }
예제 #4
0
 private bool IsEpisodePartOfTheExclusiveFeature(IPTV2Entities context, Episode episode)
 {
     var feature = context.Features.Find(GlobalConfig.UAAPExclusiveFeaturesId);
     var listOfFeatureIds = episode.EpisodeFeatureItems.Select(e => e.FeatureId);
     var featureItemsOfFeature = feature.FeatureItems.Select(f => f.FeatureId);
     return listOfFeatureIds.Intersect(featureItemsOfFeature).Any();
 }
예제 #5
0
 public static bool DoesEpisodeHaveIosCdnReferenceBasedOnAsset(Episode episode)
 {
     try
     {
         //var premiumAsset = episode.PremiumAssets.FirstOrDefault();
         var premiumAsset = episode.PremiumAssets.LastOrDefault();
         if (premiumAsset != null)
         {
             var asset = premiumAsset.Asset;
             return asset.AssetCdns.Count(a => a.CdnId == 5) > 0;
         }
     }
     catch (Exception) { }
     return false;
 }
예제 #6
0
        public static bool CanPlayVideo(IPTV2Entities context, Offering offering, Episode episode, Asset asset, System.Security.Principal.IPrincipal thisUser, HttpRequestBase req)
        {
            bool IsUserEntitled = false;

            var profiler = MiniProfiler.Current;

            using (profiler.Step("ContextHelper.CanPlayVideo"))
            {
                string CountryCode = GlobalConfig.DefaultCountry;
                try
                {
                    CountryCode = MyUtility.getCountry(req.GetUserHostAddressFromCloudflare()).getCode();
                }
                catch (Exception) { }

                var packageId = GlobalConfig.AnonymousDefaultPackageId;

                if (!IsUserEntitled)
                    IsUserEntitled = User.IsAssetEntitled(context, offering.OfferingId, packageId, episode.EpisodeId, asset.AssetId, CountryCode, RightsType.Online);
                else
                    IsUserEntitled = true;

                // check user's access rights
                if (!IsUserEntitled && thisUser.Identity.IsAuthenticated)
                {
                    var user = context.Users.FirstOrDefault(u => u.UserId == new System.Guid(thisUser.Identity.Name));
                    if (user != null)
                    {
                        // check access from default logged in user package
                        packageId = GlobalConfig.LoggedInDefaultPackageId;
                        IsUserEntitled = User.IsAssetEntitled(context, offering.OfferingId, packageId, episode.EpisodeId, asset.AssetId, user.CountryCode, RightsType.Online);

                        if (!IsUserEntitled)
                        {
                            if (GlobalConfig.IsTVERegionBlockingEnabled)
                            {
                                var userCountryCode = MyUtility.GetCountryCodeViaIp();
                                int GomsSubsidiaryId = 0;
                                if (GlobalConfig.UseGomsSubsidiaryForTVECheck)
                                    GomsSubsidiaryId = ContextHelper.GetGomsSubsidiaryIdOfCountry(context, userCountryCode);
                                else
                                    GomsSubsidiaryId = -1;
                                //var GomsSubsidiaryId = ContextHelper.GetGomsSubsidiaryIdOfCountry(context, userCountryCode);
                                //IsUserEntitled = user.CanPlayVideo(offering, episode, asset, RightsType.Online); // check if user has entitlements that can play the video
                                var IncludePackageIds = MyUtility.StringToIntList(GlobalConfig.CanPlayIncludedPackageIds);
                                var ExcludePackageIds = MyUtility.StringToIntList(GlobalConfig.CanPlayExcludedPackageIds);
                                IsUserEntitled = user.CanPlayVideo(offering, episode, asset, RightsType.Online, ExcludePackageIds, IncludePackageIds, userCountryCode, GomsSubsidiaryId);
                                if (GlobalConfig.IsTVEIpCheckEnabled)
                                {
                                    try
                                    {
                                        string ip = GlobalConfig.IpWhiteList;
                                        string[] IpAddresses = ip.Split(';');
                                        if (IpAddresses.Contains(req.GetUserHostAddressFromCloudflare()))
                                            IsUserEntitled = user.CanPlayVideo(offering, episode, asset, RightsType.Online);
                                    }
                                    catch (Exception e) { MyUtility.LogException(e, "ContextHelper IsUserEntitled IP Whitelisting"); }
                                }
                            }
                            else
                                IsUserEntitled = user.CanPlayVideo(offering, episode, asset, RightsType.Online);
                        }
                        else
                            IsUserEntitled = true;
                    }
                }
            }

            ////Check for subclips
            //int snippetStart = 0;
            //int snippetEnd = 0;
            //AkamaiFlowPlayerPluginClipDetails clipDetails = null;

            //if (!IsUserEntitled)
            //{
            //    if ((asset.SnippetStart != null) && (asset.SnippetEnd != null) && (asset.SnippetEnd > asset.SnippetStart))
            //    {
            //        snippetStart = Convert.ToInt32(asset.SnippetStart.Value.TotalSeconds);
            //        snippetEnd = Convert.ToInt32(asset.SnippetEnd.Value.TotalSeconds);
            //    }
            //    else
            //    {
            //        snippetStart = 0;
            //        snippetEnd = GlobalConfig.snippetEnd;
            //    }
            //    clipDetails.PromptToSubscribe = true;
            //}
            //else
            //    clipDetails.PromptToSubscribe = false;

            //clipDetails.SubClip = (snippetStart + snippetEnd > 0) ? new SubClip { Start = snippetStart, End = snippetEnd } : null;
            //if (clipDetails.SubClip != null)
            //    IsUserEntitled = false;
            //else
            //    IsUserEntitled = true;

            return IsUserEntitled;
        }
예제 #7
0
        public static StreamSenseObj CreateStreamSenseObject(Episode episode, Show show)
        {
            string show_name = show.Description.Trim();
            var streamSenseObj = new StreamSenseObj()
            {
                dateaired = episode.DateAired,
                id = episode.EpisodeId,
                playlist = String.Format("{0} episodes", show_name),
                program = show_name,
                IsEpisode = (show is IPTV2_Model.Movie || show is IPTV2_Model.LiveEvent) ? false : true
            };

            if (show is IPTV2_Model.Movie)
            {
                streamSenseObj.playlist = String.Format("{0} movie", show_name);
            }
            else if (show is IPTV2_Model.LiveEvent)
            {
                streamSenseObj.playlist = String.Format("{0} live event", show_name);
            }
            return streamSenseObj;
        }