diff --git a/radiofeed/feedparser/feed_parser.py b/radiofeed/feedparser/feed_parser.py index be016f490..2adbbf37c 100644 --- a/radiofeed/feedparser/feed_parser.py +++ b/radiofeed/feedparser/feed_parser.py @@ -124,6 +124,7 @@ def _handle_update( feed: Feed, ) -> None: categories_dct = get_categories() + try: with transaction.atomic(): self._podcast_update( @@ -134,8 +135,8 @@ def _handle_update( active=not (feed.complete), etag=self._parse_etag(response), modified=self._parse_modified(response), + keywords=self._parse_keywords(feed, categories_dct), extracted_text=self._tokenize_content(feed), - keywords=" ".join(self._parse_keywords(feed, categories_dct)), frequency=scheduler.schedule(feed), **feed.model_dump( exclude={ @@ -149,7 +150,9 @@ def _handle_update( self._podcast.categories.set( self._parse_categories(feed, categories_dct) ) + self._episode_updates(feed) + self._logger.success("Feed updated") except DataError as exc: raise InvalidDataError from exc @@ -239,21 +242,19 @@ def _podcast_update(self, **fields) -> None: **fields, ) - def _parse_keywords( - self, feed: Feed, categories_dct: dict[str, Category] - ) -> Iterator[str]: - categories_dct = get_categories() - - for value in feed.categories: - if value not in categories_dct: - yield value + def _parse_keywords(self, feed: Feed, categories_dct: dict[str, Category]) -> str: + return " ".join( + [value for value in feed.categories if value not in categories_dct] + ) def _parse_categories( self, feed: Feed, categories_dct: dict[str, Category] - ) -> Iterator[Category]: - for value in feed.categories: - if value in categories_dct: - yield categories_dct[value] + ) -> list[Category]: + return [ + categories_dct[value] + for value in feed.categories + if value in categories_dct + ] def _tokenize_content(self, feed: Feed) -> str: text = " ".join(