'Set the initial episode of an existing show'

@api.response(200, u'Episodes    for    series    will    be    accepted    starting    with    ep_id', show_details_schema)
@api.response(Conflict)
@api.validate(series_edit_schema, description=ep_identifier_doc)
@api.doc(description=u'Set    a    begin    episode    or    alternate    names    using    a    show    ID.    Note    that    alternate    names    override    the    existing    names    (if    name    does    not    belong    to    a    different    show).')
def put(self, show_id, session):

    try:
        show = series.show_by_id(show_id, session=session)
    except NoResultFound:
        raise NotFoundError((u'Show    with    ID    %s    not    found' % show_id))
    data = request.json
    ep_id = data.get(u'begin_episode')
    alt_names = data.get(u'alternate_names')
    if ep_id:
        series.set_series_begin(show, ep_id)
    if alt_names:
        try:
            series.set_alt_names(alt_names, show, session)
        except PluginError as e:
            raise Conflict(e.value)
    return jsonify(series_details(show, begin=(ep_id is not None)))
