Exemplo n.º 1
0
 /// <summary>
 /// タイトルを用いてエントリーを検索
 /// </summary>
 /// <param name="queue"></param>
 /// <returns></returns>
 /// <exception cref="ArgumentException"/>
 public static Task <IEnumerable <Entities.EntriesListItem> > SearchEntriesWithTitleAsync(
     string title,
     EntriesListMode mode = EntriesListMode.Recent,
     long threshold       = 3,
     DateTime dateBegin   = default(DateTime),
     DateTime dateEnd     = default(DateTime),
     bool safe            = false)
 {
     return(SearchEntriesAsync("title", title, mode, threshold, dateBegin, dateEnd, safe));
 }
Exemplo n.º 2
0
        /// <summary>
        /// 特定サイトのエントリーを検索
        /// </summary>
        /// <param name="targetUrl"></param>
        /// <param name="mode"></param>
        /// <returns></returns>
        public static Task <IEnumerable <Entities.EntriesListItem> > SearchEntriesWithUrlAsync(
            string targetUrl,
            EntriesListMode mode = EntriesListMode.Recent)
        {
            if (string.IsNullOrWhiteSpace(targetUrl))
            {
                throw new ArgumentException("invalid url", nameof(targetUrl));
            }

            var sort = mode == EntriesListMode.Recent ? "recent" : "count";
            var url  = $"{BaseUrl}/entrylist?url={targetUrl}&mode=rss&sort={sort}";

            return(GetEntriesImplAsync(url));
        }
Exemplo n.º 3
0
        /// <summary>
        /// エントリーを検索
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentException"/>
        private static Task <IEnumerable <Entities.EntriesListItem> > SearchEntriesAsync(
            string mode,
            string query,
            EntriesListMode order,
            long threshold,
            DateTime dateBegin,
            DateTime dateEnd,
            bool safe)
        {
            if (!(mode == "text" || mode == "tag" || mode == "title"))
            {
                throw new ArgumentException("invalid mode: " + mode);
            }

            if (string.IsNullOrWhiteSpace(query))
            {
                throw new ArgumentException(nameof(query));
            }

            var url = $"{BaseUrl}/search/{mode}?q={query}&mode=rss&threshold={threshold}&safe={(safe ? "on" : "off")}";

            switch (order)
            {
            case EntriesListMode.Hot:
                url += "&sort=popular";
                break;

            case EntriesListMode.Recent:
                url += "&sort=recent";
                break;

            default: throw new NotImplementedException();
            }

            if (dateBegin != default(DateTime))
            {
                url += $"&date_begin={dateBegin.ToString("yyyy-MM-dd")}";
            }

            if (dateEnd != default(DateTime))
            {
                url += $"&date_end={dateEnd.ToString("yyyy-MM-dd")}";
            }

            return(GetEntriesImplAsync(url));
        }
Exemplo n.º 4
0
        /// <summary>
        /// ホット・新着エントリ一覧を取得する
        /// </summary>
        /// <param name="category"></param>
        /// <param name="mode"></param>
        /// <returns></returns>
        public static Task <IEnumerable <Entities.EntriesListItem> > GetEntriesAsync(Category category, EntriesListMode mode)
        {
            var target   = mode == EntriesListMode.Hot ? "hotentry" : "entrylist";
            var endpoint = GetCategoryEndPoint(category);
            var url      = $"{BaseUrl}/{target}{endpoint}";

            return(GetEntriesImplAsync(url));
        }