Exemple #1
0
def post_feed():
    """
    Insert feed
    """
    data = request.get_json(silent=True)
    type = data['type']
    if type == 1:
        video = data['video']
        title = video['title']
        description = video['description']
        url = video['url']
        v_result = Video.create(title=title, description=description, url=url)

    if type == 2:
        photo = data['photo']
        title = photo['title']
        description = photo['description']
        url = photo['url']
        Photo.create(title=title, description=description, url=url)

    if type == 3:
        article = data['news']

    print(data)

    if 'name' in data and 'description' in data and 'slug' in data:
        name = data['name']
        description = data['description']
        slug = data['slug']
        Feed.create(name=name, description=description, slug=slug)
        return make_response(jsonify({'success': True, 'result': 'Category Created'}), 201)
    else:
        return make_response(jsonify({'success': False, 'result': 'Incomplete parameters'}), 400)
Exemple #2
0
def batch_add_videos(datas):
    for data in datas:
        data['file_type'] = os.path.splitext(data['file_path'])[1].strip('.')
        data['file_size'] = get_size(data['file_path'])
        video = Video.create(data)
        res = video.to_dict()
        project_ids = data.get('project_ids', [])
        generate_project(res['id'], project_ids)
Exemple #3
0
def add_video():
    data = request.json
    data['file_type'] = os.path.splitext(data['file_path'])[1].strip('.')
    if data['file_type'] not in video_allow_extensions:
        raise ApiError('视频格式不正确')
    data['file_size'] = video_service.get_size(data['file_path'])
    video = Video.create(data)
    res = video.to_dict()
    project_ids = data.get('project_ids', [])
    video_service.generate_project(res['id'], project_ids)
    return api_success(res)