Panel improvements

- Added progress meter for video and audio media types.
- Changed the __repr__ method of a MediaEntry to display a bit more
  useful explanation.
- Added a new MediaEntry.state, 'processing', which means that the task
  is running the processor on the item currently.
- Fixed some PEP8 issues in user_pages/views.py
- Fixed the ATOM TAG URI to show the correct year.
This commit is contained in:
Joar Wandborg
2012-07-11 00:36:42 +02:00
parent 51eb0267d9
commit 6471291575
10 changed files with 101 additions and 27 deletions

View File

@@ -20,13 +20,14 @@ import os
from mediagoblin import mg_globals as mgg
from mediagoblin.processing import (create_pub_filepath, BadMediaFail,
FilenameBuilder)
FilenameBuilder, ProgressCallback)
from mediagoblin.media_types.audio.transcoders import (AudioTranscoder,
AudioThumbnailer)
_log = logging.getLogger(__name__)
def sniff_handler(media_file, **kw):
try:
transcoder = AudioTranscoder()
@@ -40,6 +41,7 @@ def sniff_handler(media_file, **kw):
return False
def process_audio(entry):
audio_config = mgg.global_config['media_type:mediagoblin.media_types.audio']
@@ -72,11 +74,13 @@ def process_audio(entry):
transcoder = AudioTranscoder()
with tempfile.NamedTemporaryFile() as webm_audio_tmp:
progress_callback = ProgressCallback(entry)
transcoder.transcode(
queued_filename,
webm_audio_tmp.name,
quality=audio_config['quality'])
quality=audio_config['quality'],
progress_callback=progress_callback)
transcoder.discover(webm_audio_tmp.name)

View File

@@ -206,7 +206,7 @@ class AudioTranscoder(object):
data = dict(message.structure)
if self.__on_progress:
self.__on_progress(data)
self.__on_progress(data.get('percent'))
_log.info('{0}% done...'.format(
data.get('percent')))

View File

@@ -19,7 +19,7 @@ import logging
from mediagoblin import mg_globals as mgg
from mediagoblin.processing import \
create_pub_filepath, FilenameBuilder, BaseProcessingFail
create_pub_filepath, FilenameBuilder, BaseProcessingFail, ProgressCallback
from mediagoblin.tools.translate import lazy_pass_to_ugettext as _
from . import transcoders
@@ -78,11 +78,13 @@ def process_video(entry):
with tmp_dst:
# Transcode queued file to a VP8/vorbis file that fits in a 640x640 square
progress_callback = ProgressCallback(entry)
transcoder = transcoders.VideoTranscoder()
transcoder.transcode(queued_filename, tmp_dst.name,
vp8_quality=video_config['vp8_quality'],
vp8_threads=video_config['vp8_threads'],
vorbis_quality=video_config['vorbis_quality'])
vorbis_quality=video_config['vorbis_quality'],
progress_callback=progress_callback)
# Push transcoded video to public storage
_log.debug('Saving medium...')

View File

@@ -625,7 +625,7 @@ class VideoTranscoder:
data = dict(message.structure)
if self._progress_callback:
self._progress_callback(data)
self._progress_callback(data.get('percent'))
_log.info('{percent}% done...'.format(
percent=data.get('percent')))