Stashing changes
This commit is contained in:
parent
359781f075
commit
a63b640f12
@ -17,11 +17,8 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
from mediagoblin.media_types import get_media_types
|
||||
|
||||
|
||||
MANDATORY_CELERY_IMPORTS = ['mediagoblin.process_media']
|
||||
MANDATORY_CELERY_IMPORTS = [i for i in get_media_types()]
|
||||
|
||||
print(MANDATORY_CELERY_IMPORTS)
|
||||
|
||||
|
@ -26,31 +26,33 @@ class FileTypeNotSupported(Exception):
|
||||
class InvalidFileType(Exception):
|
||||
pass
|
||||
|
||||
# This should be more dynamic in the future. Perhaps put it in the .ini?
|
||||
# -- Joar
|
||||
MEDIA_TYPES = [
|
||||
'mediagoblin.media_types.image',
|
||||
'mediagoblin.media_types.video']
|
||||
|
||||
|
||||
def get_media_types():
|
||||
'''
|
||||
Generator that returns the available media types
|
||||
'''
|
||||
for media_type in MEDIA_TYPES:
|
||||
yield media_type
|
||||
|
||||
|
||||
def get_media_managers():
|
||||
'''
|
||||
Generator that returns all available media managers
|
||||
'''
|
||||
for media_type in get_media_types():
|
||||
'''
|
||||
FIXME
|
||||
__import__ returns the lowest-level module. If the plugin is located
|
||||
outside the conventional plugin module tree, it will not be loaded
|
||||
properly because of the [...]ugin.media_types.
|
||||
|
||||
We need this if we want to support a separate site-specific plugin
|
||||
folder.
|
||||
'''
|
||||
try:
|
||||
__import__(media_type)
|
||||
except ImportError as e:
|
||||
raise Exception('ERROR: Could not import {0}: {1}'.format(media_type, e))
|
||||
raise Exception(
|
||||
_('ERROR: Could not import {media_type}: {exception}').format(
|
||||
media_type=media_type,
|
||||
exception=e))
|
||||
|
||||
yield media_type, sys.modules[media_type].MEDIA_MANAGER
|
||||
|
||||
@ -67,8 +69,8 @@ def get_media_type_and_manager(filename):
|
||||
ext = os.path.splitext(filename)[1].lower()
|
||||
else:
|
||||
raise InvalidFileType(
|
||||
'Could not find any file extension in "{0}"'.format(
|
||||
filename))
|
||||
_('Could not find any file extension in "{filename}"').format(
|
||||
filename=filename))
|
||||
|
||||
if ext[1:] in manager['accepted_extensions']:
|
||||
return media_type, manager
|
||||
|
@ -15,25 +15,21 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import tempfile
|
||||
import pkg_resources
|
||||
import os
|
||||
import logging
|
||||
import os
|
||||
|
||||
from celery.task import Task
|
||||
from celery import registry
|
||||
|
||||
from mediagoblin.db.util import ObjectId
|
||||
from mediagoblin import mg_globals as mgg
|
||||
from mediagoblin.util import lazy_pass_to_ugettext as _
|
||||
from mediagoblin.process_media.errors import BaseProcessingFail, BadMediaFail
|
||||
from mediagoblin.process_media import BaseProcessingFail
|
||||
from mediagoblin.process_media import mark_entry_failed
|
||||
from . import transcoders
|
||||
|
||||
THUMB_SIZE = 180, 180
|
||||
MEDIUM_SIZE = 640, 640
|
||||
|
||||
loop = None # Is this even used?
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.basicConfig()
|
||||
logger.setLevel(logging.DEBUG)
|
||||
@ -59,7 +55,11 @@ def process_video(entry):
|
||||
'source')
|
||||
|
||||
medium_filepath = create_pub_filepath(
|
||||
entry, '640p.webm')
|
||||
entry,
|
||||
'{original}-640p.webm'.format(
|
||||
original=os.path.splitext(
|
||||
queued_filepath[-1])[0] # Select the
|
||||
))
|
||||
|
||||
thumbnail_filepath = create_pub_filepath(
|
||||
entry, 'thumbnail.jpg')
|
||||
@ -163,38 +163,3 @@ class ProcessMedia(Task):
|
||||
|
||||
|
||||
process_media = registry.tasks[ProcessMedia.name]
|
||||
|
||||
|
||||
def mark_entry_failed(entry_id, exc):
|
||||
"""
|
||||
Mark a media entry as having failed in its conversion.
|
||||
|
||||
Uses the exception that was raised to mark more information. If the
|
||||
exception is a derivative of BaseProcessingFail then we can store extra
|
||||
information that can be useful for users telling them why their media failed
|
||||
to process.
|
||||
|
||||
Args:
|
||||
- entry_id: The id of the media entry
|
||||
|
||||
"""
|
||||
# Was this a BaseProcessingFail? In other words, was this a
|
||||
# type of error that we know how to handle?
|
||||
if isinstance(exc, BaseProcessingFail):
|
||||
# Looks like yes, so record information about that failure and any
|
||||
# metadata the user might have supplied.
|
||||
mgg.database['media_entries'].update(
|
||||
{'_id': entry_id},
|
||||
{'$set': {u'state': u'failed',
|
||||
u'fail_error': exc.exception_path,
|
||||
u'fail_metadata': exc.metadata}})
|
||||
else:
|
||||
# Looks like no, so just mark it as failed and don't record a
|
||||
# failure_error (we'll assume it wasn't handled) and don't record
|
||||
# metadata (in fact overwrite it if somehow it had previous info
|
||||
# here)
|
||||
mgg.database['media_entries'].update(
|
||||
{'_id': entry_id},
|
||||
{'$set': {u'state': u'failed',
|
||||
u'fail_error': None,
|
||||
u'fail_metadata': {}}})
|
||||
|
@ -56,7 +56,6 @@ try:
|
||||
import pygst
|
||||
pygst.require('0.10')
|
||||
import gst
|
||||
from gst import pbutils
|
||||
from gst.extend import discoverer
|
||||
except:
|
||||
raise Exception('gst/pygst 0.10 could not be found')
|
||||
|
@ -53,10 +53,13 @@ class ProcessMedia(Task):
|
||||
|
||||
# Try to process, and handle expected errors.
|
||||
try:
|
||||
__import__(entry['media_type'])
|
||||
process_image(entry)
|
||||
except BaseProcessingFail, exc:
|
||||
mark_entry_failed(entry[u'_id'], exc)
|
||||
return
|
||||
except ImportError, exc:
|
||||
mark_entry_failed(entry[u'_id'], exc)
|
||||
|
||||
entry['state'] = u'processed'
|
||||
entry.save()
|
||||
|
@ -28,8 +28,15 @@
|
||||
href="{{ request.staticdirect('/css/extlib/960_16_col.css') }}"/>
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="{{ request.staticdirect('/css/base.css') }}"/>
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="{{ request.staticdirect('/css/video-js.css') }}"/>
|
||||
<link rel="shortcut icon"
|
||||
href="{{ request.staticdirect('/images/goblin.ico') }}" />
|
||||
<script type="text/javascript"
|
||||
src="{{ request.staticdirect('/js/lib/video.js') }}"></script>
|
||||
<script type="text/javascript"
|
||||
src="{{ request.staticdirect('/js/video.js') }}"></script>
|
||||
<script type="text/javascript" src="http://html5.kaltura.org/js" > </script>
|
||||
{% block mediagoblin_head %}
|
||||
{% endblock mediagoblin_head %}
|
||||
</head>
|
||||
|
@ -1,11 +1,17 @@
|
||||
{% extends 'mediagoblin/user_pages/media.html' %}
|
||||
{% block mediagoblin_media %}
|
||||
<video width="{{ media.media_data.video.width }}"
|
||||
height="{{ media.media_data.video.height }}" controls="controls">
|
||||
<source src="{{ request.app.public_store.file_url(
|
||||
media['media_files']['webm_640']) }}"
|
||||
type='video/webm; codecs="vp8, vorbis"' />
|
||||
</video>
|
||||
<div class="video-player" style="position: relative;">
|
||||
<video class="video-js vjs-default-skin"
|
||||
width="{{ media.media_data.video.width }}"
|
||||
height="{{ media.media_data.video.height }}"
|
||||
controls="controls"
|
||||
preload="auto"
|
||||
data-setup="">
|
||||
<source src="{{ request.app.public_store.file_url(
|
||||
media['media_files']['webm_640']) }}"
|
||||
type="video/webm; codecs="vp8, vorbis"" />
|
||||
</video>
|
||||
</div>
|
||||
{% if 'original' in media.media_files %}
|
||||
<p>
|
||||
<a href="{{ request.app.public_store.file_url(
|
||||
|
Loading…
x
Reference in New Issue
Block a user