Make all media types use the new MediaManager classes.
authorPraveen Kumar <praveen97uma@gmail.com>
Mon, 29 Apr 2013 00:15:05 +0000 (05:45 +0530)
committerElrond <elrond+mediagoblin.org@samba-tng.org>
Tue, 30 Apr 2013 20:09:25 +0000 (22:09 +0200)
mediagoblin/media_types/ascii/__init__.py
mediagoblin/media_types/audio/__init__.py
mediagoblin/media_types/pdf/__init__.py
mediagoblin/media_types/stl/__init__.py
mediagoblin/media_types/video/__init__.py

index 856d1d7b176619ff992dfc3a8854962fc98d5f1d..0931e83a0f9755d20d451ef329261da623dfb739 100644 (file)
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+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
index 4f3ead60a92e38248fa46f60e471c1c2f05110b5..2eb7300e3e12e44f127f76340b58cb3325d1daba 100644 (file)
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+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
index a6d23c93189e4b00f2b71da76512020bed6575dd..f0ba7867d6177dea621c1e90fa84a3d386f96dd6 100644 (file)
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+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
index edffc6336de43aa76f0324589aef0686b346f0e6..b691e43dd0ddf15125ff621773a1ac748c806522 100644 (file)
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+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
index fab601f66fb55f38cdc620053b1826ea35dcbd25..569cf11a3525b9529160c988636e72a3e2047adb 100644 (file)
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+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