def mode_podcast(pid):
    podcast = feedparser.parse((('https://podcasts.files.bbci.co.uk/' + pid) + '.rss'))
    image_url = None
    if ('image' in podcast.feed):
        image_url = podcast.feed.image.url
    for entry in podcast.entries:
        entry_pid = entry.ppg_canonical.split('/')
        entry_date = datetime.datetime.fromtimestamp(mktime(entry.published_parsed)).strftime('%Y-%m-%d')
        entry_title = ((entry_date + ': ') + entry.title)
        if (len(entry_pid) > 2):
            url = build_url({'mode': 'episode', 'pid': entry_pid[2]})
            li = xbmcgui.ListItem(entry_title)
            li.setInfo('video', {'plot': entry.description})
            li.setThumbnailImage(image_url)
            li.setProperty('IsPlayable', 'true')
            xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
        else:
            xbmc.log(('No pid could be found for the item at ' + entry.link), level=xbmc.LOGERROR)
    xbmcplugin.endOfDirectory(addon_handle)
def mode_podcast(pid):
    podcast = feedparser.parse((('https://podcasts.files.bbci.co.uk/' + pid) + '.rss'))
    image_url = None
    if ('image' in podcast.feed):
        image_url = podcast.feed.image.url
    for entry in podcast.entries:
        entry_pid = entry.ppg_canonical.split('/')
        entry_date = datetime.datetime.fromtimestamp(mktime(entry.published_parsed)).strftime('%Y-%m-%d')
        entry_title = ((entry_date + ': ') + entry.title)
        if (len(entry_pid) > 2):
            url = build_url({'mode': 'episode', 'pid': entry_pid[2]})
            li = xbmcgui.ListItem(entry_title)
            li.setInfo('video', {'plot': entry.description})
            li.setThumbnailImage(image_url)
            li.setProperty('IsPlayable', 'true')
            xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
        else:
            xbmc.log(('No pid could be found for the item at ' + entry.link), level=xbmc.LOGERROR)
    xbmcplugin.endOfDirectory(addon_handle)