Heckie75 / kodi-addon-podcast

Subscribe to podcasts in KODI
MIT License
14 stars 3 forks source link

Error When Podcast RSS Feed Has Episodes With No Description #2

Closed stobb3s closed 3 years ago

stobb3s commented 3 years ago

I tried to add a new podcast RSS feed to my opml file. However, I found that the addon would not open the feed. After looking at the kodi.log, I found that python is raising a KeyError exception at line 195 in addon.py where the episode description is assigned to name2.

            entries = entries + [{
                "path": str(index),
                "name": item["title"],
                "name2": item["description"],
                "icon": image,
                "params": [
                    {
                        "call": "playRss",
                        "index": str(index),
                        "url": url
                    }
                ],
                "pubDate": pubDate

            }]

After looking at the RSS feed, I discovered that not every episode has a description, which is causing the KeyError. I propose to assign name2 in a try/except block, which will handle the exception in case an episode in the feed does not have a description. I changed code to below and it fixed the issue.

            try:
                name2 = item["description"]
            except:
                name2 = "No description available"

            entries = entries + [{
                "path": str(index),
                "name": item["title"],
                "name2": name2,
                "icon": image,
                "params": [
                    {
                        "call": "playRss",
                        "index": str(index),
                        "url": url
                    }
                ],
                "pubDate": pubDate

            }]
Heckie75 commented 3 years ago

Thanks for your feedback.

I have changed the code so that the description is optional.

Please double-check if this works for you.

Best regards

stobb3s commented 3 years ago

Yes, your fix works for me. Thank you.