Exemplo n.º 1
0
 public void Initialize(ScrapedPage page)
 {
     LogManager.Log("Initializing view window");
     this.lastPage = page;
     this.buttonSpecHeaderGroupMore.Visible = GetNextPage() != null;
     this.verticalSingleColumnGalleryWidget1.AddItems(page);
 }
Exemplo n.º 2
0
 public void OnScrapVideoCompleted(ScrapedPage page)
 {
     Program.SetIdle();
     this.InvokeEx(() =>
     {
         Initialize(page);
     });
 }
Exemplo n.º 3
0
        public override ScrapedPage ScrapeVideos(SearchParameters sparam = null)
        {
            var rootUrl = RootUrl;

            if (sparam != null)
            {
                if (!String.IsNullOrEmpty(sparam.Url))
                {
                    rootUrl = sparam.Url;
                }
                var ub = new Uri(rootUrl);
                if (!String.IsNullOrEmpty(sparam.Query))
                {
                    ub = ub.AddQuery("k", sparam.Query);
                    ub = ub.AddQuery("sort", sparam.SortBy == VideoSortby.Relevance ? "relevance"
                        : (sparam.SortBy == VideoSortby.Rating ? "rating" : "uploaddate"));
                    ub = ub.AddQuery("durf", sparam.Duration == VideoDuration.All ? "allduration" : (sparam.Duration == VideoDuration.Long ? "10min_more" :
                                                                                                     (sparam.Duration == VideoDuration.Short ? "1-3min" : "3-10min")));
                    ub = ub.AddQuery("datef", sparam.Period == VideoPeriod.Anytime ? "all" : (sparam.Period == VideoPeriod.Today ? "today" :
                                                                                              ((sparam.Period == VideoPeriod.ThisWeek ? "week" : "month"))));
                    rootUrl = ub.AbsoluteUri;
                }
            }

            var page = new ScrapedPage();
            var elem = GotoUrl(rootUrl);

            page.Videos = ScrapThumbnailVideos(elem);
            //get next page
            var pages = SelectItems(elem, ".pagination.small.top a").ToList();

            foreach (var p in pages)
            {
                bool selected = p.Attributes["class"] != null && p.Attributes["class"].Value == "sel";
                page.Links.Add(new PagingLink
                {
                    Url        = selected? rootUrl : new Uri(new Uri(RootUrl), p.Attributes["href"].Value).AbsoluteUri,
                    IsSelected = selected,
                    Text       = p.InnerText
                });
            }


            var showMore = SelectItem(elem, ".showMore a");

            if (showMore != null)
            {
                page.Links.Add(new PagingLink
                {
                    Url  = String.Format("{0}{1}", RootUrl, showMore.Attributes["href"].Value),
                    Text = showMore.InnerText,
                });
            }

            return(page);
        }
Exemplo n.º 4
0
 public void OnScrapVideoCompleted(ScrapedPage page)
 {
     LogManager.Log("Download complete. Total videos: " + page.Videos.Count);
     this.InvokeEx(() =>
     {
         this.labelLoading.Dispose();
         this.viewerWindow.Initialize(page);
         this.browseWindow.Initialize(page);
     });
 }
 protected override void OnAddItems(ScrapedPage page)
 {
     for (var i = 0; i < Constants.GetMaxDisplayCount(page.Videos.Count); i++)
     {
         var video = page.Videos[i];
         AddItem(video);
         if (Constants.ShowAds && i % 4 == 0)
         {
             var ad = CreateAdWidget(Constants.VerticalAdId);
             this.tableLayoutPanel.Controls.Add(ad);
         }
     }
 }
        protected override void OnAddItems(ScrapedPage page)
        {
            this.flowLayoutPanel.SuspendLayout();

            for (var i = 0; i < Constants.GetMaxDisplayCount(page.Videos.Count); i++)
            {
                var video = page.Videos[i];
                var widget = new WebViewWidget(video,
                    Properties.Resources.TestHtml.Replace("{0}", video.Url).Replace("{1}", video.ImageUrl).
                       Replace("{2}", video.Title).Replace("{3}", video.Duration.ToString()));
                this.flowLayoutPanel.Controls.Add(widget);
                widget.ViewSelected += delegate(object sender, GalleryItemSelectedEventArgs e)
                {
                    OnItemSelected(sender, e);
                };
            }
            this.flowLayoutPanel.ResumeLayout();
            flowLayoutPanel_Resize(this, null);
            AddLinks();

            base.OnAddItems(page);
        }
        protected override void OnAddItems(ScrapedPage page)
        {
            if (this.kryptonPanel1.Controls.Contains(this.kryptonLabelPrivacy))
                this.kryptonPanel1.Controls.Remove(this.kryptonLabelPrivacy);

            for (var i = 0; i < Constants.GetMaxDisplayCount(page.Videos.Count); i++)
            {
                var video = page.Videos[i];
                var widget = new WebViewWidget(video,
                    Properties.Resources.TestHtml.Replace("{0}", video.Url).Replace("{1}", video.ImageUrl).
                       Replace("{2}", video.Title).Replace("{3}", video.Duration.ToString()));
                this.flowLayoutPanel.Controls.Add(widget);
                widget.ViewSelected += delegate(object sender, GalleryItemSelectedEventArgs e)
                {
                    OnItemSelected(sender, e);
                };

                if (Constants.ShowAds && i % 4 == 0)
                {
                    var ad = CreateAdWidget(Constants.HorizontalAdId);
                    this.flowLayoutPanel.Controls.Add(ad);
                }
            }
        }
Exemplo n.º 8
0
 public void Initialize(ScrapedPage page)
 {
     this.browseGalleryWidget.ClearItems();
     this.browseGalleryWidget.AddItems(page);
 }
Exemplo n.º 9
0
        public override ScrapedPage ScrapeVideos(SearchParameters sparam = null)
        {
            var rootUrl = RootUrl;
            if (sparam != null )
            {
                if (!String.IsNullOrEmpty(sparam.Url))
                    rootUrl = sparam.Url;
                var ub = new Uri(rootUrl);
                if (!String.IsNullOrEmpty(sparam.Query))
                {
                    ub = ub.AddQuery("k", sparam.Query);
                    ub = ub.AddQuery("sort", sparam.SortBy == VideoSortby.Relevance ? "relevance"
                        : (sparam.SortBy == VideoSortby.Rating ? "rating" : "uploaddate"));
                    ub = ub.AddQuery("durf", sparam.Duration == VideoDuration.All ? "allduration" : (sparam.Duration == VideoDuration.Long ? "10min_more" :
                        (sparam.Duration == VideoDuration.Short ? "1-3min" : "3-10min")));
                    ub = ub.AddQuery("datef", sparam.Period == VideoPeriod.Anytime ? "all" : (sparam.Period == VideoPeriod.Today ? "today" :
                        ((sparam.Period == VideoPeriod.ThisWeek ? "week" : "month"))));
                    rootUrl = ub.AbsoluteUri;
                }
            }

            var page = new ScrapedPage();
            var elem = GotoUrl(rootUrl);
            page.Videos =  ScrapThumbnailVideos(elem);
            //get next page
            var pages = SelectItems(elem, ".pagination.small.top a").ToList();
            foreach (var p in pages)
            {
                bool selected = p.Attributes["class"] != null && p.Attributes["class"].Value == "sel";
                page.Links.Add(new PagingLink
                {
                    Url = selected? rootUrl : new Uri(new Uri(RootUrl), p.Attributes["href"].Value).AbsoluteUri,
                    IsSelected = selected,
                    Text = p.InnerText
                });
            }

               var showMore = SelectItem(elem, ".showMore a");
               if (showMore != null)
               {
                page.Links.Add(new PagingLink
                {
                    Url = String.Format("{0}{1}", RootUrl, showMore.Attributes["href"].Value),
                    Text = showMore.InnerText,
                });
               }

            return page;
        }
Exemplo n.º 10
0
 public void AddItems(ScrapedPage page)
 {
     this.currentPage = page;
     OnAddItems(page);
 }
Exemplo n.º 11
0
 protected virtual void OnAddItems(ScrapedPage page)
 {
 }