示例#1
0
def list_actor_related_videos(date, actor, video):
    raise_date_error, raise_actor_error, raise_video_error = True, True, True

    db_date = check_date(date)
    raise_date_error = db_date is None

    if raise_date_error:
        status_code = 450
        raise InvalidUsage(get_error_message(status_code),
                           status_code=status_code)

    actor = actor.replace('_', ' ')
    result_actor = DBYouTube.get_info_actor(db_date, actor)
    raise_actor_error = result_actor is None

    if raise_actor_error:
        status_code = 460
        raise InvalidUsage(get_error_message(status_code),
                           status_code=status_code)

    result = DBYouTube.get_video_by_actor(db_date, result_actor['channel_id'],
                                          video)

    raise_video_error = result is None
    if raise_video_error:
        status_code = 470
        raise InvalidUsage(get_error_message(status_code),
                           status_code=status_code)

    return jsonify(result)
示例#2
0
def list_actor_channel_info(date, actor):

    raise_date_error, raise_actor_error = True, True
    db_date = check_date(date)
    raise_date_error = db_date is None

    if raise_date_error:
        status_code = 450
        raise InvalidUsage(get_error_message(status_code),
                           status_code=status_code)

    actor = actor.replace('_', ' ')
    result_actor = DBYouTube.get_info_actor(db_date, actor)
    raise_actor_error = result_actor is None

    if raise_actor_error:
        status_code = 460
        raise InvalidUsage(get_error_message(status_code),
                           status_code=status_code)

    return jsonify(result_actor)
 def test_db_get_info_actor_name(self):
     actor = DBYouTube.get_info_actor('2018-06-14', 'Marina Silva')
     self.assertEqual(actor['actor_name'], 'Marina Silva')
 def test_db_get_info_actor_none(self):
     actor = DBYouTube.get_info_actor('2018-06-14', 'Bolsonaro')
     self.assertEqual(actor, None)