public async Task <IEnumerable <string> > Get(ChannelInfo channel, DateTimeOffset time, CancellationToken cancellationToken)
        {
            MatchingThread matchingThread = this.threadResolver.Resolve(channel, true);

            if (matchingThread == null)
            {
                return(Enumerable.Empty <string>());
            }

            string[] keywords = matchingThread.ThreadTitleKeywords?.Select(
                x => x.ToLower().Normalize(NormalizationForm.FormKD)
                ).ToArray() ?? Array.Empty <string>();
            (string server, string board) = GetServerAndBoardFromBoardUrl(matchingThread.BoardUri.ToString());

            if (!this.pastThreadListerCache.TryGetValue(board, out var threadLister))
            {
                threadLister = new Nichan.PastThreadLister(board, server, this.backTime);
                await threadLister.Initialize(cancellationToken).ConfigureAwait(false);

                this.pastThreadListerCache.Add(board, threadLister);
            }

            DateTimeOffset startTime            = time;
            IEnumerable <Nichan.Thread> threads = await threadLister.GetBetween(
                startTime, startTime + this.getTimeSpan, cancellationToken
                ).ConfigureAwait(false);

            return(threads.Where(x => keywords.All(
                                     keyword => x.Title.ToLower().Normalize(NormalizationForm.FormKD).Contains(keyword)
                                     )).Select(x => x.Uri.ToString()));
        }
Ejemplo n.º 2
0
        public string Get(ChannelInfo channel, DateTime time)
        {
            MatchingThread matchingThread = this.threadResolver.Resolve(channel);

            if (matchingThread == null)
            {
                return("");
            }

            return(matchingThread.BoardUri.ToString());
        }
Ejemplo n.º 3
0
        public IEnumerable <string> Get(ChannelInfo channel, DateTime time)
        {
            MatchingThread matchingThread = threadResolver.Resolve(channel);

            if (matchingThread == null)
            {
                return(new string[0]);
            }

            IEnumerable <string> keywords = matchingThread.ThreadTitleKeywords.Select(x => x.ToLower().Normalize(NormalizationForm.FormKD));

            Nichan.Board board = Nichan.BoardParser.ParseFromUri(matchingThread.BoardUri.ToString());

            return(board.Threads.Select(x => { x.Title = x.Title.ToLower().Normalize(NormalizationForm.FormKD); return x; })
                   .Where(x => x.ResCount <= 1000 && keywords.All(keyword => x.Title.Contains(keyword))).OrderByDescending(x => x.ResCount).Take(3).Select(x => x.Uri.ToString()));
        }
Ejemplo n.º 4
0
        public async Task <IEnumerable <string> > Get(
            ChannelInfo channel, DateTimeOffset time, CancellationToken cancellationToken
            )
        {
            MatchingThread matchingThread = threadResolver.Resolve(channel, false);

            if (matchingThread == null)
            {
                return(new string[0]);
            }

            IEnumerable <string> keywords = matchingThread.ThreadTitleKeywords.Select(
                x => x.ToLower().Normalize(NormalizationForm.FormKD)
                );

            string boardUri  = matchingThread.BoardUri.ToString();
            var    uri       = new Uri(boardUri);
            string boardHost = $"{uri.Scheme}://{uri.Host}";
            string boardName = uri.Segments[1];

            if (boardName.EndsWith('/'))
            {
                boardName = boardName[..^ 1];