Esempio n. 1
0
        private void renderVideoArchive(videoArchive archive)
        {
            string archiveString = "archiveHtml";
            string html          = (string)Cache[archiveString];

            if (html == null)
            {
                StringBuilder menuBuilder = new StringBuilder();
                StringBuilder clipBuilder = new StringBuilder();

                //prepare menu
                menuBuilder.AppendLine("<div class=\"categories\">\n");
                menuBuilder.AppendLine("\t<ul>\n");

                //prepare clips
                clipBuilder.AppendLine("<div class=\"video-listing\"></div>\n");
                int categoryId = 1;

                foreach (videoCategory category in archive.categories)
                {
                    menuBuilder.AppendLine("<li><a href=\"javascript:showCategory(playlistId_" + categoryId.ToString() + ");\">" + category.name + "</a></li>\n");

                    clipBuilder.AppendLine("<div id=\"playlistId_" + categoryId.ToString() + "\" style=\"display:none;\">\n");

                    foreach (videoItem video in category.videos)
                    {
                        string description = string.Empty;
                        if (video.longDescription != null && video.longDescription != "")
                        {
                            description = video.longDescription;
                        }
                        else
                        {
                            description = video.shortDescription;
                        };

                        clipBuilder.AppendLine("<div class=\"post\">\n");
                        clipBuilder.AppendLine("<a href=\"?bctid=" + video.id + "\" class=\"videoBox\">");
                        clipBuilder.AppendLine("<div class=\"info-box\"><h2>" + video.name + "</h2><img src=\"" + video.videoStillURL + "\"/><p>" + description + "</p></div>");
                        clipBuilder.AppendLine("\t<div class=\"item-video\">\n");
                        //clipBuilder.AppendLine("\t\t<img src=\"" + video.thumbnailURL + "\" alt=\"" + video.shortDescription + "\">\n");
                        clipBuilder.AppendLine("\t\t<img src=\"" + video.videoStillURL + "\" alt=\"" + video.shortDescription + "\">\n");
                        clipBuilder.AppendLine("\t</div>\n");
                        clipBuilder.AppendLine("\t<h3>" + video.name + "</h3>");
                        clipBuilder.AppendLine("</a>");
                        clipBuilder.AppendLine("</div>\n");
                    }
                    clipBuilder.AppendLine("</div>\n");

                    categoryId++;
                }

                menuBuilder.AppendLine("\t</ul>\n");
                menuBuilder.AppendLine("</div>\n");

                html = menuBuilder.ToString() + clipBuilder.ToString();
                Cache.Insert("archiveHtml", html, null, DateTime.UtcNow.AddMinutes(10), Cache.NoSlidingExpiration);
            }
            wrapper.InnerHtml = html;
        }
Esempio n. 2
0
 public indexMessage buildIndex(indexMessage message)
 {
     if (_archive == null)
     {
         _archive = getVideoArchive();
     }
     buildIndex(_archive, message);
     return(message);
 }
Esempio n. 3
0
        private videoArchive build()
        {
            videoArchive archive = new videoArchive();

            archive.categories = new List <videoCategory>();

            string BRSArchivePlayerBcId = "3222810931001";

            string videoFields = "id,name,shortDescription,longDescription,videoStillURL,thumbnailURL,length,playsTotal,publishedDate,startDate";

            var BRSRequest = (HttpWebRequest)HttpWebRequest.Create(string.Format("http://api.brightcove.com/services/library?command=find_playlists_for_player_id&player_id={0}&video_fields={1}&token={2}", BRSArchivePlayerBcId, videoFields, RSReadToken));

            BRSRequest.Method = "POST";

            //Get BRS Account Items
            try
            {
                var    response         = BRSRequest.GetResponse();
                Stream dataStream       = response.GetResponseStream();
                string BCResponseString = string.Empty;
                using (StreamReader reader = new StreamReader(dataStream))
                {
                    BCResponseString = reader.ReadToEnd();

                    if (BCResponseString != null && BCResponseString != "null")
                    {
                        var results = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(BCResponseString);

                        foreach (dynamic category in results.items)
                        {
                            videoCategory cat = new videoCategory();
                            cat.name   = category.name;
                            cat.videos = new List <videoItem>();
                            foreach (dynamic video in category.videos)
                            {
                                videoItem item = new videoItem();
                                item.id               = video.id;
                                item.name             = video.name.ToString().Replace("\"", "&quot");
                                item.length           = video.length;
                                item.playsTotal       = video.playsTotal;
                                item.thumbnailURL     = video.thumbnailURL;
                                item.videoStillURL    = video.videoStillURL;
                                item.publishedDate    = video.publishedDate;
                                item.startDate        = video.startDate;
                                item.shortDescription = video.shortDescription.ToString().Replace("\"", "&quot");
                                item.longDescription  = video.longDescription.ToString().Replace("\"", "&quot");
                                cat.videos.Add(item);
                            }
                            archive.categories.Add(cat);
                        }
                    }
                }
            }
            catch { }
            return(archive);
        }
Esempio n. 4
0
 private videoArchive getVideoArchive()
 {
     _archive = (videoArchive)_cache["Archive"];
     if (_archive == null)
     {
         buildVideoArchive builder = new buildVideoArchive();
         _archive = builder.render();
         _cache.Insert("Archive", _archive, null, DateTime.UtcNow.AddMinutes(10), Cache.NoSlidingExpiration);
     }
     return(_archive);
 }
Esempio n. 5
0
        private void buildIndex(videoArchive archive, indexMessage message)
        {
            Lucene.Net.Index.IndexWriter writer;

            try
            {
                writer = new Lucene.Net.Index.IndexWriter(videoIndex, analyser, Lucene.Net.Index.IndexWriter.MaxFieldLength.UNLIMITED);
                foreach (videoCategory cat in archive.categories)
                {
                    foreach (videoItem video in cat.videos)
                    {
                        string title = "";
                        if (!string.IsNullOrEmpty(video.name))
                        {
                            title = video.name;
                        }
                        string bcid = "";
                        if (!string.IsNullOrEmpty(video.id))
                        {
                            bcid = video.id;
                        }
                        string shortDescription = "";
                        if (!string.IsNullOrEmpty(video.shortDescription))
                        {
                            shortDescription = video.shortDescription;
                        }
                        string longDescription = "";
                        if (!string.IsNullOrEmpty(video.longDescription))
                        {
                            longDescription = video.longDescription;
                        }
                        string imageURL = "";
                        if (!string.IsNullOrEmpty(video.thumbnailURL))
                        {
                            imageURL = video.videoStillURL;
                        }

                        addVideoToIndex(bcid, title, shortDescription, longDescription, imageURL, writer, message);
                    }
                }
                message.success = true;
                writer.Optimize();
                message.message = "Index built and optimized!";
                writer.Dispose();
            }

            catch (Exception ex)
            {
                message.success = false;
                message.message = ex.Message;
            }
        }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string archiveString = "Archive";

            _archive = (videoArchive)Cache[archiveString];
            if (_archive == null)
            {
                buildVideoArchive builder = new buildVideoArchive();
                _archive = builder.render();
                Cache.Insert(archiveString, _archive, null, DateTime.UtcNow.AddMinutes(10), Cache.NoSlidingExpiration);
            }

            //För att inte indexera staging-server
            if (!Request.Url.Host.ToString().Contains("play.skane.com"))
            {
                HtmlMeta robotMeta = new HtmlMeta();
                robotMeta.Name    = "ROBOTS";
                robotMeta.Content = "NOINDEX, NOFOLLOW";
                Page.Header.Controls.Add(robotMeta);
            }

            string queryId = string.Empty;

            if (Request.QueryString["bctid"] != null)
            {
                frontpage = false;
                queryId   = Request.QueryString.GetValues("bctid").GetValue(0).ToString();
                findVideoInArchive(queryId);
            }
            else
            {
                getLatestVideo();
                setStandardMeta();
            }

            renderVideoArchive(_archive);
        }