summaryrefslogtreecommitdiff
path: root/mediabrowser/__init__.py
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2015-12-31 17:35:15 +0100
committerYves Fischer <yvesf-git@xapek.org>2016-01-08 20:38:18 +0100
commit988f8cfc74446e7aa58f6e0ce916110e9ed23ca8 (patch)
treeb4239e1de001dec8cdbee8a1070de44b548bc373 /mediabrowser/__init__.py
parent8378a89bbd5b54d8efb064581725a765fb54740a (diff)
downloadflask-mediabrowser-988f8cfc74446e7aa58f6e0ce916110e9ed23ca8.tar.gz
flask-mediabrowser-988f8cfc74446e7aa58f6e0ce916110e9ed23ca8.zip
video thumbnails
Diffstat (limited to 'mediabrowser/__init__.py')
-rw-r--r--mediabrowser/__init__.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/mediabrowser/__init__.py b/mediabrowser/__init__.py
index 6927205..8766ac2 100644
--- a/mediabrowser/__init__.py
+++ b/mediabrowser/__init__.py
@@ -70,7 +70,7 @@ def build(root_directory, cache):
'.webm': 'video/webm',
'.flv': 'video/x-flv',
'.mp4': 'video/mp4',
- '.mpg': 'video/mp2t'}
+ '.mpg': 'video/MP2T'}
(filetype, encoding) = mimetypes.guess_type(path)
if filetype is None:
@@ -145,6 +145,20 @@ def build(root_directory, cache):
r.last_modified = mtime
return r
+ @blueprint.route('/<path:path>/thumbnail_video')
+ def thumbnail_video(path):
+ path = os.path.normpath(path)
+ ospath = os.path.join(root_directory, path)
+ client_mtime = request.if_modified_since
+ mtime = datetime.fromtimestamp(os.stat(ospath).st_mtime)
+ if client_mtime is not None and mtime <= client_mtime:
+ return Response(status=304)
+ else:
+ thumbnail_stream = ffmpeg.thumbnail_video(ospath, 90, 50)
+ r = Response(thumbnail_stream, mimetype="video/webm")
+ r.last_modified = mtime
+ return r
+
@blueprint.route('/<path:path>/download/inline')
def download_inline(path):
return download(path, inline=True)