From 761389507d4944498132ea7c126165c7a91ed78b Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Mon, 29 Apr 2013 05:45:05 +0530 Subject: [PATCH] Make all media types use the new MediaManager classes. --- mediagoblin/media_types/ascii/__init__.py | 20 ++++++++-------- mediagoblin/media_types/audio/__init__.py | 17 +++++++++----- mediagoblin/media_types/pdf/__init__.py | 20 ++++++++-------- mediagoblin/media_types/stl/__init__.py | 18 +++++++++------ mediagoblin/media_types/video/__init__.py | 28 ++++++++++++----------- 5 files changed, 59 insertions(+), 44 deletions(-) diff --git a/mediagoblin/media_types/ascii/__init__.py b/mediagoblin/media_types/ascii/__init__.py index 856d1d7b..0931e83a 100644 --- a/mediagoblin/media_types/ascii/__init__.py +++ b/mediagoblin/media_types/ascii/__init__.py @@ -14,16 +14,18 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from mediagoblin.media_types import MediaManagerBase from mediagoblin.media_types.ascii.processing import process_ascii, \ sniff_handler -MEDIA_MANAGER = { - "human_readable": "ASCII", - "processor": process_ascii, # alternately a string, - # 'mediagoblin.media_types.image.processing'? - "sniff_handler": sniff_handler, - "display_template": "mediagoblin/media_displays/ascii.html", - "default_thumb": "images/media_thumbs/ascii.jpg", - "accepted_extensions": [ - "txt", "asc", "nfo"]} +class ASCIIMediaManager(MediaManagerBase): + human_readable = "ASCII" + processor = staticmethod(process_ascii) + sniff_handler = staticmethod(sniff_handler) + display_template = "mediagoblin/media_displays/ascii.html" + default_thumb = "images/media_thumbs/ascii.jpg" + accepted_extensions = ["txt", "asc", "nfo"] + + +MEDIA_MANAGER = ASCIIMediaManager diff --git a/mediagoblin/media_types/audio/__init__.py b/mediagoblin/media_types/audio/__init__.py index 4f3ead60..2eb7300e 100644 --- a/mediagoblin/media_types/audio/__init__.py +++ b/mediagoblin/media_types/audio/__init__.py @@ -14,12 +14,17 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from mediagoblin.media_types import MediaManagerBase from mediagoblin.media_types.audio.processing import process_audio, \ sniff_handler -MEDIA_MANAGER = { - 'human_readable': 'Audio', - 'processor': process_audio, - 'sniff_handler': sniff_handler, - 'display_template': 'mediagoblin/media_displays/audio.html', - 'accepted_extensions': ['mp3', 'flac', 'wav', 'm4a']} + +class AudioMediaManager(MediaManagerBase): + human_readable = "Audio" + processor = staticmethod(process_audio) + sniff_handler = staticmethod(sniff_handler) + display_template = "mediagoblin/media_displays/audio.html" + accepted_extensions = ["mp3", "flac", "wav", "m4a"] + + +MEDIA_MANAGER = AudioMediaManager diff --git a/mediagoblin/media_types/pdf/__init__.py b/mediagoblin/media_types/pdf/__init__.py index a6d23c93..f0ba7867 100644 --- a/mediagoblin/media_types/pdf/__init__.py +++ b/mediagoblin/media_types/pdf/__init__.py @@ -14,16 +14,18 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from mediagoblin.media_types import MediaManagerBase from mediagoblin.media_types.pdf.processing import process_pdf, \ sniff_handler -MEDIA_MANAGER = { - "human_readable": "PDF", - "processor": process_pdf, # alternately a string, - # 'mediagoblin.media_types.image.processing'? - "sniff_handler": sniff_handler, - "display_template": "mediagoblin/media_displays/pdf.html", - "default_thumb": "images/media_thumbs/pdf.jpg", - "accepted_extensions": [ - "pdf"]} +class PDFMediaManager(MediaManagerBase): + human_readable = "PDF" + processor = staticmethod(process_pdf) + sniff_handler = staticmethod(sniff_handler) + display_template = "mediagoblin/media_displays/pdf.html" + default_thumb = "images/media_thumbs/pdf.jpg" + accepted_extensions = ["pdf"] + + +MEDIA_MANAGER = PDFMediaManager diff --git a/mediagoblin/media_types/stl/__init__.py b/mediagoblin/media_types/stl/__init__.py index edffc633..b691e43d 100644 --- a/mediagoblin/media_types/stl/__init__.py +++ b/mediagoblin/media_types/stl/__init__.py @@ -14,14 +14,18 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from mediagoblin.media_types import MediaManagerBase from mediagoblin.media_types.stl.processing import process_stl, \ sniff_handler -MEDIA_MANAGER = { - "human_readable": "stereo lithographics", - "processor": process_stl, - "sniff_handler": sniff_handler, - "display_template": "mediagoblin/media_displays/stl.html", - "default_thumb": "images/media_thumbs/video.jpg", - "accepted_extensions": ["obj", "stl"]} +class STLMediaManager(MediaManagerBase): + human_readable = "stereo lithographics" + processor = staticmethod(process_stl) + sniff_handler = staticmethod(sniff_handler) + display_template = "mediagoblin/media_displays/stl.html" + default_thumb = "images/media_thumbs/video.jpg" + accepted_extensions = ["obj", "stl"] + + +MEDIA_MANGER = STLMediaManager diff --git a/mediagoblin/media_types/video/__init__.py b/mediagoblin/media_types/video/__init__.py index fab601f6..569cf11a 100644 --- a/mediagoblin/media_types/video/__init__.py +++ b/mediagoblin/media_types/video/__init__.py @@ -14,21 +14,23 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from mediagoblin.media_types import MediaManagerBase from mediagoblin.media_types.video.processing import process_video, \ sniff_handler -MEDIA_MANAGER = { - "human_readable": "Video", - "processor": process_video, # alternately a string, - # 'mediagoblin.media_types.image.processing'? - "sniff_handler": sniff_handler, - "display_template": "mediagoblin/media_displays/video.html", - "default_thumb": "images/media_thumbs/video.jpg", - "accepted_extensions": [ - "mp4", "mov", "webm", "avi", "3gp", "3gpp", "mkv", "ogv", "m4v"], - +class VideoMediaManager(MediaManagerBase): + human_readable = "Video" + processor = staticmethod(process_video) + sniff_handler = staticmethod(sniff_handler) + display_template = "mediagoblin/media_displays/video.html" + default_thumb = "images/media_thumbs/video.jpg" + accepted_extensions = [ + "mp4", "mov", "webm", "avi", "3gp", "3gpp", "mkv", "ogv", "m4v"] + # Used by the media_entry.get_display_media method - "media_fetch_order": [u'webm_640', u'original'], - "default_webm_type": 'video/webm; codecs="vp8, vorbis"', -} + media_fetch_order = [u'webm_640', u'original'] + default_webm_type = 'video/webm; codecs="vp8, vorbis"' + + +MEDIA_MANAGER = VideoMediaManager -- 2.25.1