diff options
| author | Shyam Sunder <sgsunder1@gmail.com> | 2020-04-02 16:17:26 -0400 |
|---|---|---|
| committer | Shyam Sunder <sgsunder1@gmail.com> | 2020-04-03 13:11:54 -0400 |
| commit | 99a69333e656fcbf7acf55f8593cf2a70781fc6d (patch) | |
| tree | 1b858da2bdb7f5af9e39ee95358b569649ddd016 /server/szurubooru/api/post_api.py | |
| parent | 08e62ec8853d7564ac718471be7fd32739a0bf90 (diff) | |
server/posts/upload: Add youtube-dl functionality
allows for video-based posts to be created by using youtube-dl
on the server. Access is controlled with the 'uploads:use_downloader'
permission.
Diffstat (limited to 'server/szurubooru/api/post_api.py')
| -rw-r--r-- | server/szurubooru/api/post_api.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/server/szurubooru/api/post_api.py b/server/szurubooru/api/post_api.py index 09aea90..6d48fbd 100644 --- a/server/szurubooru/api/post_api.py +++ b/server/szurubooru/api/post_api.py @@ -2,7 +2,8 @@ from typing import Optional, Dict, List from datetime import datetime from szurubooru import db, model, errors, rest, search from szurubooru.func import ( - auth, tags, posts, snapshots, favorites, scores, serialization, versions) + auth, tags, posts, snapshots, favorites, scores, + serialization, versions, mime) _search_executor_config = search.configs.PostSearchConfig() @@ -46,7 +47,10 @@ def create_post( auth.verify_privilege(ctx.user, 'posts:create:anonymous') else: auth.verify_privilege(ctx.user, 'posts:create:identified') - content = ctx.get_file('content') + content = ctx.get_file( + 'content', + use_video_downloader=auth.has_privilege( + ctx.user, 'uploads:use_downloader')) tag_names = ctx.get_param_as_string_list('tags', default=[]) safety = ctx.get_param_as_string('safety') source = ctx.get_param_as_string('source', default='') @@ -105,7 +109,10 @@ def update_post(ctx: rest.Context, params: Dict[str, str]) -> rest.Response: versions.bump_version(post) if ctx.has_file('content'): auth.verify_privilege(ctx.user, 'posts:edit:content') - posts.update_post_content(post, ctx.get_file('content')) + posts.update_post_content( + post, + ctx.get_file('content', use_video_downloader=auth.has_privilege( + ctx.user, 'uploads:use_downloader'))) if ctx.has_param('tags'): auth.verify_privilege(ctx.user, 'posts:edit:tags') new_tags = posts.update_post_tags( |