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
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)
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
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
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
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
# 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
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):