Skip to content

Commit

Permalink
Merge pull request #785 from Mrnt/movie-mime-type-support
Browse files Browse the repository at this point in the history
Fix mime type for video downloads
  • Loading branch information
ccrisan authored Feb 5, 2018
2 parents aef6801 + 293bde5 commit 8129256
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions motioneye/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import hashlib
import json
import logging
import mimetypes
import os
import re
import socket
Expand Down Expand Up @@ -1521,7 +1522,7 @@ def download(self, camera_id, filename):
content = mediafiles.get_media_content(camera_config, filename, 'movie')

pretty_filename = camera_config['@name'] + '_' + os.path.basename(filename)
self.set_header('Content-Type', 'video/mpeg')
self.set_header('Content-Type', mimetypes.guess_type(filename)[0] or 'video/mpeg')
self.set_header('Content-Disposition', 'attachment; filename=' + pretty_filename + ';')

self.finish(content)
Expand All @@ -1533,7 +1534,7 @@ def on_response(response=None, error=None):
'url': remote.pretty_camera_url(camera_config), 'msg': error}})

pretty_filename = os.path.basename(filename) # no camera name available w/o additional request
self.set_header('Content-Type', 'video/mpeg')
self.set_header('Content-Type', mimetypes.guess_type(filename)[0] or 'video/mpeg')
self.set_header('Content-Disposition', 'attachment; filename=' + pretty_filename + ';')

self.finish(response)
Expand Down
5 changes: 5 additions & 0 deletions motioneye/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4932,6 +4932,11 @@ function isFullScreen() {
function refreshCameraFrames() {
var timestamp = new Date().getTime();

if ($('div.modal-container').is(':visible')) {
/* pause camera refresh if hidden by a dialog */
return setTimeout(refreshCameraFrames, 1000);
}

function refreshCameraFrame(cameraId, img, serverSideResize) {
if (refreshDisabled[cameraId]) {
/* camera refreshing disabled, retry later */
Expand Down

0 comments on commit 8129256

Please sign in to comment.