Skip to content

Commit

Permalink
🐛 Fix 'href' attribute error on some feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
tibonihoo committed Aug 20, 2024
1 parent ec5809d commit 5159ee2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions wom_river/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ def get_and_patch_link(entry):
return entry_link
other_links = (
[ link for link in entry.get("links", [])
if link.rel == "enclosure" and link.href]
if link.get("rel", None) == "enclosure" and link.get("href", None)]
+
[ link for link in entry.get("links", [])
if link.rel != "enclosure" and link.href]
if link.get("rel", None) != "enclosure" and link.get("href", None)]
)
if not other_links:
return None
Expand Down
10 changes: 10 additions & 0 deletions wom_river/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,16 @@ def setUp(self):
<!-- No pubDate -->
<guid isPermaLink="false">123</guid>
</item>
<item>
<title>The art</title>
<!-- No link but an enclosure without any url -->
<enclosure type="image/png" size="42"/>
<category>test</category>
<description>&lt;p>This is just a test&lt;/p>
</description>
<!-- No pubDate -->
<guid isPermaLink="false">123</guid>
</item>
</channel>
</rss>
"""
Expand Down

0 comments on commit 5159ee2

Please sign in to comment.