Stashing changes
authorJoar Wandborg <git@wandborg.com>
Sun, 20 Nov 2011 23:06:59 +0000 (00:06 +0100)
committerJoar Wandborg <git@wandborg.com>
Sun, 20 Nov 2011 23:06:59 +0000 (00:06 +0100)
mediagoblin/init/celery/__init__.py
mediagoblin/media_types/__init__.py
mediagoblin/media_types/video/processing.py
mediagoblin/media_types/video/transcoders.py
mediagoblin/process_media/__init__.py
mediagoblin/templates/mediagoblin/base.html
mediagoblin/templates/mediagoblin/media_displays/video.html
setup.py

index 05c54b0542b3fc79356cd86879b71cabc113743c..c5d3742021ebc12f0d99e02df3c1c9ce62832c55 100644 (file)
 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)
 
index 49d3ab9dcd146c7498cea67434063c78224d4624..2d13f5a6ce35d4742d7daf7663d004eb2035165e 100644 (file)
@@ -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
index 027f527bfc13e18537b668fe255803c2d4b1c573..4e05a71c111b28d0bdbe8b90b8e19a14039805f3 100644 (file)
 # 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': {}}})
index f6a2eb214951d96dae8ac07c405274327e1495b4..8d80beda964a6eaeb9f86d6d4f5b216ee96a7dbe 100644 (file)
@@ -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')
index 2b9eed6e111a051afe1001262caa85c17305a9c7..96fe49fe62bbccd0f3b28e0d2dbf71e5cac380f3 100644 (file)
@@ -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()
index b4c4dcf33539f7aa04d0284534761e8b63052c50..bad22e7e5b94aecab834a550920141d91a04fa8c 100644 (file)
           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>
index bff9889a17094f3f410980b44d00da4570a6f34c..5b8ec7895c22e3734a04cb5e16d7d9930ff29d7d 100644 (file)
@@ -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=&quot;vp8, vorbis&quot;" />
+    </video>
+  </div>
   {% if 'original' in media.media_files %}
   <p>
     <a href="{{ request.app.public_store.file_url(
index 605349f080275ba1f0baa818464e0c5a0c1869ba..ccd1f653f80e393cce954488d3977ae2727262cc 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -61,7 +61,6 @@ setup(
         'ConfigObj',
         'Markdown',
         'python-cloudfiles',
-        'pygtk',
         ## For now we're expecting that users will install this from
         ## their package managers.
         # 'lxml',