converted video media_type to plugin
This commit is contained in:
parent
239296b004
commit
cbac4a7fc9
@ -17,20 +17,40 @@
|
||||
from mediagoblin.media_types import MediaManagerBase
|
||||
from mediagoblin.media_types.video.processing import process_video, \
|
||||
sniff_handler
|
||||
from mediagoblin.tools import pluginapi
|
||||
|
||||
MEDIA_TYPE = 'mediagoblin.media_types.video'
|
||||
ACCEPTED_EXTENSIONS = [
|
||||
"mp4", "mov", "webm", "avi", "3gp", "3gpp", "mkv", "ogv", "m4v"]
|
||||
|
||||
|
||||
def setup_plugin():
|
||||
config = pluginapi.get_config(MEDIA_TYPE)
|
||||
|
||||
|
||||
class VideoMediaManager(MediaManagerBase):
|
||||
human_readable = "Video"
|
||||
processor = staticmethod(process_video)
|
||||
sniff_handler = staticmethod(sniff_handler)
|
||||
display_template = "mediagoblin/media_displays/video.html"
|
||||
default_thumb = "images/media_thumbs/video.jpg"
|
||||
accepted_extensions = [
|
||||
"mp4", "mov", "webm", "avi", "3gp", "3gpp", "mkv", "ogv", "m4v"]
|
||||
|
||||
# Used by the media_entry.get_display_media method
|
||||
media_fetch_order = [u'webm_640', u'original']
|
||||
default_webm_type = 'video/webm; codecs="vp8, vorbis"'
|
||||
|
||||
|
||||
MEDIA_MANAGER = VideoMediaManager
|
||||
def get_media_manager(media_type):
|
||||
if media_type == MEDIA_TYPE:
|
||||
return VideoMediaManager
|
||||
|
||||
|
||||
def get_media_type_and_manager(ext):
|
||||
if ext in ACCEPTED_EXTENSIONS:
|
||||
return MEDIA_TYPE, VideoMediaManager
|
||||
|
||||
hooks = {
|
||||
'setup': setup_plugin,
|
||||
'get_media_type_and_manager': get_media_type_and_manager,
|
||||
'sniff_handler': sniff_handler,
|
||||
'get_media_manager': get_media_manager,
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ from .util import skip_transcode
|
||||
_log = logging.getLogger(__name__)
|
||||
_log.setLevel(logging.DEBUG)
|
||||
|
||||
MEDIA_TYPE = 'mediagoblin.media_types.video'
|
||||
|
||||
|
||||
class VideoTranscodingFail(BaseProcessingFail):
|
||||
'''
|
||||
@ -41,17 +43,18 @@ def sniff_handler(media_file, **kw):
|
||||
transcoder = transcoders.VideoTranscoder()
|
||||
data = transcoder.discover(media_file.name)
|
||||
|
||||
_log.info('Sniffing {0}'.format(MEDIA_TYPE))
|
||||
_log.debug('Discovered: {0}'.format(data))
|
||||
|
||||
if not data:
|
||||
_log.error('Could not discover {0}'.format(
|
||||
kw.get('media')))
|
||||
return False
|
||||
return None
|
||||
|
||||
if data['is_video'] == True:
|
||||
return True
|
||||
return MEDIA_TYPE
|
||||
|
||||
return False
|
||||
return None
|
||||
|
||||
|
||||
def process_video(proc_state):
|
||||
|
Loading…
x
Reference in New Issue
Block a user