-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use same base ALLOWED_FORMATS list as thumbor (#25)
- Loading branch information
Showing
1 changed file
with
12 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,31 @@ | ||
from thumbor.filters import BaseFilter, filter_method, PHASE_PRE_LOAD | ||
import thumbor.filters.format | ||
from thumbor.utils import logger | ||
|
||
from thumbor_video_engine.compat import filter_retval | ||
|
||
|
||
ALLOWED_FORMATS = [ | ||
'png', 'jpeg', 'jpg', 'gif', 'webp', 'webm', 'mp4', 'hevc', 'h264', 'h265', 'vp9'] | ||
ALLOWED_FORMATS = list(thumbor.filters.format.ALLOWED_FORMATS) + [ | ||
"webm", | ||
"mp4", | ||
"hevc", | ||
"h264", | ||
"h265", | ||
"vp9", | ||
] | ||
|
||
|
||
class Filter(BaseFilter): | ||
phase = PHASE_PRE_LOAD | ||
|
||
@filter_method(BaseFilter.String) | ||
def format(self, format): | ||
logger.debug('Setting format to %s' % format) | ||
logger.debug("Setting format to %s" % format) | ||
if format.lower() not in ALLOWED_FORMATS: | ||
logger.warning('Format not allowed: %s' % format.lower()) | ||
logger.warning("Format not allowed: %s" % format.lower()) | ||
self.context.request.format = None | ||
else: | ||
logger.debug('Format specified: %s' % format.lower()) | ||
logger.debug("Format specified: %s" % format.lower()) | ||
self.context.request.format = format.lower() | ||
|
||
return filter_retval() |