Skip to content

Commit b5761d7

Browse files
committed
0.4.3
1 parent fb021c0 commit b5761d7

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = fastfeedparser
3-
version = 0.4.2
3+
version = 0.4.3
44
author = Vladimir Prelovac
55
author_email = [email protected]
66
description = High performance RSS, Atom and RDF parser in Python

src/fastfeedparser/main.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ def parse(source: str | bytes) -> FastFeedParserDict:
209209
channel = root
210210
else:
211211
raise ValueError("Invalid RSS feed: missing channel element")
212+
elif len(list(channel)) == 0 and len([child for child in root if child.tag == "item"]) > 0:
213+
# Handle malformed RSS where channel is empty but items are at root level
214+
# This handles feeds like canolcer.eu that have <channel></channel> but items outside
215+
channel = root
212216
# Find items with or without namespace
213217
items = channel.findall("item")
214218
if not items:
@@ -903,8 +907,10 @@ def _get_element_value(
903907
if el is None:
904908
return None
905909
if attribute is not None:
906-
return el.get(attribute)
907-
return el.text
910+
attr_value = el.get(attribute)
911+
return attr_value.strip() if attr_value else None
912+
text_value = el.text
913+
return text_value.strip() if text_value else None
908914

909915
custom_tzinfos: dict[str, int] = {
910916
'EST': -5 * 3600, # Eastern Standard Time

0 commit comments

Comments
 (0)