mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-25 23:02:26 +00:00
Merge pull request #1966 from haiwen/video-thumb
udpate generate video thumbnail
This commit is contained in:
@@ -38,7 +38,7 @@ from seahub.group.utils import is_group_member, is_group_admin_or_owner, \
|
|||||||
get_group_member_info
|
get_group_member_info
|
||||||
import seahub.settings as settings
|
import seahub.settings as settings
|
||||||
from seahub.settings import ENABLE_THUMBNAIL, THUMBNAIL_ROOT, \
|
from seahub.settings import ENABLE_THUMBNAIL, THUMBNAIL_ROOT, \
|
||||||
THUMBNAIL_DEFAULT_SIZE, SHOW_TRAFFIC, MEDIA_URL
|
THUMBNAIL_DEFAULT_SIZE, SHOW_TRAFFIC, MEDIA_URL, ENABLE_VIDEO_THUMBNAIL
|
||||||
from seahub.utils import check_filename_with_rename, EMPTY_SHA1, \
|
from seahub.utils import check_filename_with_rename, EMPTY_SHA1, \
|
||||||
gen_block_get_url, TRAFFIC_STATS_ENABLED, get_user_traffic_stat,\
|
gen_block_get_url, TRAFFIC_STATS_ENABLED, get_user_traffic_stat,\
|
||||||
new_merge_with_no_conflict, get_commit_before_new_merge, \
|
new_merge_with_no_conflict, get_commit_before_new_merge, \
|
||||||
@@ -345,14 +345,23 @@ def list_lib_dir(request, repo_id):
|
|||||||
f_['obj_id'] = f.obj_id
|
f_['obj_id'] = f.obj_id
|
||||||
f_['perm'] = f.permission # perm for file in current dir
|
f_['perm'] = f.permission # perm for file in current dir
|
||||||
|
|
||||||
file_type, file_ext = get_file_type_and_ext(f.obj_name)
|
if not repo.encrypted and ENABLE_THUMBNAIL:
|
||||||
if file_type == IMAGE:
|
# used for providing a way to determine
|
||||||
f_['is_img'] = True
|
# if send a request to create thumbnail.
|
||||||
if file_type == VIDEO:
|
file_type, file_ext = get_file_type_and_ext(f.obj_name)
|
||||||
f_['is_video'] = True
|
if file_type == IMAGE:
|
||||||
if file_type == IMAGE or file_type == VIDEO:
|
f_['is_img'] = True
|
||||||
if not repo.encrypted and ENABLE_THUMBNAIL and \
|
|
||||||
os.path.exists(os.path.join(THUMBNAIL_ROOT, str(size), f.obj_id)):
|
if file_type == VIDEO and ENABLE_VIDEO_THUMBNAIL:
|
||||||
|
f_['is_video'] = True
|
||||||
|
|
||||||
|
# if thumbnail has already been created, return its src.
|
||||||
|
# Then web browser will use this src to get thumbnail instead of
|
||||||
|
# recreating it.
|
||||||
|
thumbnail_file_path = os.path.join(THUMBNAIL_ROOT, str(size), f.obj_id)
|
||||||
|
thumbnail_exist = os.path.exists(thumbnail_file_path)
|
||||||
|
if thumbnail_exist and (file_type == IMAGE or
|
||||||
|
file_type == VIDEO and ENABLE_VIDEO_THUMBNAIL):
|
||||||
file_path = posixpath.join(path, f.obj_name)
|
file_path = posixpath.join(path, f.obj_name)
|
||||||
src = get_thumbnail_src(repo_id, size, file_path)
|
src = get_thumbnail_src(repo_id, size, file_path)
|
||||||
f_['encoded_thumbnail_src'] = urlquote(src)
|
f_['encoded_thumbnail_src'] = urlquote(src)
|
||||||
|
Reference in New Issue
Block a user