fastfeedparser 0.5.6__tar.gz → 0.5.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fastfeedparser
3
- Version: 0.5.6
3
+ Version: 0.5.7
4
4
  Summary: High performance RSS, Atom, JSON and RDF feed parser in Python
5
5
  Home-page: https://github.com/kagisearch/fastfeedparser
6
6
  Author: Vladimir Prelovac
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = fastfeedparser
3
- version = 0.5.6
3
+ version = 0.5.7
4
4
  author = Vladimir Prelovac
5
5
  author_email = vlad@kagi.com
6
6
  description = High performance RSS, Atom, JSON and RDF feed parser in Python
@@ -411,6 +411,13 @@ def _parse_json_feed(
411
411
  if enclosures:
412
412
  entry["enclosures"] = enclosures
413
413
 
414
+ # Derive feedparser-compatible author fields
415
+ _author = entry.get("author")
416
+ if _author:
417
+ _detail = {"name": _author}
418
+ entry["author_detail"] = _detail
419
+ entry["authors"] = [_detail]
420
+
414
421
  # Add links
415
422
  entry["links"] = []
416
423
  item_url = item.get("url")
@@ -455,7 +462,14 @@ def _fetch_url_content(url: str) -> str | bytes:
455
462
  )
456
463
  content = brotli.decompress(content)
457
464
  content_charset = response.headers.get_content_charset()
458
- return content.decode(content_charset) if content_charset else content
465
+ if content_charset:
466
+ try:
467
+ return content.decode(content_charset)
468
+ except (UnicodeDecodeError, LookupError):
469
+ # Server lied about charset; return raw bytes and let
470
+ # lxml detect encoding from the XML declaration/BOM.
471
+ return content
472
+ return content
459
473
 
460
474
 
461
475
  def _maybe_parse_json_feed(
@@ -805,6 +819,12 @@ def _parse_content(
805
819
  # Ensure that titles and descriptions are always present
806
820
  entry["title"] = entry.get("title", "").strip()
807
821
  entry["description"] = entry.get("description", "").strip()
822
+ # Derive feedparser-compatible author fields
823
+ _author = entry.get("author")
824
+ if _author:
825
+ _detail = {"name": _author}
826
+ entry["author_detail"] = _detail
827
+ entry["authors"] = [_detail]
808
828
  entries.append(entry)
809
829
 
810
830
  return feed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fastfeedparser
3
- Version: 0.5.6
3
+ Version: 0.5.7
4
4
  Summary: High performance RSS, Atom, JSON and RDF feed parser in Python
5
5
  Home-page: https://github.com/kagisearch/fastfeedparser
6
6
  Author: Vladimir Prelovac
File without changes
File without changes