public virtual IndexerPageableRequestChain GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria)
        {
            var pageableRequests = new IndexerPageableRequestChain();

            var parameters = new BroadcastheNetTorrentQuery();
            if (AddSeriesSearchParameters(parameters, searchCriteria))
            {
                foreach (var episode in searchCriteria.Episodes)
                {
                    parameters = parameters.Clone();

                    parameters.Category = "Episode";
                    parameters.Name = string.Format("S{0:00}%E{1:00}%", episode.SeasonNumber, episode.EpisodeNumber);

                    pageableRequests.Add(GetPagedRequests(MaxPages, parameters));
                }

                foreach (var seasonNumber in searchCriteria.Episodes.Select(v => v.SeasonNumber).Distinct())
                {
                    parameters = parameters.Clone();

                    parameters.Category = "Season";
                    parameters.Name = string.Format("Season {0}", seasonNumber);

                    pageableRequests.Add(GetPagedRequests(MaxPages, parameters));
                }
            }

            return pageableRequests;
        }
        public virtual IList <IEnumerable <IndexerRequest> > GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria)
        {
            var pageableRequest = new List <IEnumerable <IndexerRequest> >();

            var parameters = new BroadcastheNetTorrentQuery();

            if (AddSeriesSearchParameters(parameters, searchCriteria))
            {
                foreach (var episode in searchCriteria.Episodes)
                {
                    parameters = parameters.Clone();

                    parameters.Category = "Episode";
                    parameters.Name     = String.Format("S{0:00}E{1:00}", episode.SeasonNumber, episode.EpisodeNumber);

                    pageableRequest.AddIfNotNull(GetPagedRequests(MaxPages, parameters));
                }

                foreach (var seasonNumber in searchCriteria.Episodes.Select(v => v.SeasonNumber).Distinct())
                {
                    parameters = parameters.Clone();

                    parameters.Category = "Season";
                    parameters.Name     = String.Format("Season {0}", seasonNumber);

                    pageableRequest.AddIfNotNull(GetPagedRequests(MaxPages, parameters));
                }
            }

            return(pageableRequest);
        }
Exemple #3
0
        public virtual IndexerPageableRequestChain GetSearchRequests(SeasonSearchCriteria searchCriteria)
        {
            var pageableRequests = new IndexerPageableRequestChain();

            var parameters = new BroadcastheNetTorrentQuery();

            if (AddSeriesSearchParameters(parameters, searchCriteria))
            {
                foreach (var seasonNumber in searchCriteria.Episodes.Select(v => v.SeasonNumber).Distinct())
                {
                    parameters.Category = "Season";
                    parameters.Name     = string.Format("Season {0}", seasonNumber);

                    pageableRequests.Add(GetPagedRequests(MaxPages, parameters));

                    parameters = parameters.Clone();

                    parameters.Category = "Episode";
                    parameters.Name     = string.Format("S{0:00}E%", seasonNumber);

                    pageableRequests.Add(GetPagedRequests(MaxPages, parameters));
                }
            }

            return(pageableRequests);
        }
Exemple #4
0
        public virtual IndexerPageableRequestChain GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria)
        {
            var pageableRequests = new IndexerPageableRequestChain();

            var parameters = new BroadcastheNetTorrentQuery();

            if (AddSeriesSearchParameters(parameters, searchCriteria))
            {
                parameters.Category = "Episode";
                parameters.Name     = string.Format("{0:yyyy}.{0:MM}.{0:dd}", searchCriteria.AirDate);

                pageableRequests.Add(GetPagedRequests(MaxPages, parameters));

                pageableRequests.AddTier();

                foreach (var episode in searchCriteria.Episodes)
                {
                    parameters = parameters.Clone();

                    parameters.Category = "Episode";
                    parameters.Name     = string.Format("S{0:00}E{1:00}", episode.SeasonNumber, episode.EpisodeNumber);

                    pageableRequests.Add(GetPagedRequests(MaxPages, parameters));
                }
            }

            return(pageableRequests);
        }
        public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria)
        {
            var pageableRequest = new List<IEnumerable<IndexerRequest>>();

            var parameters = new BroadcastheNetTorrentQuery();
            if (AddSeriesSearchParameters(parameters, searchCriteria))
            {
                foreach (var episode in searchCriteria.Episodes)
                {
                    parameters = parameters.Clone();

                    parameters.Category = "Episode";
                    parameters.Name = String.Format("S{0:00}E{1:00}", episode.SeasonNumber, episode.EpisodeNumber);

                    pageableRequest.AddIfNotNull(GetPagedRequests(MaxPages, parameters));
                }

                foreach (var seasonNumber in searchCriteria.Episodes.Select(v => v.SeasonNumber).Distinct())
                {
                    parameters = parameters.Clone();

                    parameters.Category = "Season";
                    parameters.Name = String.Format("Season {0}", seasonNumber);

                    pageableRequest.AddIfNotNull(GetPagedRequests(MaxPages, parameters));
                }
            }

            return pageableRequest;
        }
        public virtual IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearchCriteria searchCriteria)
        {
            var pageableRequests = new IndexerPageableRequestChain();

            var parameters = new BroadcastheNetTorrentQuery();

            if (AddSeriesSearchParameters(parameters, searchCriteria))
            {
                var episodeQueryTitle = searchCriteria.Episodes.Where(e => !string.IsNullOrWhiteSpace(e.Title))
                                        .Select(e => SearchCriteriaBase.GetQueryTitle(e.Title))
                                        .ToArray();

                foreach (var queryTitle in episodeQueryTitle)
                {
                    parameters = parameters.Clone();

                    parameters.Category = "Episode";
                    parameters.Name     = "%" + queryTitle + "%";


                    pageableRequests.Add(GetPagedRequests(MaxPages, parameters));
                }
            }

            return(pageableRequests);
        }
        private IEnumerable <IndexerRequest> GetPagedRequests(BroadcastheNetTorrentQuery parameters, int results, int offset)
        {
            var builder = new JsonRpcRequestBuilder(Settings.BaseUrl)
                          .Call("getTorrents", Settings.ApiKey, parameters, results, offset);

            builder.SuppressHttpError = true;

            yield return(new IndexerRequest(builder.Build()));
        }
        public IndexerPageableRequestChain GetSearchRequests(TvSearchCriteria searchCriteria)
        {
            var pageableRequests = new IndexerPageableRequestChain();

            var parameters = new BroadcastheNetTorrentQuery();

            var searchString = searchCriteria.SearchTerm != null ? searchCriteria.SearchTerm : "";

            var btnResults = searchCriteria.Limit.GetValueOrDefault();

            if (btnResults == 0)
            {
                btnResults = (int)Capabilities.LimitsDefault;
            }

            var btnOffset = searchCriteria.Offset.GetValueOrDefault();

            if (searchCriteria.TvdbId > 0)
            {
                parameters.Tvdb = string.Format("{0}", searchCriteria.TvdbId);
            }

            if (searchCriteria.RId > 0)
            {
                parameters.Tvrage = string.Format("{0}", searchCriteria.RId);
            }

            // If only the season/episode is searched for then change format to match expected format
            if (searchCriteria.Season > 0 && searchCriteria.Episode.IsNullOrWhiteSpace())
            {
                // Season Only
                parameters.Name     = string.Format("Season {0}%", searchCriteria.Season.Value);
                parameters.Category = "Season";
            }
            else if (searchCriteria.Season > 0 && Regex.IsMatch(searchCriteria.EpisodeSearchString, "(\\d{4}\\.\\d{2}\\.\\d{2})"))
            {
                // Daily Episode
                parameters.Name     = searchCriteria.EpisodeSearchString;
                parameters.Category = "Episode";
            }
            else if (searchCriteria.Season > 0 && int.Parse(searchCriteria.Episode) > 0)
            {
                // Standard (S/E) Episode
                parameters.Name     = string.Format("S{0:00}E{1:00}", searchCriteria.Season.Value, int.Parse(searchCriteria.Episode));
                parameters.Category = "Episode";
            }

            // Neither a season only search nor daily nor standard, fall back to query
            parameters.Search = searchString.Replace(" ", "%");

            pageableRequests.Add(GetPagedRequests(parameters, btnResults, btnOffset));

            return(pageableRequests);
        }
        private IEnumerable <IndexerRequest> GetPagedRequests(int maxPages, BroadcastheNetTorrentQuery parameters)
        {
            var builder = new JsonRpcRequestBuilder(Settings.BaseUrl)
                          .Call("getTorrents", Settings.ApiKey, parameters, PageSize, 0);

            builder.SuppressHttpError = true;

            for (var page = 0; page < maxPages; page++)
            {
                builder.JsonParameters[3] = page * PageSize;

                yield return(new IndexerRequest(builder.Build()));
            }
        }
Exemple #10
0
 private bool AddSeriesSearchParameters(BroadcastheNetTorrentQuery parameters, SearchCriteriaBase searchCriteria)
 {
     if (searchCriteria.Series.TvdbId != 0)
     {
         parameters.Tvdb = string.Format("{0}", searchCriteria.Series.TvdbId);
         return(true);
     }
     if (searchCriteria.Series.TvRageId != 0)
     {
         parameters.Tvrage = string.Format("{0}", searchCriteria.Series.TvRageId);
         return(true);
     }
     // BTN is very neatly managed, so it's unlikely they map tvrage/tvdb wrongly.
     return(false);
 }
        public virtual IList <IEnumerable <IndexerRequest> > GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria)
        {
            var pageableRequest = new List <IEnumerable <IndexerRequest> >();

            var parameters = new BroadcastheNetTorrentQuery();

            if (AddSeriesSearchParameters(parameters, searchCriteria))
            {
                parameters.Category = "Episode";
                parameters.Name     = String.Format("{0:yyyy}.{0:MM}.{0:dd}", searchCriteria.AirDate);

                pageableRequest.AddIfNotNull(GetPagedRequests(MaxPages, parameters));
            }

            return(pageableRequest);
        }
        public virtual IList <IEnumerable <IndexerRequest> > GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria)
        {
            var pageableRequest = new List <IEnumerable <IndexerRequest> >();

            var parameters = new BroadcastheNetTorrentQuery();

            if (AddSeriesSearchParameters(parameters, searchCriteria))
            {
                parameters.Category = "Episode";
                parameters.Name     = String.Format("S{0:00}E{1:00}", searchCriteria.SeasonNumber, searchCriteria.EpisodeNumber);

                pageableRequest.AddIfNotNull(GetPagedRequests(MaxPages, parameters));
            }

            return(pageableRequest);
        }
Exemple #13
0
        public virtual IndexerPageableRequestChain GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria)
        {
            var pageableRequests = new IndexerPageableRequestChain();

            var parameters = new BroadcastheNetTorrentQuery();

            if (AddSeriesSearchParameters(parameters, searchCriteria))
            {
                parameters.Category = "Episode";
                parameters.Name     = string.Format("{0:yyyy}.{0:MM}.{0:dd}", searchCriteria.AirDate);

                pageableRequests.Add(GetPagedRequests(MaxPages, parameters));
            }

            return(pageableRequests);
        }
Exemple #14
0
        private IEnumerable <IndexerRequest> GetPagedRequests(int maxPages, BroadcastheNetTorrentQuery parameters)
        {
            if (parameters == null)
            {
                parameters = new BroadcastheNetTorrentQuery();
            }

            var builder = new JsonRpcRequestBuilder(Settings.BaseUrl, "getTorrents", new object[] { Settings.ApiKey, parameters, PageSize, 0 });

            builder.SupressHttpError = true;

            for (var page = 0; page < maxPages; page++)
            {
                builder.Parameters[3] = page * PageSize;

                yield return(new IndexerRequest(builder.Build("")));
            }
        }
        public IndexerPageableRequestChain GetSearchRequests(BasicSearchCriteria searchCriteria)
        {
            var pageableRequests = new IndexerPageableRequestChain();

            var parameters = new BroadcastheNetTorrentQuery();

            var searchString = searchCriteria.SearchTerm != null ? searchCriteria.SearchTerm : "";

            var btnResults = searchCriteria.Limit.GetValueOrDefault();

            if (btnResults == 0)
            {
                btnResults = (int)Capabilities.LimitsDefault;
            }

            parameters.Search = searchString.Replace(" ", "%");

            var btnOffset = searchCriteria.Offset.GetValueOrDefault();

            pageableRequests.Add(GetPagedRequests(parameters, btnResults, btnOffset));

            return(pageableRequests);
        }
        public virtual IndexerPageableRequestChain GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria)
        {
            var pageableRequests = new IndexerPageableRequestChain();
            
            var parameters = new BroadcastheNetTorrentQuery();
            if (AddSeriesSearchParameters(parameters, searchCriteria))
            {
                parameters.Category = "Episode";
                parameters.Name = string.Format("{0:yyyy}.{0:MM}.{0:dd}", searchCriteria.AirDate);

                pageableRequests.Add(GetPagedRequests(MaxPages, parameters));
            }

            return pageableRequests;
        }
        public virtual IndexerPageableRequestChain GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria)
        {
            var pageableRequests = new IndexerPageableRequestChain();

            var parameters = new BroadcastheNetTorrentQuery();
            if (AddSeriesSearchParameters(parameters, searchCriteria))
            {
                parameters.Category = "Episode";
                parameters.Name = string.Format("{0:yyyy}.{0:MM}.{0:dd}", searchCriteria.AirDate);

                pageableRequests.Add(GetPagedRequests(MaxPages, parameters));

                pageableRequests.AddTier();

                foreach (var episode in searchCriteria.Episodes)
                {
                    parameters = parameters.Clone();

                    parameters.Category = "Episode";
                    parameters.Name = string.Format("S{0:00}E{1:00}", episode.SeasonNumber, episode.EpisodeNumber);

                    pageableRequests.Add(GetPagedRequests(MaxPages, parameters));
                }
            }

            return pageableRequests;
        }
        private IEnumerable<IndexerRequest> GetPagedRequests(int maxPages, BroadcastheNetTorrentQuery parameters)
        {
            var builder = new JsonRpcRequestBuilder(Settings.BaseUrl)
                .Call("getTorrents", Settings.ApiKey, parameters, PageSize, 0);
            builder.SuppressHttpError = true;

            for (var page = 0; page < maxPages; page++)
            {
                builder.JsonParameters[3] = page * PageSize;

                yield return new IndexerRequest(builder.Build());
            }
        }
        public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria)
        {
            var pageableRequest = new List<IEnumerable<IndexerRequest>>();

            var parameters = new BroadcastheNetTorrentQuery();
            if (AddSeriesSearchParameters(parameters, searchCriteria))
            {
                parameters.Category = "Episode";
                parameters.Name = String.Format("{0:yyyy}.{0:MM}.{0:dd}", searchCriteria.AirDate);

                pageableRequest.AddIfNotNull(GetPagedRequests(MaxPages, parameters));
            }

            return pageableRequest;
        }
 private bool AddSeriesSearchParameters(BroadcastheNetTorrentQuery parameters, SearchCriteriaBase searchCriteria)
 {
     if (searchCriteria.Series.TvdbId != 0)
     {
         parameters.Tvdb = String.Format("{0}", searchCriteria.Series.TvdbId);
         return true;
     }
     if (searchCriteria.Series.TvRageId != 0)
     {
         parameters.Tvrage = String.Format("{0}", searchCriteria.Series.TvRageId);
         return true;
     }
     // BTN is very neatly managed, so it's unlikely they map tvrage/tvdb wrongly.
     return false;
 }
        private IEnumerable<IndexerRequest> GetPagedRequests(Int32 maxPages, BroadcastheNetTorrentQuery parameters)
        {
            if (parameters == null)
            {
                parameters = new BroadcastheNetTorrentQuery();
            }

            var builder = new JsonRpcRequestBuilder(Settings.BaseUrl, "getTorrents", new Object[] { Settings.ApiKey, parameters, PageSize, 0 });
            builder.SupressHttpError = true;

            for (var page = 0; page < maxPages;page++)
            {
                builder.Parameters[3] = page * PageSize;

                yield return new IndexerRequest(builder.Build(""));
            }
        }