diff options
author | Joar Wandborg <git@wandborg.com> | 2011-11-21 00:06:59 +0100 |
---|---|---|
committer | Joar Wandborg <git@wandborg.com> | 2011-11-21 00:06:59 +0100 |
commit | a63b640f12896a873ebf96f9fe0ef62d0794bfe7 (patch) | |
tree | ade6c4076183f4fe34557e20796568c5988fd3a8 /mediagoblin/media_types | |
parent | 359781f075f22c6ea677e28756c8046b2f405e63 (diff) | |
download | mediagoblin-a63b640f12896a873ebf96f9fe0ef62d0794bfe7.tar.lz mediagoblin-a63b640f12896a873ebf96f9fe0ef62d0794bfe7.tar.xz mediagoblin-a63b640f12896a873ebf96f9fe0ef62d0794bfe7.zip |
Stashing changes
Diffstat (limited to 'mediagoblin/media_types')
-rw-r--r-- | mediagoblin/media_types/__init__.py | 26 | ||||
-rw-r--r-- | mediagoblin/media_types/video/processing.py | 49 | ||||
-rw-r--r-- | mediagoblin/media_types/video/transcoders.py | 1 |
3 files changed, 21 insertions, 55 deletions
diff --git a/mediagoblin/media_types/__init__.py b/mediagoblin/media_types/__init__.py index 49d3ab9d..2d13f5a6 100644 --- a/mediagoblin/media_types/__init__.py +++ b/mediagoblin/media_types/__init__.py @@ -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 diff --git a/mediagoblin/media_types/video/processing.py b/mediagoblin/media_types/video/processing.py index 027f527b..4e05a71c 100644 --- a/mediagoblin/media_types/video/processing.py +++ b/mediagoblin/media_types/video/processing.py @@ -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': {}}}) diff --git a/mediagoblin/media_types/video/transcoders.py b/mediagoblin/media_types/video/transcoders.py index f6a2eb21..8d80beda 100644 --- a/mediagoblin/media_types/video/transcoders.py +++ b/mediagoblin/media_types/video/transcoders.py @@ -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') |