def mode_station_date(pid, year, month, day):
    schedule = get_page(((((((('https://www.bbc.co.uk/schedules/' + pid) + '/') + year) + '/') + month) + '/') + day))
    result = None
    for tag in schedule.find_all('script', type='application/ld+json'):
        if ('RadioEpisode' in tag.contents[0]):
            result = json.loads(tag.contents[0])
    if (result is None):
        xbmcgui.Dialog().notification(__addonname__, "Something went wrong parsing the station's schedule", icon=xbmcgui.NOTIFICATION_ERROR)
        return
    for episode in result['@graph']:
        date = dateutil.parser.parse(episode['publication']['startDate'])
        time = date.strftime('%Y-%m-%d, %H:%M')
        if ('partOfSeries' in episode):
            title = ((((time + ': ') + episode['partOfSeries']['name']) + ' - ') + episode['name'])
        else:
            title = ((time + ': ') + episode['name'])
        url = build_url({'mode': 'episode', 'pid': episode['identifier']})
        list_item = xbmcgui.ListItem(title)
        list_item.setInfo('video', {'plot': episode['description']})
        list_item.setPath(url)
        list_item.setProperty('IsPlayable', 'true')
        list_item.setThumbnailImage(episode['image'])
        xbmcplugin.addDirectoryItem(addon_handle, url, list_item, isFolder=False)
    xbmcplugin.endOfDirectory(addon_handle)
def mode_station_date(pid, year, month, day):
    schedule = get_page(((((((('https://www.bbc.co.uk/schedules/' + pid) + '/') + year) + '/') + month) + '/') + day))
    result = None
    for tag in schedule.find_all('script', type='application/ld+json'):
        if ('RadioEpisode' in tag.contents[0]):
            result = json.loads(tag.contents[0])
    if (result is None):
        xbmcgui.Dialog().notification(__addonname__, "Something went wrong parsing the station's schedule", icon=xbmcgui.NOTIFICATION_ERROR)
        return
    for episode in result['@graph']:
        date = dateutil.parser.parse(episode['publication']['startDate'])
        time = date.strftime('%Y-%m-%d, %H:%M')
        if ('partOfSeries' in episode):
            title = ((((time + ': ') + episode['partOfSeries']['name']) + ' - ') + episode['name'])
        else:
            title = ((time + ': ') + episode['name'])
        url = build_url({'mode': 'episode', 'pid': episode['identifier']})
        list_item = xbmcgui.ListItem(title)
        list_item.setInfo('video', {'plot': episode['description']})
        list_item.setPath(url)
        list_item.setProperty('IsPlayable', 'true')
        list_item.setThumbnailImage(episode['image'])
        xbmcplugin.addDirectoryItem(addon_handle, url, list_item, isFolder=False)
    xbmcplugin.endOfDirectory(addon_handle)