예제 #1
0
        private void writeTag(videoItem item, XmlWriter w, string priority)
        {
            w.WriteStartElement("url");

            w.WriteElementString("loc", "http://video.malmo.se/?bctid=" + item.id);
            w.WriteElementString("changefreq", "monthly");
            w.WriteElementString("priority", priority);

            w.WriteEndElement();
        }
예제 #2
0
        private void writeTag(string category, string publisherId, string playerId, videoItem item, XmlWriter w)
        {
            long milli;
            bool parse = long.TryParse(item.length, out milli);

            if (milli >= 28800000)
            {
                milli = 28800000;
            }
            string duration = (milli / 1000).ToString();

            string _viewComunt = item.playsTotal;

            if (_viewComunt == null)
            {
                _viewComunt = "0";
            }

            string _thumbnail = item.videoStillURL;

            if (_thumbnail == null)
            {
                _thumbnail = item.thumbnailURL;
            }

            w.WriteStartElement("url");

            w.WriteElementString("loc", "http://video.malmo.se/?bctid=" + item.id);

            w.WriteStartElement("video", "video", null);

            w.WriteElementString("video", "title", null, item.name);
            w.WriteElementString("video", "description", null, item.shortDescription);
            w.WriteElementString("video", "thumbnail_loc", null, _thumbnail);
            w.WriteElementString("video", "family_friendly", null, "Yes");
            w.WriteElementString("video", "category", null, category);
            w.WriteElementString("video", "view_count", null, _viewComunt);
            w.WriteElementString("video", "duration", null, duration);

            w.WriteStartElement("video", "player_loc", null);
            w.WriteAttributeString("allow_embed", "true");
            w.WriteString("http://c.brightcove.com/services/viewer/federated_f9/" + playerId + "?isVid=1&isUI=1&domain=embed&playerID=" + playerId + "&videoID=" + item.id + "&publisherID=" + publisherId);
            w.WriteEndElement();



            w.WriteEndElement();

            w.WriteEndElement();
        }
예제 #3
0
        private videoArchive buildVideoArchive(bool komin)
        {
            videoArchive archive = new videoArchive();

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

            string kfPlaylistBcId = "2623641282001";

            if (komin)
            {
                mArchivePlayerBcId = "1213665896001";
            }
            else
            {
                mArchivePlayerBcId = "1180742924001";
            }

            string videoFields = "id,name,shortDescription,videoStillURL,thumbnailURL,length,playsTotal,tags,customFields";

            var mRequest  = (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}", mArchivePlayerBcId, videoFields, MReadToken));
            var kfRequest = (HttpWebRequest)HttpWebRequest.Create(string.Format("http://api.brightcove.com/services/library?command=find_playlist_by_id&playlist_id={0}&video_fields={1}&token={2}", kfPlaylistBcId, videoFields, KFReadToken));

            mRequest.Method  = "POST";
            kfRequest.Method = "POST";

            //Get Malmö Account Items
            try
            {
                var    response         = mRequest.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)
                            {
                                bool kominVideo = false;
                                if (video.customFields != null)
                                {
                                    var customFields = video.customFields;
                                    foreach (dynamic field in customFields)
                                    {
                                        if (field.Name != null)
                                        {
                                            if (field.Name == "targetgroup")
                                            {
                                                if (field.Value == "Komin")
                                                {
                                                    kominVideo = true;
                                                }
                                            }
                                        }
                                    }
                                }
                                if (!kominVideo || kominVideo && komin)
                                {
                                    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.shortDescription = video.shortDescription.ToString().Replace("\"", "&quot");
                                    if (video.tags != null)
                                    {
                                        item.tags = new List <string>();
                                        var tags = video.tags;
                                        foreach (string tag in tags)
                                        {
                                            item.tags.Add((string)tag);
                                        }
                                    }

                                    cat.videos.Add(item);
                                }
                            }
                            archive.categories.Add(cat);
                        }
                    }
                }
            }
            catch { }
            ////Get KF Account Items
            try
            {
                var    response         = kfRequest.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);

                        videoCategory category = new videoCategory();
                        category.name   = results.name;
                        category.videos = new List <videoItem>();

                        foreach (dynamic video in results.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.shortDescription = video.shortDescription.ToString().Replace("\"", "&quot");
                            if (video.tags != null)
                            {
                                item.tags = new List <string>();
                                var tags = video.tags;
                                foreach (string tag in tags)
                                {
                                    item.tags.Add((string)tag);
                                }
                            }

                            category.videos.Add(item);
                        }
                        archive.categories.Add(category);
                    }
                }
            }
            catch { }
            return(archive);
        }