Media Types

From GNU MediaGoblin Wiki
Jump to navigation Jump to search

Media types are plugin-like

File structure

mediagoblin/media_types/video
├── __init__.py      # Contains the MEDIA_MANAGER
├── migrations.py    # DB migrations
├── models.py        # DB models
├── processing.py    # De-facto standard main file
└── transcoders.py   # Additional python models for video
                     # specifically, name it appropriately
                     # for your media type.

MEDIA_MANAGER

The media manager contains metadata about the media type, along with a reference to the method used to process the media.

MEDIA_MANAGER = {
    "human_readable": "Video",
    "processor": process_video,
    "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"]}

human_readable

A human-readable name for the media type.

processor

A reference to the media processing method for the media type.

sniff_handler

A reference to the sniffing handler for the media type.

display_template

A path to the display template, relative to mediagoblin/templates.

defailt_thumb

No current use.

accepted_extensions

A list containing file extensions that should be associated to this media type. This is used as a fast way to get the media type based on an uploaded file before MediaGoblin falls back to sniffing.