'Build the JSON structure to send back to Trakt'

@staticmethod
def trakt_bulk_data_generate(data):

    uniqueShows = {}
    uniqueSeasons = {}
    for (showid, indexerid, show_name, startyear, season, episode) in data:
        if (showid not in uniqueShows):
            uniqueShows[showid] = {u'title': show_name, u'year': startyear, u'ids': {}, u'seasons': []}
            trakt_id = srIndexerApi(indexerid).config[u'trakt_id']
            if (trakt_id == u'tvdb_id'):
                uniqueShows[showid][u'ids'][u'tvdb'] = showid
            else:
                uniqueShows[showid][u'ids'][u'tvrage'] = showid
            uniqueSeasons[showid] = []
    for (showid, indexerid, show_name, startyear, season, episode) in data:
        if (season not in uniqueSeasons[showid]):
            uniqueSeasons[showid].append(season)
    traktShowList = []
    seasonsList = {}
    for searchedShow in uniqueShows:
        seasonsList[searchedShow] = []
        for searchedSeason in uniqueSeasons[searchedShow]:
            episodesList = []
            for (showid, indexerid, show_name, startyear, season, episode) in data:
                if ((season == searchedSeason) and (showid == searchedShow)):
                    episodesList.append({u'number': episode})
            show = uniqueShows[searchedShow]
            show[u'seasons'].append({u'number': searchedSeason, u'episodes': episodesList})
            traktShowList.append(show)
    return {u'shows': traktShowList}
