diff options
author | Rodney Ewing <ewing.rj@gmail.com> | 2013-08-15 08:54:09 -0700 |
---|---|---|
committer | Rodney Ewing <ewing.rj@gmail.com> | 2013-08-16 15:30:23 -0700 |
commit | 1cefccc7554a5df4c9bb126ef3b80b53f9e41cd7 (patch) | |
tree | 90a148e6ec77ee6c452dbb24fe236b7d3c88d0d9 /mediagoblin/processing | |
parent | 9b1317e3e29b87a6e9959583ff27a62c844f48b3 (diff) | |
download | mediagoblin-1cefccc7554a5df4c9bb126ef3b80b53f9e41cd7.tar.lz mediagoblin-1cefccc7554a5df4c9bb126ef3b80b53f9e41cd7.tar.xz mediagoblin-1cefccc7554a5df4c9bb126ef3b80b53f9e41cd7.zip |
refactor get_orig_filename to return an acceptable filename to the processor.
If there is an original video file and we skip transcoding, delete the webm_640 file
Diffstat (limited to 'mediagoblin/processing')
-rw-r--r-- | mediagoblin/processing/__init__.py | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/mediagoblin/processing/__init__.py b/mediagoblin/processing/__init__.py index e2415fd5..746f4d8e 100644 --- a/mediagoblin/processing/__init__.py +++ b/mediagoblin/processing/__init__.py @@ -327,29 +327,34 @@ def mark_entry_failed(entry_id, exc): u'fail_metadata': {}}) -def get_orig_filename(entry, workbench): +def get_process_filename(entry, workbench, acceptable_files): """ - Get the a filename for the original, on local storage + Try and get the queued file if available, otherwise return the first file + in the acceptable_files that we have. - If the media entry has a queued_media_file, use that, otherwise - use the original. - - In the future, this will return the highest quality file available - if neither the original or queued file are available by checking - some ordered list of preferred keys. + If no acceptable_files, raise ProcessFileNotFound """ if entry.queued_media_file: - orig_filepath = entry.queued_media_file + filepath = entry.queued_media_file storage = mgg.queue_store else: - orig_filepath = entry.media_files['original'] - storage = mgg.public_store + for keyname in acceptable_files: + if entry.media_files.get(keyname): + filepath = entry.media_files[keyname] + storage = mgg.public_store + break + + if not filepath: + raise ProcessFileNotFound() - orig_filename = workbench.localized_file( - storage, orig_filepath, + filename = workbench.localized_file( + storage, filepath, 'source') - return orig_filename + if not os.path.exists(filename): + raise ProcessFileNotFound() + + return filename def store_public(entry, keyname, local_file, target_name=None, @@ -415,3 +420,11 @@ class PublicStoreFail(BaseProcessingFail): Error that should be raised when copying to public store fails """ general_message = _('Copying to public storage failed.') + + +class ProcessFileNotFound(BaseProcessingFail): + """ + Error that should be raised when an acceptable file for processing + is not found. + """ + general_message = _(u'An acceptable processing file was not found') |