'Submits movies or episodes to trakt api.'

def submit(self, entries, remove=False):

    found = {}
    for entry in entries:
        if ((self.config[u'type'] in [u'auto', u'shows', u'seasons', u'episodes']) and entry.get(u'series_name')):
            (show_name, show_year) = split_title_year(entry[u'series_name'])
            show = {u'title': show_name, u'ids': get_entry_ids(entry)}
            if show_year:
                show[u'year'] = show_year
            if ((self.config[u'type'] in [u'auto', u'seasons', u'episodes']) and (entry.get(u'series_season') is not None)):
                season = {u'number': entry[u'series_season']}
                if ((self.config[u'type'] in [u'auto', u'episodes']) and (entry.get(u'series_episode') is not None)):
                    season[u'episodes'] = [{u'number': entry[u'series_episode']}]
                show[u'seasons'] = [season]
            if ((self.config[u'type'] in [u'seasons', u'episodes']) and (u'seasons' not in show)):
                log.debug((u'Not    submitting    `%s`,    no    season    found.' % entry[u'title']))
                continue
            if ((self.config[u'type'] == u'episodes') and (u'episodes' not in show[u'seasons'][0])):
                log.debug((u'Not    submitting    `%s`,    no    episode    number    found.' % entry[u'title']))
                continue
            found.setdefault(u'shows', []).append(show)
        elif (self.config[u'type'] in [u'auto', u'movies']):
            movie = {u'ids': get_entry_ids(entry)}
            if (not movie[u'ids']):
                if (entry.get(u'movie_name') is not None):
                    movie[u'title'] = (entry.get(u'movie_name') or entry.get(u'imdb_name'))
                    movie[u'year'] = (entry.get(u'movie_year') or entry.get(u'imdb_year'))
                else:
                    log.debug((u'Not    submitting    `%s`,    no    movie    name    or    id    found.' % entry[u'title']))
                    continue
            found.setdefault(u'movies', []).append(movie)
    if (not (found.get(u'shows') or found.get(u'movies'))):
        log.debug(u'Nothing    to    submit    to    trakt.')
        return
    if (self.config[u'list'] in [u'collection', u'watchlist', u'watched']):
        args = (u'sync', (u'history' if (self.config[u'list'] == u'watched') else self.config[u'list']))
    else:
        args = (u'users', self.config[u'username'], u'lists', make_list_slug(self.config[u'list']), u'items')
    if remove:
        args += (u'remove',)
    url = get_api_url(args)
    log.debug((u'Submitting    data    to    trakt.tv    (%s):    %s' % (url, found)))
    try:
        result = self.session.post(url, data=json.dumps(found), raise_status=False)
    except RequestException as e:
        log.error((u'Error    submitting    data    to    trakt.tv:    %s' % e))
        return
    if (200 <= result.status_code < 300):
        action = (u'deleted' if remove else u'added')
        res = result.json()
        for cat in (u'movies', u'shows', u'episodes', u'seasons'):
            res[action].setdefault(cat, 0)
        log.info(u'Successfully    {0}    to/from    list    {1}:    {movies}    movie(s),    {shows}    show(s),    {episodes}    episode(s),    {seasons}    season(s).'.format(action, self.config[u'list'], **res[action]))
        for (k, r) in res[u'not_found'].items():
            if r:
                log.debug((u'not    found    %s:    %s' % (k, r)))
        if (sum(res[action].values()) > 0):
            self.invalidate_cache()
    elif (result.status_code == 404):
        log.error((u'List    does    not    appear    to    exist    on    trakt:    %s' % self.config[u'list']))
    elif (result.status_code == 401):
        log.error(u'Authentication    error:    have    you    authorized    Flexget    on    Trakt.tv?')
        log.debug((u'trakt    response:    ' + result.text))
    else:
        log.error((u'Unknown    error    submitting    data    to    trakt.tv:    %s' % result.text))
