Ticket #688: 0001-Make-all-media-types-use-the-new-MediaManager-classe.patch

File 0001-Make-all-media-types-use-the-new-MediaManager-classe.patch, 7.1 KB (added by praveen97uma, 12 years ago)
  • mediagoblin/media_types/ascii/__init__.py

    From 02f04b9cb5c10c12b9ecea516d99672b946ae225 Mon Sep 17 00:00:00 2001
    From: Praveen Kumar <praveen97uma@gmail.com>
    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 856d1d7..0931e83 100644
    a b  
    1414# You should have received a copy of the GNU Affero General Public License
    1515# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1616
     17from mediagoblin.media_types import MediaManagerBase
    1718from mediagoblin.media_types.ascii.processing import process_ascii, \
    1819    sniff_handler
    1920
    2021
    21 MEDIA_MANAGER = {
    22     "human_readable": "ASCII",
    23     "processor": process_ascii, # alternately a string,
    24                                 # 'mediagoblin.media_types.image.processing'?
    25     "sniff_handler": sniff_handler,
    26     "display_template": "mediagoblin/media_displays/ascii.html",
    27     "default_thumb": "images/media_thumbs/ascii.jpg",
    28     "accepted_extensions": [
    29         "txt", "asc", "nfo"]}
     22class ASCIIMediaManager(MediaManagerBase):
     23    human_readable = "ASCII"
     24    processor = staticmethod(process_ascii)
     25    sniff_handler = staticmethod(sniff_handler)
     26    display_template = "mediagoblin/media_displays/ascii.html"
     27    default_thumb = "images/media_thumbs/ascii.jpg"
     28    accepted_extensions = ["txt", "asc", "nfo"]
     29   
     30
     31MEDIA_MANAGER = ASCIIMediaManager
  • mediagoblin/media_types/audio/__init__.py

    diff --git a/mediagoblin/media_types/audio/__init__.py b/mediagoblin/media_types/audio/__init__.py
    index 4f3ead6..2eb7300 100644
    a b  
    1414# You should have received a copy of the GNU Affero General Public License
    1515# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1616
     17from mediagoblin.media_types import MediaManagerBase
    1718from mediagoblin.media_types.audio.processing import process_audio, \
    1819    sniff_handler
    1920
    20 MEDIA_MANAGER = {
    21     'human_readable': 'Audio',
    22     'processor': process_audio,
    23     'sniff_handler': sniff_handler,
    24     'display_template': 'mediagoblin/media_displays/audio.html',
    25     'accepted_extensions': ['mp3', 'flac', 'wav', 'm4a']}
     21
     22class AudioMediaManager(MediaManagerBase):
     23    human_readable = "Audio"
     24    processor = staticmethod(process_audio)
     25    sniff_handler = staticmethod(sniff_handler)
     26    display_template = "mediagoblin/media_displays/audio.html"
     27    accepted_extensions = ["mp3", "flac", "wav", "m4a"]
     28
     29
     30MEDIA_MANAGER = AudioMediaManager
  • mediagoblin/media_types/pdf/__init__.py

    diff --git a/mediagoblin/media_types/pdf/__init__.py b/mediagoblin/media_types/pdf/__init__.py
    index a6d23c9..f0ba786 100644
    a b  
    1414# You should have received a copy of the GNU Affero General Public License
    1515# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1616
     17from mediagoblin.media_types import MediaManagerBase
    1718from mediagoblin.media_types.pdf.processing import process_pdf, \
    1819    sniff_handler
    1920
    2021
    21 MEDIA_MANAGER = {
    22     "human_readable": "PDF",
    23     "processor": process_pdf, # alternately a string,
    24                                 # 'mediagoblin.media_types.image.processing'?
    25     "sniff_handler": sniff_handler,
    26     "display_template": "mediagoblin/media_displays/pdf.html",
    27     "default_thumb": "images/media_thumbs/pdf.jpg",
    28     "accepted_extensions": [
    29         "pdf"]}
     22class PDFMediaManager(MediaManagerBase):
     23    human_readable = "PDF"
     24    processor = staticmethod(process_pdf)
     25    sniff_handler = staticmethod(sniff_handler)
     26    display_template = "mediagoblin/media_displays/pdf.html"
     27    default_thumb = "images/media_thumbs/pdf.jpg"
     28    accepted_extensions = ["pdf"]
     29
     30
     31MEDIA_MANAGER = PDFMediaManager
  • mediagoblin/media_types/stl/__init__.py

    diff --git a/mediagoblin/media_types/stl/__init__.py b/mediagoblin/media_types/stl/__init__.py
    index edffc63..b691e43 100644
    a b  
    1414# You should have received a copy of the GNU Affero General Public License
    1515# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1616
     17from mediagoblin.media_types import MediaManagerBase
    1718from mediagoblin.media_types.stl.processing import process_stl, \
    1819    sniff_handler
    1920
    2021
    21 MEDIA_MANAGER = {
    22     "human_readable": "stereo lithographics",
    23     "processor": process_stl,
    24     "sniff_handler": sniff_handler,
    25     "display_template": "mediagoblin/media_displays/stl.html",
    26     "default_thumb": "images/media_thumbs/video.jpg",
    27     "accepted_extensions": ["obj", "stl"]}
     22class STLMediaManager(MediaManagerBase):
     23    human_readable = "stereo lithographics"
     24    processor = staticmethod(process_stl)
     25    sniff_handler = staticmethod(sniff_handler)
     26    display_template = "mediagoblin/media_displays/stl.html"
     27    default_thumb = "images/media_thumbs/video.jpg"
     28    accepted_extensions = ["obj", "stl"]
     29
     30
     31MEDIA_MANGER = STLMediaManager
  • mediagoblin/media_types/video/__init__.py

    diff --git a/mediagoblin/media_types/video/__init__.py b/mediagoblin/media_types/video/__init__.py
    index fab601f..569cf11 100644
    a b  
    1414# You should have received a copy of the GNU Affero General Public License
    1515# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1616
     17from mediagoblin.media_types import MediaManagerBase
    1718from mediagoblin.media_types.video.processing import process_video, \
    1819    sniff_handler
    1920
    2021
    21 MEDIA_MANAGER = {
    22     "human_readable": "Video",
    23     "processor": process_video,  # alternately a string,
    24                                  # 'mediagoblin.media_types.image.processing'?
    25     "sniff_handler": sniff_handler,
    26     "display_template": "mediagoblin/media_displays/video.html",
    27     "default_thumb": "images/media_thumbs/video.jpg",
    28     "accepted_extensions": [
    29         "mp4", "mov", "webm", "avi", "3gp", "3gpp", "mkv", "ogv", "m4v"],
    30 
     22class VideoMediaManager(MediaManagerBase):
     23    human_readable = "Video"
     24    processor = staticmethod(process_video)
     25    sniff_handler = staticmethod(sniff_handler)
     26    display_template = "mediagoblin/media_displays/video.html"
     27    default_thumb = "images/media_thumbs/video.jpg"
     28    accepted_extensions = [
     29        "mp4", "mov", "webm", "avi", "3gp", "3gpp", "mkv", "ogv", "m4v"]
     30       
    3131    # Used by the media_entry.get_display_media method
    32     "media_fetch_order": [u'webm_640', u'original'],
    33     "default_webm_type": 'video/webm; codecs="vp8, vorbis"',
    34 }
     32    media_fetch_order = [u'webm_640', u'original']
     33    default_webm_type = 'video/webm; codecs="vp8, vorbis"'
     34
     35
     36MEDIA_MANAGER = VideoMediaManager