Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def parse(url, stream, max_episodes=0):
"""Parse a podcast feed from the given URL and stream
:param url: the URL of the feed. Will be used to resolve relative links
:param stream: file-like object containing the feed content
:param max_episodes: maximum number of episodes to return. 0 (default)
means no limit
:returns: a dict with the parsed contents of the feed
"""
handler = PodcastHandler(url, max_episodes)
try:
sax.parse(stream, handler)
except sax.SAXParseException as e:
raise FeedParseError(e.getMessage(), e.getException(), e._locator)
return handler.data