Beispiel #1
0
    def put(self, show_id, session):
        """ Set the initial episode of an existing show """
        try:
            show = series.show_by_id(show_id, session=session)
        except NoResultFound:
            return {'status': 'error',
                    'message': 'Show with ID %s not found' % show_id
                    }, 404
        data = request.json
        ep_id = data.get('episode_identifier')
        alt_names = data.get('alternate_names')
        if ep_id:
            try:
                series.set_series_begin(show, ep_id)
            except ValueError as e:
                return {'status': 'error',
                        'message': e.args[0]
                        }, 501
        if alt_names:
            try:
                series.set_alt_names(alt_names, show, session)
            except PluginError as e:
                return {'status': 'error',
                        'message': e.value
                        }, 502

        return jsonify(get_series_details(show))
Beispiel #2
0
    def put(self, show_id, session):
        """ Set the initial episode of an existing show """
        try:
            show = series.show_by_id(show_id, session=session)
        except NoResultFound:
            return {'status': 'error',
                    'message': 'Show with ID %s not found' % show_id
                    }, 404
        data = request.json
        ep_id = data.get('episode_identifier')
        alt_names = data.get('alternate_names')
        if ep_id:
            try:
                series.set_series_begin(show, ep_id)
            except ValueError as e:
                return {'status': 'error',
                        'message': e.args[0]
                        }, 501
        if alt_names:
            try:
                series.set_alt_names(alt_names, show, session)
            except PluginError as e:
                return {'status': 'error',
                        'message': e.value
                        }, 502

        return jsonify(get_series_details(show))
Beispiel #3
0
    def post(self, session):
        """ Create a new show and set its first accepted episode and/or alternate names """
        data = request.json
        series_name = data.get('series_name')

        normalized_name = series.normalize_series_name(series_name)
        matches = series.shows_by_exact_name(normalized_name, session=session)
        if matches:
            return {'status': 'error',
                    'message': 'Show `%s` already exist in DB' % series_name
                    }, 500
        show = series.Series()
        show.name = series_name
        session.add(show)

        ep_id = data.get('episode_identifier')
        alt_names = data.get('alternate_names')
        if ep_id:
            try:
                series.set_series_begin(show, ep_id)
            except ValueError as e:
                return {'status': 'error',
                        'message': e.args[0]
                        }, 501
        if alt_names:
            try:
                series.set_alt_names(alt_names, show, session)
            except PluginError as e:
                return {'status': 'error',
                        'message': e.value
                        }, 502

        return jsonify(get_series_details(show))
Beispiel #4
0
    def post(self, session):
        """ Create a new show and set its first accepted episode and/or alternate names """
        data = request.json
        series_name = data.get('series_name')

        normalized_name = series.normalize_series_name(series_name)
        matches = series.shows_by_exact_name(normalized_name, session=session)
        if matches:
            return {'status': 'error',
                    'message': 'Show `%s` already exist in DB' % series_name
                    }, 500
        show = series.Series()
        show.name = series_name
        session.add(show)

        ep_id = data.get('episode_identifier')
        alt_names = data.get('alternate_names')
        if ep_id:
            try:
                series.set_series_begin(show, ep_id)
            except ValueError as e:
                return {'status': 'error',
                        'message': e.args[0]
                        }, 501
        if alt_names:
            try:
                series.set_alt_names(alt_names, show, session)
            except PluginError as e:
                return {'status': 'error',
                        'message': e.value
                        }, 502

        return jsonify(get_series_details(show))
Beispiel #5
0
    def post(self, session):
        """ Create a new show and set its first accepted episode and/or alternate names """
        data = request.json
        series_name = data.get('name')

        normalized_name = series.normalize_series_name(series_name)
        matches = series.shows_by_exact_name(normalized_name, session=session)
        if matches:
            raise Conflict('Show `%s` already exist in DB' % series_name)
        show = series.Series()
        show.name = series_name
        session.add(show)

        ep_id = data.get('begin_episode')
        alt_names = data.get('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:
                # Alternate name already exist for a different show
                raise Conflict(e.value)
        session.commit()
        rsp = jsonify(series_details(show, begin=ep_id is not None))
        rsp.status_code = 201
        return rsp
Beispiel #6
0
    def post(self, session):
        """ Create a new show and set its first accepted episode and/or alternate names """
        data = request.json
        series_name = data.get('name')

        normalized_name = series.normalize_series_name(series_name)
        matches = series.shows_by_exact_name(normalized_name, session=session)
        if matches:
            raise Conflict('Show `%s` already exist in DB' % series_name)
        show = series.Series()
        show.name = series_name
        session.add(show)

        ep_id = data.get('begin_episode')
        alt_names = data.get('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:
                # Alternate name already exist for a different show
                raise Conflict(e.value)
        session.commit()
        rsp = jsonify(series_details(show, begin=ep_id is not None))
        rsp.status_code = 201
        return rsp
Beispiel #7
0
 def put(self, show_id, session):
     """ Set the initial episode of an existing show """
     try:
         show = series.show_by_id(show_id, session=session)
     except NoResultFound:
         raise NotFoundError('Show with ID %s not found' % show_id)
     data = request.json
     ep_id = data.get('begin_episode')
     alt_names = data.get('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:
             # Alternate name already exist for a different show
             raise Conflict(e.value)
     return jsonify(series_details(show, begin=ep_id is not None))
Beispiel #8
0
 def put(self, show_id, session):
     """ Set the initial episode of an existing show """
     try:
         show = series.show_by_id(show_id, session=session)
     except NoResultFound:
         raise NotFoundError('Show with ID %s not found' % show_id)
     data = request.json
     ep_id = data.get('begin_episode')
     alt_names = data.get('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:
             # Alternate name already exist for a different show
             raise Conflict(e.value)
     return jsonify(series_details(show, begin=ep_id is not None))