Exemplo n.º 1
0
        public ICollection<IDownloadSource> GetPage(IChannelSource source, int page)
        {
            BlipVideoChannelSource channelSource = (BlipVideoChannelSource)source;

            // page is relative to the current page
            // instead of throwing an exception for the current page,
            // it could just return the current download sources
            int actualPage = channelSource.CurrentPage + page;
            if (actualPage <= 0 || actualPage > channelSource.TotalPages)
                throw new ArgumentOutOfRangeException("page");

            string pagingUrlFormat = channelSource.PagingUrlFormat;
            string pagingUrl = String.Format(pagingUrlFormat, actualPage);
            Uri pagingUri = new Uri(channelSource.Uri, pagingUrl);
            string pageData = GetPageData(pagingUri);

            IDownloadSource[] downloadSources = ParseDownloadSources(pageData, channelSource).ToArray();

            return downloadSources;
        }
        public ICollection<IDownloadSource> GetPage(IChannelSource source, int page)
        {
            var channelSource = (YoutubeVideoChannelSource)source;
            // youtube channels are always on page zero,
            // so relative pages must be greater than zero
            if (page <= 0)
                throw new ArgumentOutOfRangeException("page");

            string ajaxSessionInfo = channelSource.AjaxSessionInfo;
            string postData = String.Format(pagingPostDataFormat, page, ajaxSessionInfo);

            string pagingUrl = String.Format(pagingUrlFormat, channelSource.User);
            var pagingUri = new Uri(channelSource.Uri, pagingUrl);
            string pageData = GetPageData(pagingUri, postData);

            string escapedMarkup = pageData.GetStringBetween("\"data\"", "\"", "<\\/div>\"");
            string markup = Regex.Unescape(escapedMarkup);

            IDownloadSource[] downloadSources = ParseDownloadSources(markup, channelSource).ToArray();

            return downloadSources;
        }
 public void Setup()
 {
     _channelSource = Substitute.For<IChannelSource>();
 }
 // constructors
 /// <summary>
 /// Initializes a new instance of the <see cref="ChannelSourceHandle"/> class.
 /// </summary>
 /// <param name="channelSource">The channel source.</param>
 public ChannelSourceHandle(IChannelSource channelSource)
     : this(new ReferenceCounted<IChannelSource>(channelSource))
 {
 }