Ejemplo n.º 1
0
    def get(self, video_id):
        """
            Get a list of like by video id
        """
        try:
            video_id = request.url.split('/')[-2]
            token = get_jwt_identity()

            # check authority
            if service_auth_video_get(token, video_id) is False:
                raise RouteError(ErrorCode.ROUTE_PRIVATE_VIDEO)

            like_result = service_video_likes(video_id=video_id)
            return util_serializer_api_response(
                200, body=like_result, msg="Successfully got video likes")
        except (ServiceError, MongoError, RouteError, Exception) as e:
            return util_error_handler(e)
Ejemplo n.º 2
0
    def get(self, video_id):
        """
            Get video view comments list by video ID
        """
        # TODO
        # print("get user name", get_jwt_identity())
        try:
            video_id = request.url.split('/')[-2]
            token = get_jwt_identity()

            # check authority
            if service_auth_video_get(token, video_id) is False:
                raise RouteError(ErrorCode.ROUTE_PRIVATE_VIDEO)

            comments_result = service_video_comments(video_id=video_id)

            return util_serializer_api_response(
                200,
                body=comments_result,
                msg="Successfully got video comments")
        except (ServiceError, MongoError, RouteError, Exception) as e:
            return util_error_handler(e)
Ejemplo n.º 3
0
    def get(self, video_id):
        """
            Get video information by video ID
        """
        try:
            video_id = request.url.split('/')[-1]
            token = get_jwt_identity()

            video = service_video_info(video_id=request.url.split('/')[-1])

            # remove deleted video
            if video['video_status'] == 'deleted':
                raise RouteError(ErrorCode.ROUTE_DELETED_VIDEO)

            # check authority
            if service_auth_video_get(token, video_id) is False:
                raise RouteError(ErrorCode.ROUTE_PRIVATE_VIDEO)

            return util_serializer_api_response(
                200, body=video, msg="Successfully got video by ID.")
        except (ServiceError, MongoError, RouteError, Exception) as e:
            return util_error_handler(e)