Ejemplo n.º 1
0
        public void Parse(Feed<Video> videoFeed, VideoList videoList)
        {
            foreach (Video video in videoFeed.Entries)
            {
                string id = video.VideoId;
                string title = video.Title;

                if (video.Thumbnails != null && video.Thumbnails.Count > 0)
                {
                    foreach (MediaContent mediaContent in video.Contents)
                    {
                        if ("5".Equals(mediaContent.Format))
                        {
                            if ("120".Equals(video.Thumbnails[0].Width) && "90".Equals(video.Thumbnails[0].Height))
                            {
                                VideoItem videoItem = new VideoItem(id, title, ProviderEnum.YouTube);
                                videoItem.ThumbnailImageURL = video.Thumbnails[0].Url;
                                videoItem.ThumbnailImageWidth = video.Thumbnails[0].Width;
                                videoItem.ThumbnailImageHeight = video.Thumbnails[0].Height;

                                videoList.AddVideo(videoItem);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 protected override void LoadData()
 {
     Trace.Write("VideoTrendsControl LoadData() - Start Calling Video Command");
     if (VideoCommand != null)
     {
         VideoList = VideoCommand.GetVideo();
     }
     Trace.Write("VideoTrendsControl LoadData() - End Calling Video Command");
 }
        static public void Serialize(VideoList videoList)
        {
            string filepath = System.Web.Hosting.HostingEnvironment.MapPath("~/data/VideoTrends.xml");

            Type type = typeof(VideoList);
            Type[] extraTypes = new Type[] { typeof(VideoItem) };

            lock (guard)
            {
                XMLSerializer.Serialize(videoList, type, extraTypes, filepath);
            }
        }
        private void AddVideo(YouTubeRequest request, string urlTemplate, string maxResultsKey, VideoList videoList)
        {
            int maxResults = ConfigService.GetConfig(maxResultsKey, 0);
            if (maxResults > 0)
            {
                string url = string.Format(urlTemplate, maxResults);
                Feed<Video> videos = request.Get<Video>(new Uri(url));

                YouTubeVideoParser parser = new YouTubeVideoParser();
                parser.Parse(videos, videoList);
            }
        }
        private void AddVideo(YouTubeRequest request, string maxResultsKey, string query, VideoList videoList)
        {
            int maxResults = ConfigService.GetConfig(maxResultsKey, 0);
            if (maxResults > 0)
            {
                YouTubeQuery youtubeQuery = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);
                youtubeQuery.Query = "%22" + query +  "%22";
                youtubeQuery.SafeSearch = YouTubeQuery.SafeSearchValues.Strict;
                youtubeQuery.NumberToRetrieve = maxResults;
                Feed<Video> videos = request.Get<Video>(youtubeQuery);

                YouTubeVideoParser parser = new YouTubeVideoParser();
                parser.Parse(videos, videoList);
            }
        }
        public VideoList Search(string query)
        {
            VideoList videoList = new VideoList();
            try
            {
                string api = ConfigService.GetConfig(ConfigKeys.YOUTUBE_API_KEY, "");
                YouTubeRequestSettings settings = new YouTubeRequestSettings("TheInternetBuzz.org", "TheInternetBuzz.org", api);
                YouTubeRequest request = new YouTubeRequest(settings);

                AddVideo(request, ConfigKeys.YOUTUBE_SEARCH_MAXRESULTS, query, videoList);
            }
            catch (Exception exception)
            {
                ErrorService.Log("YouTubeSearchService", "Search", query, exception);
            }

            return videoList;
        }
        public VideoList GetVideo()
        {
            VideoList videoList = new VideoList();
            try
            {
                string api = ConfigService.GetConfig(ConfigKeys.YOUTUBE_API_KEY, "");
                YouTubeRequestSettings settings = new YouTubeRequestSettings("TheInternetBuzz.com", "TheInternetBuzz.com", api);
                YouTubeRequest request = new YouTubeRequest(settings);

                AddVideo(request, RecentlyFeaturedUrlTemplate, ConfigKeys.YOUTUBE_FEEDS_RECENTLYFEATURED_MAXRESULTS, videoList);
                AddVideo(request, TopRatedFeedUrlTemplate, ConfigKeys.YOUTUBE_FEEDS_TOPRATED_MAXRESULTS, videoList);
                AddVideo(request, TopFavouritesFeedUrlTemplate, ConfigKeys.YOUTUBE_FEEDS_TOPFAVOURITES_MAXRESULTS, videoList);
                AddVideo(request, MostViewedFeedUrlTemplate, ConfigKeys.YOUTUBE_FEEDS_MOSTVIEWED_MAXRESULTS, videoList);
                AddVideo(request, MostPopularFeedUrlTemplate, ConfigKeys.YOUTUBE_FEEDS_MOSTPOPULAR_MAXRESULTS, videoList);
                AddVideo(request, MostDiscussedFeedUrlTemplate, ConfigKeys.YOUTUBE_FEEDS_MOSTDISCUSSED_MAXRESULTS, videoList);
                AddVideo(request, MostRespondedFeedUrlTemplate, ConfigKeys.YOUTUBE_FEEDS_MOSTRESPONDED_MAXRESULTS, videoList);
            }
            catch (Exception exception)
            {
                ErrorService.Log("YouTubeTrendsService", "GetVideo", null, exception);
            }

            return videoList;
        }
 public static void CacheSearchResultList(string query, VideoList videoList)
 {
     string cacheName = "video-" + query;
     int cacheExpiration = ConfigService.GetConfig(ConfigKeys.THEINTERNETBUZZ_VIDEO_SEARCH_EXPIRATION, 60);
     CacheService.Put(cacheName, cacheExpiration, videoList);
 }
Ejemplo n.º 9
0
 public static void CacheVideoTrends(VideoList videoList)
 {
     int cacheExpiration = int.MaxValue;
     CacheService.Put("video-trends", cacheExpiration, videoList);
 }