edsu / feediverse

Send RSS/Atom feeds to Mastodon
MIT License
113 stars 23 forks source link

Make `enclosures` and `links` attributes optional #24

Closed joschi closed 3 months ago

joschi commented 3 years ago

Feediverse fails to process entries which do not contain the enclosures or links elements.

Traceback:

Traceback (most recent call last):
  File "/path/to/lib/python3.6/site-packages/feedparser/util.py", line 156, in __getattr__
    return self.__getitem__(key)
  File "/path/to/lib/python3.6/site-packages/feedparser/util.py", line 65, in __getitem__
    for link in dict.__getitem__(self, 'links')
KeyError: 'links'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./feediverse.py", line 277, in <module>
    main()
  File "./feediverse.py", line 64, in main
    generator=feed.get('generator')):
  File "./feediverse.py", line 133, in get_feed
    yield get_entry(entry, include_images, generator)
  File "./feediverse.py", line 222, in get_entry
    'images': collect_images(entry, generator) if include_images else [],
  File "./feediverse.py", line 154, in collect_images
    for e in (entry.enclosures
  File "/path/to/lib/python3.6/site-packages/feedparser/util.py", line 158, in __getattr__
    raise AttributeError("object has no attribute '%s'" % key)
AttributeError: object has no attribute 'enclosures'
edsu commented 3 months ago

I'm sorry I didn't get to this in a timely manner! It looks like the code no longer gets enclosures and links this way. Please reopen if you find this is not the case.