Refactor video processing to use FilenameMunger.

This commit is contained in:
Brett Smith 2012-03-25 13:32:25 -04:00
parent ab35ad4605
commit 84725abd64

View File

@ -20,7 +20,7 @@ import os
from mediagoblin import mg_globals as mgg from mediagoblin import mg_globals as mgg
from mediagoblin.processing import mark_entry_failed, \ from mediagoblin.processing import mark_entry_failed, \
THUMB_SIZE, MEDIUM_SIZE, create_pub_filepath THUMB_SIZE, MEDIUM_SIZE, create_pub_filepath, FilenameMunger
from . import transcoders from . import transcoders
logging.basicConfig() logging.basicConfig()
@ -49,17 +49,13 @@ def process_video(entry):
queued_filename = workbench.localized_file( queued_filename = workbench.localized_file(
mgg.queue_store, queued_filepath, mgg.queue_store, queued_filepath,
'source') 'source')
name_munger = FilenameMunger(queued_filename)
medium_filepath = create_pub_filepath( medium_filepath = create_pub_filepath(
entry, entry, name_munger.munge('{basename}-640p.webm'))
'{original}-640p.webm'.format(
original=os.path.splitext(
queued_filepath[-1])[0] # Select the
))
thumbnail_filepath = create_pub_filepath( thumbnail_filepath = create_pub_filepath(
entry, 'thumbnail.jpg') entry, name_munger.munge('{basename}.thumbnail.jpg'))
# Create a temporary file for the video destination # Create a temporary file for the video destination
tmp_dst = tempfile.NamedTemporaryFile() tmp_dst = tempfile.NamedTemporaryFile()