aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElrond <elrond+mediagoblin.org@samba-tng.org>2011-12-13 21:35:15 +0100
committerElrond <elrond+mediagoblin.org@samba-tng.org>2011-12-13 21:35:15 +0100
commit8d52214f1e7b6d446fdf34fbfc8328f08eafbb1e (patch)
tree1e4748ff7d5957bfac141b545f93fde1e22d4985
parentbb3b9e4090706e1e9815c5132c01b9e706e31360 (diff)
parent4535f7597f112443d8997bbd6b8a445612c2440d (diff)
downloadmediagoblin-8d52214f1e7b6d446fdf34fbfc8328f08eafbb1e.tar.lz
mediagoblin-8d52214f1e7b6d446fdf34fbfc8328f08eafbb1e.tar.xz
mediagoblin-8d52214f1e7b6d446fdf34fbfc8328f08eafbb1e.zip
Merge remote branch 'joar/b681-comments_from_reviewing_video'
* joar/b681-comments_from_reviewing_video: Bug 681 - Comments from reviewing the new video merge
-rw-r--r--mediagoblin/media_types/__init__.py21
-rw-r--r--mediagoblin/media_types/image/processing.py9
-rw-r--r--mediagoblin/media_types/video/transcoders.py4
-rw-r--r--mediagoblin/views.py6
4 files changed, 23 insertions, 17 deletions
diff --git a/mediagoblin/media_types/__init__.py b/mediagoblin/media_types/__init__.py
index 25f3d255..6f94c714 100644
--- a/mediagoblin/media_types/__init__.py
+++ b/mediagoblin/media_types/__init__.py
@@ -30,7 +30,7 @@ class InvalidFileType(Exception):
def get_media_types():
"""
- Generator that returns the available media types
+ Generator, yields the available media types
"""
for media_type in mg_globals.app_config['media_types']:
yield media_type
@@ -38,7 +38,7 @@ def get_media_types():
def get_media_managers():
'''
- Generator that returns all available media managers
+ Generator, yields all enabled media managers
'''
for media_type in get_media_types():
__import__(media_type)
@@ -46,7 +46,16 @@ def get_media_managers():
yield media_type, sys.modules[media_type].MEDIA_MANAGER
-def get_media_manager(_media_type = None):
+def get_media_manager(_media_type):
+ '''
+ Get the MEDIA_MANAGER based on a media type string
+
+ Example::
+ get_media_type('mediagoblin.media_types.image')
+ '''
+ if not _media_type:
+ return False
+
for media_type, manager in get_media_managers():
if media_type in _media_type:
return manager
@@ -57,13 +66,19 @@ def get_media_manager(_media_type = None):
def get_media_type_and_manager(filename):
+ '''
+ Get the media type and manager based on a filename
+ '''
for media_type, manager in get_media_managers():
if filename.find('.') > 0:
+ # Get the file extension
ext = os.path.splitext(filename)[1].lower()
else:
raise InvalidFileType(
_('Could not find any file extension in "{filename}"').format(
filename=filename))
+ # Omit the dot from the extension and match it against
+ # the media manager
if ext[1:] in manager['accepted_extensions']:
return media_type, manager
diff --git a/mediagoblin/media_types/image/processing.py b/mediagoblin/media_types/image/processing.py
index 5b8259fc..e493eb2b 100644
--- a/mediagoblin/media_types/image/processing.py
+++ b/mediagoblin/media_types/image/processing.py
@@ -17,15 +17,10 @@
import Image
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.processing import BaseProcessingFail, \
- mark_entry_failed, BadMediaFail, create_pub_filepath, THUMB_SIZE, \
- MEDIUM_SIZE
+from mediagoblin.processing import BadMediaFail, \
+ create_pub_filepath, THUMB_SIZE, MEDIUM_SIZE
################################
# Media processing initial steps
diff --git a/mediagoblin/media_types/video/transcoders.py b/mediagoblin/media_types/video/transcoders.py
index d7ed14ca..7071b887 100644
--- a/mediagoblin/media_types/video/transcoders.py
+++ b/mediagoblin/media_types/video/transcoders.py
@@ -74,14 +74,14 @@ class VideoThumbnailer:
buffer_probes = {}
- errors = []
-
def __init__(self, source_path, dest_path):
'''
Set up playbin pipeline in order to get video properties.
Initializes and runs the gobject.MainLoop()
'''
+ self.errors = []
+
self.source_path = source_path
self.dest_path = dest_path
diff --git a/mediagoblin/views.py b/mediagoblin/views.py
index cd6aba9b..1e1db6c3 100644
--- a/mediagoblin/views.py
+++ b/mediagoblin/views.py
@@ -14,14 +14,11 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import sys
-
from mediagoblin import mg_globals
from mediagoblin.tools.pagination import Pagination
from mediagoblin.tools.response import render_to_response
from mediagoblin.db.util import DESCENDING
from mediagoblin.decorators import uses_pagination
-from mediagoblin import media_types
@@ -36,8 +33,7 @@ def root_view(request, page):
request, 'mediagoblin/root.html',
{'media_entries': media_entries,
'allow_registration': mg_globals.app_config["allow_registration"],
- 'pagination': pagination,
- 'sys': sys})
+ 'pagination': pagination})
def simple_template_render(request):