Skip to content

Commit

Permalink
Use redirected URI as main URI when creating feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasLM committed Dec 13, 2018
1 parent 37caf6f commit 2786498
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions reader/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ class FeedFetchError(Exception):


def _fetch_and_create_feed(uri: str, process_html: bool=True
) -> Tuple[models.Feed, ParsedFeed]:
) -> Tuple[models.Feed, Optional[ParsedFeed]]:
try:
feed_request = http_fetcher.fetch_feed(uri, None, None, 1, None)
except (requests.exceptions.RequestException,
Expand Down Expand Up @@ -323,12 +323,15 @@ def _fetch_and_create_feed(uri: str, process_html: bool=True
f'Could not create feed "{uri}", content is not a valid feed'
)

feed = models.Feed.objects.create(
name=parsed_feed.title[:100],
uri=uri,
feed, created = models.Feed.objects.update_or_create(
defaults={'name': parsed_feed.title[:100]}, uri=feed_request.final_url
)
logger.info('Created feed %s', feed)
return feed, parsed_feed
if created:
logger.info('Created feed %s', feed)
return feed, parsed_feed
else:
logger.info('Submitted URI %s points to existing %s', uri, feed)
return feed, None


def calculate_frequency_per_year(feed: models.Feed) -> Optional[int]:
Expand Down

0 comments on commit 2786498

Please sign in to comment.