Skip to content

Commit

Permalink
remove wordpress footer from entry preview
Browse files Browse the repository at this point in the history
  • Loading branch information
facundoolano committed Jan 4, 2024
1 parent 26021bc commit c90d08f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions feedi/parsers/rss.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,20 @@ def parse_avatar_url(self, entry):
return url

def parse_content_short(self, entry):
content_url = self.parse_content_url(entry)
summary = entry.get('summary')
if summary:
# wordpress adds an annoying footer by default ('the post x appeared first on')
# removing it by skipping the last line when it includes a link to the article
footer = summary.split('\n')[-1]
if content_url.split('?')[0] in footer:
summary = summary.strip(footer).strip()

summary = html.unescape(summary)
else:
url = self.parse_content_url(entry)
if not url:
if not content_url:
return
summary = self.fetch_meta(url, 'og:description', 'description')
summary = self.fetch_meta(content_url, 'og:description', 'description')
if not summary:
return

Expand Down

0 comments on commit c90d08f

Please sign in to comment.