prenagha / patreon-mp3

Download MP3s from the Patreon artists you sponsor
Apache License 2.0
3 stars 1 forks source link

Fixed error when there is no summary in parsed feed #2

Closed volk12 closed 7 months ago

volk12 commented 7 months ago

Script would die when no summary:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/feedparser/util.py", line 156, in __getattr__
    return self.__getitem__(key)
  File "/usr/local/lib/python3.10/dist-packages/feedparser/util.py", line 113, in __getitem__
    return dict.__getitem__(self, key)
KeyError: 'summary'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/justin/patreon-mp3-master/patreon-mp3.py", line 64, in <module>
    comment = item.summary.replace('<br>','').strip()
  File "/usr/local/lib/python3.10/dist-packages/feedparser/util.py", line 158, in __getattr__
    raise AttributeError("object has no attribute '%s'" % key)
AttributeError: object has no attribute 'summary'

fixed by putting a try around comment = item.summary.replace('<br>','').strip()

then had issue where datetime.mktime is no longer a method, fixed by passing published as a struct_time to time.mktime