diff --git a/contrib/frontends/django/nntpchan/nntpchan/settings.py b/contrib/frontends/django/nntpchan/nntpchan/settings.py index 5678e48..0614256 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/settings.py +++ b/contrib/frontends/django/nntpchan/nntpchan/settings.py @@ -127,3 +127,7 @@ ASSETS_ROOT = os.path.join(BASE_DIR, 'assets') MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/' + +# for thumbnailing +CONVERT_PATH = '/usr/bin/convert' +FFMPEG_PATH = '/usr/bin/ffmpeg' diff --git a/contrib/frontends/django/nntpchan/nntpchan/thumbnail.py b/contrib/frontends/django/nntpchan/nntpchan/thumbnail.py index dc0190b..e29bb9a 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/thumbnail.py +++ b/contrib/frontends/django/nntpchan/nntpchan/thumbnail.py @@ -1,8 +1,8 @@ +from django.conf import settings import subprocess import os -img_ext = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'ico'] -vid_ext = ['mp4', 'webm', 'm4v', 'ogv', 'avi'] -txt_ext = ['txt', 'pdf', 'ps'] +img_ext = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'ico', 'pdf', 'ps'] +vid_ext = ['mp4', 'webm', 'm4v', 'ogv', 'avi', 'txt'] def generate(fname, tname, placeholder): """ @@ -11,9 +11,9 @@ def generate(fname, tname, placeholder): ext = fname.split('.')[-1] cmd = None if ext in img_ext: - cmd = ['/usr/bin/convert', '-thumbnail', '200', fname, tname] - elif ext in vid_ext or ext in txt_ext: - cmd = ['/usr/bin/ffmpeg', '-i', fname, '-vf', 'scale=300:200', '-vframes', '1', tname] + cmd = [settings.CONVERT_PATH, '-thumbnail', '200', fname, tname] + elif ext in vid_ext: + cmd = [settings.FFMPEG_PATH, '-i', fname, '-vf', 'scale=300:200', '-vframes', '1', tname] if cmd is None: os.link(placeholder, tname)