コード例 #1
0
        /// <summary>
        /// Logic to translate/create a corresponding URL for the
        /// bucketUrl entry provided from Encoding
        /// </summary>
        /// <param name="file"></param>
        /// <param name="pathTranslationQuery"></param>
        private void ApplyPathTranslationInformation(EncodingFileContentViewModel file)
        {
            // Get an asset (the first one in the list) with the given media id
            var airing   = _airingSvc.GetByMediaId(file.MediaId).FirstOrDefault();
            var pathings = _pathingSvc.GetAll();

            foreach (var media in file.MediaCollection)
            {
                foreach (var playlist in media.Playlists)
                {
                    Dictionary <string, string> sourceUrls = playlist.Urls;

                    //If input URLs payload is empty then get bucket url
                    if (!sourceUrls.Any())
                    {
                        sourceUrls["bucketUrl"] = playlist.BucketURL;
                    }

                    foreach (var url in sourceUrls)
                    {
                        var urlType   = url.Key;
                        var sourceUrl = url.Value;

                        //Adds the given url
                        playlist.TranslatedUrls.Add(new TranslatedUrlViewModel {
                            UrlType = urlType, Url = sourceUrl
                        });

                        if (!string.IsNullOrEmpty(sourceUrl))
                        {
                            foreach (var pt in pathings.Where(x => sourceUrl.StartsWith(x.Source.BaseUrl)))
                            {
                                var translatedUrl = GetTranslatedUrl(sourceUrl, pt, airing);

                                if (!translatedUrl.IsNullOrEmpty())
                                {
                                    var tranlatedUrlType = pt.Target.UrlType;

                                    //if URL type not specified then default it to Akamai URL
                                    if (string.IsNullOrEmpty(tranlatedUrlType))
                                    {
                                        tranlatedUrlType = "akamaiUrl";
                                    }

                                    //Adds the translated URL
                                    playlist.TranslatedUrls.Add(new TranslatedUrlViewModel {
                                        UrlType = tranlatedUrlType, Url = translatedUrl
                                    });
                                }

                                // Add protectionType to properties if it doesn't already exist
                                if (playlist.ProtectionType.IsNullOrEmpty() && !translatedUrl.IsNullOrEmpty())
                                {
                                    playlist.ProtectionType = pt.Target.ProtectionType;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
 public IEnumerable <VMModel.PathTranslationViewModel> GetAll()
 {
     return(pathTranslationSvc.GetAll()
            .ToViewModel <List <BLModel.PathTranslation>, List <VMModel.PathTranslationViewModel> >());
 }