import copy


def _convert_tvdb_episode_metadata(imdb_id , season_metadata, episode, banners=True):
    """
    converts tvdb episode metadata to format suited for kodiswift
    Args:
        season_metadata: dictionary of tvdb season metadata
        episode: dictionary of tvdb episode metadata
        banners: whether to get the poster image from metadata
    Returns:
        episode metadata
    """
    info = copy.deepcopy(season_metadata)
    info['episode'] = episode.get('episodenumber')
    info['title'] = episode.get('episodename', '')
    info['aired'] = episode.get('firstaired', '')
    info['premiered'] = episode.get('firstaired', '')
    info['rating'] = episode.get('rating', '')
    info['plot'] = episode.get('overview', '')
    info['plotoutline'] = episode.get('overview', '')
    info['votes'] = episode.get('ratingcount', '')
    info['imdb_id'] = imdb_id
    if banners:
        info['poster'] = episode['filename']
    return info