None
Contents:
Recognized extensions for image files. It should be a list
or tuple
of string
s without the leading period. Default:
MMEDIA_IMAGE_EXTS = ('bmp','gif','ico','cur','jpg','jpeg','pcx',
'png','psd','tga','tiff','wmf','xcf','bmp',
'wmf','apm','emf')
Recognized extensions for video files. It should be a list
or tuple
of string
s without the leading period. Default:
MMEDIA_VIDEO_EXTS = ('asf','wmv','flv','mov','mpeg','mpg','mpe','vob',
'qt','mp4','m4v','rm','avi','ogm')
Recognized extensions for audio files. It should be a list
or tuple
of string
s without the leading period. Default:
MMEDIA_AUDIO_EXTS = ('asf','aif','aiff','aifc','flac','au','snd','mid',
'midi','mpa','m4a','mp1','mp2','mp3','ra','xm',
'wav','ogg')
Recognized extensions for SWF files. It should be a list
or tuple
of string
s without the leading period. Default:
MMEDIA_FLASH_EXTS = ('swf',)
Recognized extensions for generic document files. It should be a list
or tuple
of string
s without the leading period. Default:
MMEDIA_DOC_EXTS = ('pdf','xls','doc')
The hachoir_metadata
library allows you to specify how it parses metadata, from 0.0 (fastest) to 1.0 (best quality). Default:
MMEDIA_INFO_QUALITY = 1.0
The size of automatically generated thumbnails for images. It is a two integer tuple for width and height. The default is 100px wide by 80px high. Default:
MMEDIA_THUMB_SIZE = (100, 80)
The Python standard library includes a MIME types map of file extensions to MIME type. However, this map may be incomplete. This setting extends the default mapping. It is a dict
of dot-extensions mapped to MIME type. Default:
MMEDIA_EXTRA_MIME_TYPES = {'.flv':'video/x-flv',}
There are two ways to manage the templates used to render content: via the admin or through files on the computer’s file system. If this setting is False
, there will be a MediaTemplate
model for managing the templates by MIME type. By default, this setting is True
and templates are managed through the path massmedia/
. Massmedia looks in a hierarchy for the correct template. For example, an image with a MIME type of image/jpeg
/massmedia/image/jpeg.html
/massmedia/image/generic.html
/massmedia/generic.html
Where it first looks for the most specific template, and then falls back to more generic templates. Default:
MMEDIA_FS_TEMPLATES = True
TODO
In order to import items from Grab Network, you need an API key.
In order to import items from Grab Network, you’ll also need an API URL.
Add to project settings:
TINYMCE_FILEBROWSER = True
In TINYMCE_DEFAULT_CONFIG add:
extended_valid_elements "-p[class|style]," and "-div[class|style],"
Create URL definition:
url(r'^browse/', 'massmedia.views.browse', name="fb_browse"),
In version 0.8 preliminary support for external services was added. The first service supported was creating a Collection
of a youtube.com playlist.
Creating a collection from a YouTube playlist will not import the videos on the playlist. Because you can change the playlist independently of the Django admin interface, it would be difficult to keep it in sync with YouTube. It is easy to use the Google YouTube API to get all the videos dynamically. See YouTube Collections and Templates.
The YouTube API requires 3 settings, EMAIL
, USERNAME
, PASSWORD
:
MASSMEDIA_SERVICES = {
'YOUTUBE': {
'EMAIL': '',
'USERNAME': '',
'PASSWORD': '',
},
}
YouTube has several different URLs that reference the playlist, depending on how you get to the playlist page.
If you go to any user’s page and click on the “Playlists” button
you can select a playlist from the list on the right.
The address bar address will change to look similar to:
http://www.youtube.com/washingtontimes#p/c/4A35EB2544D73557
If you go to My Videos & Playlists
and select Playlists from the list on the left.
You can use the Link: field URL; which is formatted like:
http://www.youtube.com/view_play_list?p=4A35EB2544D73557
If you look at the URL in the Embed: field, it contains a URL like:
http://www.youtube.com/p/4A35EB2544D73557?hl=en_US&fs=1
This URL requires you to chop off the question mark and everything after it:
http://www.youtube.com/p/4A35EB2544D73557
Collection
object in the admin.For information on displaying the collection, see YouTube Collections and Templates.
The mm_youtube
template tag library handles all the communication with YouTube, plus there are some extra helper tags and filters.
Usage: {% get_youtube_feed <object> as <result> %}
This tag onverts the massmedia.models.Collection
<object>
into an object with the information about the YouTube playlist. The information is stored in the variable specified as <result>
. The <result>
object has two attributes: metadata and entries. The metadata contains information about the playlist, and entries is a list of the videos in the playlist.
Type: A list of dictionaries containing name
and uri
fields.
Example:
{{ result.metadata.author.0.name }}
{{ result.metadata.author.0.url }}
could result in:
washingtontimes
http://gdata.youtube.com/feeds/api/users/washingtontimes
Type: A list of strings.
Example:
{% for cat in result.metadata.category %}
{{ cat }}
{% endfor %}
could result in:
http://gdata.youtube.com/schemas/2007#playlist
washington
news
politics
Type: A string representation of a number for the default number of items retrieved per page.
Example:
{{ result.metadata.items_per_page }}
could result in:
25
Type: A list of dictionaries containing href
, rel
, and type
fields.
Example:
{{ result.metadata.link.0.href }}
{{ result.metadata.link.0.rel }}
{{ result.metadata.link.0.type }}
could result in:
http://www.youtube.com/view_play_list?p=3C046B163FA3957C
alternate
text/html
Comment: Typically there are four links with rel
attributes of:
alternate
http://schemas.google.com/g/2005#feed
http://schemas.google.com/g/2005#batch
self
Type: A string of the URL to the logo set for this playlist.
Example:
{{ result.metadata.logo }}
could result in:
http://www.youtube.com/img/pic_youtubelogo_123x63.gif
Type: A string representing the ID of the playlist.
Example:
{{ result.metadata.playlistId }}
could result in:
3C046B163FA3957C
Type: A string representation of a item number of a paginated result list.
Example:
{{ result.metadata.start_index }}
could result in:
1
Type: A string of the subtitle of the playlist
Example:
{{ result.metadata.subtitle }}
could result in:
The best of The Washington Times YouTube Channel
Type: A string of the title of the playlist
Example:
{{ result.metadata.title }}
could result in:
TWT Home
Type: A string representation of the number of items returned.
Example:
{{ result.metadata.total_results }}
could result in:
15
Type: A string representation of the date this playlist was last modified.
Example:
{{ result.metadata.updated }}
could result in:
2011-04-13T16:37:29.000Z
Type: A list of dictionaries containing name
and uri
fields.
Example:
{{ result.entries.0.author.0.name }}
{{ result.entries.0.author.0.url }}
could result in:
washingtontimes
http://gdata.youtube.com/feeds/api/users/washingtontimes
Type: A list of strings.
Example:
{% for cat in result.entries.0.category %}
{{ cat }}
{% endfor %}
could result in:
http://gdata.youtube.com/schemas/2007#playlist
{'label': 'Entertainment', 'term': 'Entertainment'}
evan rachel wood
the conspirator
robert redford
mildred pierce
liz glover
dawne langford
gucci
jill stuart
washington
d.c.
ford's theater
Type: A list of dictionaries containing count_hint
and href
fields.
Example:
{% for item in result.entries.0.comments %}
{{ item.count_hint }}
{{ item.href }}
{% endfor %}
could result in:
0
http://gdata.youtube.com/feeds/api/videos/DLyt64ZtZcw/comments
Type: A string
Example:
{{ result.entries.0.content }}
could result in:
Liz Glover chats with Evan Rachel Wood at the D.C. Premiere of "The Conspirator."
Type: A string
Example:
{{ result.entries.0.description }}
could result in:
Liz Glover chats with Evan Rachel Wood at the D.C. Premiere of "The Conspirator."
Type: A list of dictionaries containing href
, rel
, and type
fields.
Example:
{{ result.entries.0.link.0.href }}
{{ result.entries.0.link.0.rel }}
{{ result.entries.0.link.0.type }}
could result in:
http://www.youtube.com/watch?v=DLyt64ZtZcw&feature=youtube_gdata
alternate
text/html
Comment: Typically there are six links with rel
attributes of:
alternate
http://gdata.youtube.com/schemas/2007#video.responses
http://gdata.youtube.com/schemas/2007#video.related
http://gdata.youtube.com/schemas/2007#mobile
related
self
Type: A dictionary.
Comment: Because the media
field is complex, each field is discussed separately.
Type: A list of dictionaries with label
, and text
fields.
Example:
{% for cat in result.entries.0.media.category %}
{{ cat.label }}
{{ cat.text }}
{% endfor %}
could result in:
Entertainment
Entertainment
Type: A list of dictionaries with fields: duration
, expression
, isDefault
, medium
, type
, url
, and {http://gdata.youtube.com/schemas/2007}format
.
Example:
{% for item in result.entries.0.media.content %}
{{ item.duration|format_seconds:"i:s" }}
{{ item.expression }}
{{ item.isDefault }}
{{ item.medium }}
{{ item.type }}
{{ item.url }}
{{ item.{http://gdata.youtube.com/schemas/2007}format }}
---------------------------------
{% endfor %}
could result in:
01:05
full
true
video
application/x-shockwave-flash
http://www.youtube.com/v/DLyt64ZtZcw?f=playlists&app=youtube_gdata
5
---------------------------------
01:05
full
video
video/3gpp
rtsp://v4.cache4.c.youtube.com/CiULENy73wIaHAnMZW2G6628DBMYDSANFEgGUglwbGF5bGlzdHMM/0/0/0/video.3gp
1
---------------------------------
01:05
full
video
video/3gpp
rtsp://v4.cache5.c.youtube.com/CiULENy73wIaHAnMZW2G6628DBMYESARFEgGUglwbGF5bGlzdHMM/0/0/0/video.3gp
6
---------------------------------
Type: A string
Example:
{{ result.entries.0.media.description }}
could result in:
Liz Glover chats with Evan Rachel Wood at the D.C. Premiere of "The Conspirator."
Type: A string representing the number of seconds of the movie’s duration.
Example:
{{ result.entries.0.media.duration|format_seconds:"i:s" }}
could result in:
01:05
Type: string of comma-delimited keywords
Example:
{% split result.entries.0.media.keywords ", " as keywords %}
{% for i in keywords %}
{{ i }}
{% endfor %}
could result in:
evan rachel wood
the conspirator
robert redford
mildred pierce
liz glover
dawne langford
gucci
jill stuart
washington
d.c.
ford's theater
Type: A URL string
Example:
{{ result.entries.0.media.player }}
could result in:
http://www.youtube.com/watch?v=DLyt64ZtZcw&feature=youtube_gdata_player
Type: A list of dictionaries with height
, time
, url
, and width
.
Example:
{% for i in result.entries.0.media.thumbnail %}
<img height="{{i.height}}" width="{{i.width}}" src="{{i.url}}" alt="{{time}}">
{% endfor %}
could result in:
<img height="240" width="320" src="http://i.ytimg.com/vi/DLyt64ZtZcw/0.jpg" alt="00:00:32.500">
<img height="90" width="120" src="http://i.ytimg.com/vi/DLyt64ZtZcw/1.jpg" alt="00:00:16.250">
<img height="90" width="120" src="http://i.ytimg.com/vi/DLyt64ZtZcw/2.jpg" alt="00:00:32.500">
<img height="90" width="120" src="http://i.ytimg.com/vi/DLyt64ZtZcw/3.jpg" alt="00:00:48.750">
Type: A string
Example:
{{ result.entries.0.media.title }}
could result in:
Evan Rachel Wood at the D.C. Premiere of "The Conspirator"
Type: A string representing the position of the item in the results.
Example:
{{ result.entries.0.position }}
could result in:
1
Type: A dictionary with fields favorite_count
and view_count
.
Example:
{{ result.entries.0.statistics.favorite_count }}
{{ result.entries.0.statistics.view_count }}
could result in:
0
151
Type: A string
Example:
{{ result.entries.0.title }}
could result in:
Evan Rachel Wood at the D.C. Premiere of "The Conspirator"
Type: A string representation of the date this playlist was last modified.
Example:
{{ result.metadata.updated }}
could result in:
2011-04-13T16:37:29.000Z
Usage: {% split <string or variable> [<split_str>] as <result> %}
This tag is useful for converting a string to a list of strings. Without the split_str
parameter, it will split by space.
Example:
{% split "1 2 3 4" as result %} {# result == ['1', '2', '3', '4'] #}
{% split "1, 2, 3, 4" ", " as result %} {# result == ['1', '2', '3', '4'] #}
{# assuming commalist == "1,2,3,4" #}
{% split commalist "," as result %} {# result == ['1', '2', '3', '4'] #}
Usage: {{ secondsvar|format_seconds:"i:s"}}
This filter formats a number of seconds using the format provided. It is the same formatting options for Django’s date filter.
Each type of media has a customizable template for displaying a thumbnail version and a detail version
They are stored in massmedia/mediatypes/
Templates for each type of media are based on MIME type
Each item looks for a template in this order:
For detail templates:
massmedia/mediatypes/<base_type>/<specific_type>_detail.html
massmedia/mediatypes/<base_type>/generic_detail.html
massmedia/mediatypes/generic_detail.html
For thumbnail templates:
massmedia/mediatypes/<base_type>/<specific_type>_thumb.html
massmedia/mediatypes/<base_type>/generic_thumb.html
massmedia/mediatypes/generic_thumb.html
As an example, an item with a MIME type of application/x-shockwave-flash
would look for its templates in:
massmedia/mediatypes/application/x-shockwave-flash_detail.html
massmedia/mediatypes/application/generic_detail.html
massmedia/mediatypes/generic_detail.html
These templates are only snippets of html for rendering one item and should not contain extra HTML tags (like <head>
or <body>
)