Move reader.update_feeds to send_to_discord
This commit is contained in:
@ -119,22 +119,14 @@ def check_feed(feed_url: str) -> None:
|
|||||||
Args:
|
Args:
|
||||||
feed_url: The feed to check.
|
feed_url: The feed to check.
|
||||||
"""
|
"""
|
||||||
reader.update_feed(feed_url)
|
if feed_url is None:
|
||||||
entries = reader.get_entries(feed=feed_url, read=False)
|
logger.error("No feed URL given")
|
||||||
for entry in entries:
|
send_to_discord(feed_url)
|
||||||
send_to_discord(entry)
|
return
|
||||||
|
send_to_discord(feed_url)
|
||||||
|
|
||||||
|
|
||||||
def send_to_discord(feed=None) -> None:
|
def send_to_discord(feed=None) -> None:
|
||||||
"""Update all feeds and send all the entries that are unread to Discord.
|
|
||||||
|
|
||||||
We don't need to mark entries as read here, because send_to_discord() does that when sending entries to Discord
|
|
||||||
if it was successful.
|
|
||||||
"""
|
|
||||||
reader.update_feeds()
|
|
||||||
send_to_discord()
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Send entries to Discord.
|
Send entries to Discord.
|
||||||
|
|
||||||
@ -149,6 +141,8 @@ def send_to_discord(feed=None) -> None:
|
|||||||
Returns:
|
Returns:
|
||||||
Response: The response from the webhook.
|
Response: The response from the webhook.
|
||||||
"""
|
"""
|
||||||
|
reader.update_feeds()
|
||||||
|
|
||||||
if feed is None:
|
if feed is None:
|
||||||
entries: Iterable[Entry] = reader.get_entries(read=False)
|
entries: Iterable[Entry] = reader.get_entries(read=False)
|
||||||
else:
|
else:
|
||||||
|
@ -53,7 +53,6 @@ templates: Jinja2Templates = Jinja2Templates(directory="templates")
|
|||||||
@app.post("/check", response_class=HTMLResponse)
|
@app.post("/check", response_class=HTMLResponse)
|
||||||
def check_feed(request: Request, feed_url: str = Form()) -> _TemplateResponse:
|
def check_feed(request: Request, feed_url: str = Form()) -> _TemplateResponse:
|
||||||
"""Check all feeds"""
|
"""Check all feeds"""
|
||||||
reader.update_feeds()
|
|
||||||
send_to_discord(feed_url)
|
send_to_discord(feed_url)
|
||||||
|
|
||||||
logger.info(f"Get feed: {feed_url}")
|
logger.info(f"Get feed: {feed_url}")
|
||||||
|
Reference in New Issue
Block a user