Move things away from main and refactor things
This commit is contained in:
@ -1,16 +1,15 @@
|
||||
import urllib.parse
|
||||
from typing import Iterable
|
||||
|
||||
from reader import EntrySearchResult, Feed, HighlightedString, Reader
|
||||
from reader import Feed, HighlightedString, Reader
|
||||
|
||||
from discord_rss_bot.settings import get_reader
|
||||
|
||||
|
||||
def create_html_for_search_results(search_results: Iterable[EntrySearchResult], custom_reader: Reader | None = None) -> str:
|
||||
def create_html_for_search_results(query: str, custom_reader: Reader | None = None) -> str:
|
||||
"""Create HTML for the search results.
|
||||
|
||||
Args:
|
||||
search_results: The search results.
|
||||
query: Our search query
|
||||
custom_reader: The reader. If None, we will get the reader from the settings.
|
||||
|
||||
Returns:
|
||||
@ -22,6 +21,8 @@ def create_html_for_search_results(search_results: Iterable[EntrySearchResult],
|
||||
# Get the default reader if we didn't get a custom one.
|
||||
reader: Reader = get_reader() if custom_reader is None else custom_reader
|
||||
|
||||
search_results = reader.search_entries(query)
|
||||
|
||||
html: str = ""
|
||||
for result in search_results:
|
||||
if ".summary" in result.content:
|
||||
|
Reference in New Issue
Block a user